-2

I tried this

WebDriverWait(web.driver,1000000000000000000000000000000000000000000000000)

and it did nothing literally nothing.

The web is also changing dynamically new elements are introduced to it and the code doesn't exist in the page_source of the new elements.

please help I have been stuck on this all morning

I'm using geckodriver for firefox python 3

test code

_browser_profile = webdriver.FirefoxProfile()
_browser_profile.set_preference("dom.webnotifications.enabled", False)
driver=webdriver.Firefox(firefox_profile= _browser_profile)
driver.get("https://www.google.com/")
wait= WebDriverWait(driver,10)
driver.get("https://www.youtube.com")
  • Would be nice if you provide a link to the page, or relevant html and also error you get and the code snippet you have so far – Andrei Suvorkov Jul 06 '18 at 15:02
  • The problem is that i'm not getting any errors – Syched Flow Jul 06 '18 at 15:05
  • min i will provide the code – Syched Flow Jul 06 '18 at 15:05
  • Possible duplicate of [How to wait until the page is loaded with Selenium for Python?](https://stackoverflow.com/questions/26566799/how-to-wait-until-the-page-is-loaded-with-selenium-for-python) – JeffC Jul 06 '18 at 18:53
  • a function is not working as it should be in selenium. that's my question why does this code doesn't work. sadly any wait function doesn't work with me even the code in ur referred site – Syched Flow Jul 06 '18 at 19:12

1 Answers1

2

This is just declaration of explicit wait.

This will do nothing WebDriverWait(web.driver,1000000000000000000000000000000000000000000000000) , if you do not bind it with EC which is expected conditions.

Something like this you have to do :

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))  

More about Explicit wait can be found at Selenium python wait

UPDATE :

The code you have shared , you are just letting your script know that it has explicit wait.

You are not using explicit wait at all.

driver.get("https://www.google.com/")
search_bar = wait.until(EC.element_to_be_clickable((By.NAME, 'q')))
search_bar.sendkeys("Hi Google")

Note that, you have to import this :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC  

I do not know why @Andrei has provided you the worst kind of explicit wait which is nothing but time.sleep(10) which should be avoided as much as possible.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • 1
    sadly it's like there is no waiting is waiting there – Syched Flow Jul 06 '18 at 15:10
  • Sorry , I did not get you. Where no waiting is written ? – cruisepandey Jul 06 '18 at 15:11
  • 1
    it's as if i did not write wait = WebDriverWait(driver, 10) , i dont know but i think it's a problem with the software not the code – Syched Flow Jul 06 '18 at 15:13
  • I originally used that code before the wait but it doesnt work so i tried to look where the problem is and found out that wait doesn't work.. well at this point im really desperate for a solution anything that makes this thing work :\ . – Syched Flow Jul 06 '18 at 15:24
  • scroll down wait untill an element show up and then extract it use some regular expression and print it in text.. I did everything .the weird thing is when i scroll down and ask for page_source i only get the old html.I also tried to find the element by command without the source but the driver is still clueless. – Syched Flow Jul 06 '18 at 15:38
  • is it possible that the webdriver is not compatibale with my firefox version ? how can i check that ? – Syched Flow Jul 06 '18 at 15:38
  • geckodriver-v0.21.0 .. firefox v61, i think it's compatibale – Syched Flow Jul 06 '18 at 15:41
  • Yes it is not an issue with drivers though. Once you have scroll down , try to do refresh and then try to get the page_source – cruisepandey Jul 06 '18 at 15:46
  • the driver would get the HTML code of the url which is not exactly why i'm running a webdriver instead of requests unless that's not what you meant right? – Syched Flow Jul 06 '18 at 15:55
  • I am not able to get you properly. – cruisepandey Jul 06 '18 at 15:58
  • the url doesnt change when i scroll down. if i reload it everything i wanted to catch is gone – Syched Flow Jul 06 '18 at 16:02
  • Then in that case , you will have to wait till the DOM updates , try to wait till the time when last element get visibility. – cruisepandey Jul 06 '18 at 16:07
  • wait.until(EC.visibility_of_element_located((Your locator , 'locator value'))) – cruisepandey Jul 06 '18 at 16:08