Selenium with Chrome Headless fails to get URL

Asked

Viewed 178 times

1

In my test script I simulate the click on a button, which generates and opens a PDF in a new Chrome tab.

//Imprime consulta
IWebElement btnGeraPDF = driver.FindElement(By.Id("id"));
btnGeraPDF.Click();
Thread.Sleep(4000);

//Aguarda fechamento da página em branco da geração do PDF
driver.SwitchTo().Window(driver.WindowHandles.Last());

var urlAbaAtual = driver.Url;
var urlPaginaGeracaoPDF = ".../PDF.ashx?PdfId"; 

while (urlAbaAtual.Contains(urlPaginaGeracaoPDF))            
   Thread.Sleep(2000);

This excerpt works correctly when running the script, except for in headless mode.

Error occurs:

The HTTP request to the remote Webdriver server for URL http://..... timed out after 60 Seconds. -> The request was aborted: The Operation has timed out.

The Exception is displayed in the excerpt driver.Url.

It is the same problem portrayed at this link, except that I don’t use Specflow.

I’ve searched the List of Chromium commands but I haven’t found anything that can solve this problem.

Has anyone ever gone through the same? I currently use these headless commands:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-infobars");
options.AddArguments("--start-maximized");
options.AddArguments("--headless");
options.AddArguments("--log-level=2");
options.AddArguments("--lang=pt-br");
  • Try to use the RemoteWebDriver instead of using the IWebDriver.

  • @Fabiocardoso my project is not structured to use Selenium Grid, I can not apply RemoteWebDriver at the moment, it has to be with IWebDriver same. Any other suggestions?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.