Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scraping with some delay
#1
from selenium import webdriver
from selenium.webdriver.support import ui

driver = webdriver.Firefox()
driver.get("http://the-internet.herokuapp.com/dynamic_loading/2")
button = driver.find_element_by_xpath("//*/div[@id='start']/button")

button.click()
print("clicked")

wait = ui.WebDriver.Wait(driver, 10)
wait.until(lambda driver: driver.find_element_by_xpath("//*/div[@id='finish']"))

finish_element=driver.find_element_by_xpath("//*/div[@id='finish']/h4")
print(finish_element.text)
Error:
Traceback (most recent call last): File "C:\Python36\kodovi\click_button.py", line 11, in <module> wait = ui.WebDriver.Wait(driver, 10) AttributeError: module 'selenium.webdriver.support.ui' has no attribute 'WebDriv er'
Don't understand why there isn't a webdriver attribute. What should I put instead to do a scraping after the page is in status 'finish'? How to create object 'wait'?
Reply
#2
its WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
...
WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, ""//*/div[@id='finish']"")))
more info about:
selenium waits
locating elements
By locators
Recommended Tutorials:
Reply
#3
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


driver = webdriver.Firefox()
driver.get("http://the-internet.herokuapp.com/dynamic_loading/2")
button = driver.find_element_by_xpath("//*/div[@id='start']/button")

button.click()
print("clicked")

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//*/div[@id='finish']")))

finish_element=driver.find_element_by_xpath("//*/div[@id='finish']/h4")
print(finish_element.text)
Thank you. This works, just without double quotes for xpath.
Reply
#4
Sorry that was a typo
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Web connection delay ebolisa 5 2,956 Apr-23-2019, 11:07 AM
Last Post: DeaD_EyE
  http.server start delay pastacolsugo 1 2,947 Apr-18-2018, 08:58 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020