8
votes

I'm currently running Selenium with Specflow.

One of my tests clicks on a button which triggers the download of a pdf file. That file is automatically opened in a new tab where the test then grabs the url and downloads the referenced file directly to the selenium project. This whole process works perfectly when chrome driver is run normally but fails on a headless browser with the following error:

The HTTP request to the remote WebDriver server for URL http://localhost:59658/session/c72cd9679ae5f713a6c857b80c3515e4/url timed out after 60 seconds. -> The request was aborted: The operation has timed out.

This error occurs when attempting to run driver.Url

driver.Url calls work elsewhere in the code. It only fails after the headless browser switches tabs. (Yes, I am switching windows using the driver)

For reference, I cannot get this url without clicking the button on the first page and switching tabs as the url is auto-generated after the button is clicked.

1
I am also having this issue, did you ever find a solution?Nathanael

1 Answers

0
votes

I believe you are just using argument as "--headless" for better performance you should select screen size too. Sometimes, due to inappropriate screen size it cannot detect functions which you are looking for. try using this code or just add one line for size.

from selenium import webdriver
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
driver = webdriver.Chrome(chrome_options=chrome_options)

Don't forget to put other arguments according to your need in "driver".