2
I created a program to log in to the site, but it loads very slowly when it opens, and for that I need to put Sleep(40), which waits 40 seconds to open, but sometimes it takes 50 seconds and error and has hours that takes 20 seconds and is long idle, I tried the webdriverwait but it didn’t work, would have any solution to give me? This code contains the following error: Selenium.common.exceptions.Timeoutexception: Message:
driver = webdriver.Chrome('C:\scrapy\chromedriver', chrome_options=chrome_options)
driver.get('site')
#sleep(25)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "elementEmail"))
)
email = driver.find_element_by_xpath('//*[@translate="@APP-COMMON-EMAIL"]')
email.click()
That one
WebDriverWait
that you put is waiting at most 10 seconds - if you said the minimum is 20, maybe you’re waiting a little? Increase to 100 seconds and see if it improves.– nosklo
But that’s the problem, I don’t want you to wait a lot of time, I want him to automate, outside that this code is giving error
– guilherme
So - the purpose of
WebDriverWait
is to wait until the element appears. You have to put a time well above what you need, because it will wait at most that time - the idea is that if the element is located it stops waiting immediately, So you have to give him enough time to be located. The code must be failing because you put a very short time, after 10 seconds the element has not yet appeared.– nosklo
Yes, thank you, it worked now, I had misunderstood
– guilherme