Not able to use “explicit wait” in my code

0 votes

I've written a script using python with selenium to click on some links listed in the sidebar of google maps. When any of the items get clicked, the related information attached to each lead shows up in the right sided area. The script is doing fine. However, I've used hardcoded delay to do the job. How can I get rid of hardcoded delay by achieving the same with explicit wait. Thanks in advance.

Link to the site is this.

The script I'm trying with:

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

link = "replace_with_above_link"

driver = webdriver.Chrome()
driver.get(link)
wait = WebDriverWait(driver, 10)

for item in wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "[id^='rlimg0_']"))):
    item.location
    time.sleep(3)  #wish to try with explicit wait but can't find any idea
    item.click()

driver.quit()

I tried with wait.until(EC.staleness_of(item)) instead of hardcoded delay but no luck.

Mar 27, 2018 in Selenium by code_ninja
• 6,220 points
89 views

1 answer to this question.

0 votes

To wait until the entire data has been displayed after each click, use the below code:

for item in wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "[id^='rlimg0_']"))):
    div = driver.find_element_by_xpath("//div[@class='xpdopen']")
    item.location
    item.click()
    wait.until(EC.staleness_of(div))
answered Mar 27, 2018 by nsv999
• 5,090 points

Related Questions In Selenium

0 votes
1 answer

Not able to identify datepicker in chrome for my site "tui.co.uk".

Dear Vamshi, After clicking on the date box ...READ MORE

answered Jun 20, 2018 in Selenium by walter 123
• 240 points
64 views
+3 votes
1 answer

Not able to run in chrome

There is a very silly mistake in ...READ MORE

answered May 15, 2018 in Selenium by king_kenny
• 3,650 points
420 views
0 votes
1 answer

Not able to open a new URL in a new tab in Selenium

There is a bug in ChromeDriver that ...READ MORE

answered May 21, 2018 in Selenium by Meci Matt
• 9,420 points
8,543 views
0 votes
1 answer

Impilicit wait vs Explicit wait vs Fluent wait

Implicit wait: Your telling the WebDriver the ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,650 points
904 views
0 votes
1 answer

Implicit wait & Explicit wait in selenium WebDriver

Implicit Wait:  While loading a web page in ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,420 points
183 views
0 votes
1 answer
0 votes
2 answers
0 votes
3 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 12 in Selenium by anonymous
10,037 views
0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,090 points
1,079 views