I am using the Selenium ChromeDriver for the first time to automate a chrome web page. I am using VBA in an excel spreadsheet to do the macro.
The Philip Treacy video https://www.myonlinetraininghub.com/web-scraping-filling-forms is very helpful.
If I filter the data enough (so the downloaded file does not take more than 60 seconds to be created), your recommended command for clicking the button works fine:
Driver.FindElementByClass("button-content").Click
After doing some research, I altered the command to include a longer timeout so now it is this
Driver.FindElementByClass("button-content", timeout:=480000).Click
The problem I am having is that there is a delay after clicking a button on the webpage (could be 2 minutes or more) before the downloaded file finished downloading.
After 60 seconds I am getting a Microsoft Visual Basic Run-Time error "21": Timeout error. Timeout: timed out receiving message from rendered: 60:000. (Session info: Chrome=103.0.5060.53. Driver Info: Crimedriver=103.0.5060.53 (a1711811edd74ff1cf2150f36ffa3b0dae40b17f-refs/branch-heads/506 NT 10.0.19044 x86_64)
It seems that even though I am adding a explicit wait of 480 seconds (8 minutes) after hitting the click button, that I am actually only given 60 seconds before it times out. Am I writing the timeout wrong? Is there a better way to force Selenium to wait longer before proceeding. By the way, nothing changes on the screen after it is done with the download. I can look for the downloaded file to see if it exists, but don't know how to write the click method in the way that it waits until the downloaded file is created before moving on.
Hi Phillip,
There are multiple ways to set a timeout:
driver.Timeouts.ImplicitWait = 5000 ' 5 seconds
As well as individually :
driver.FindElementById("id", timeout:=10000).Click ' implicitly wait of 10sec
driver.FindElementById("id", timeout:=0).Click ' no implicit waiting
To set the timeout for the server that runs the browser:
driver.Timeouts.Server = 120000 ' 2 mins
source: https://stackoverflow.com/questions/32348486/how-to-make-selenium-wait-for-the-page-to-fully-load-in-selenium-wrapper-for-e