1

I'm currently facing an issue trying to run a selenium web automation with firefox(headless) on azure devops, I have the same browser version installed on the windows agent but still I get errors. It works fine for Chrome on Azure and also locally it works fine for firefox so not really sure what is causing this issue. These are the logs:

NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
1640697828054   geckodriver INFO    Listening on [::1]:58930
1640697828085   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "enable-automation" "--no-sandbox" "--headless" "--disable-gpu" "--window-size=1920,1080" "-foreground" "-no-remote" "-profile" "C:\\Users\\agent\\AppData\\Local\\Temp\\rust_mozprofileQUnaTu"
1640697829048   Marionette  INFO    Marionette enabled
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at C:\\Users\\agent\\AppData\\Local\\Temp\\rust_mozprofileQUnaTu\\search.json.mozlz4", (void 0)))
1640697832365   Marionette  INFO    Listening on port 58933
1640697832633   RemoteAgent WARN    TLS certificate errors will be ignored for this session
1640697866771   Marionette  INFO    Stopped listening on port 58933
Given is presented the home page
-> error: Timed out after 30 seconds (33.8s)
And the user enters his credentials "empty"
-> skipped because of previous errors
Then Corresponding error message is displayed "empty"
-> skipped because of previous errors
1640697868763   geckodriver INFO    Listening on [::1]:59006
  Failed LoginWithBadInput("empty",null) [41 s]
  Error Message:
   OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
  ----> OpenQA.Selenium.NoSuchElementException : Unable to locate element: //h2[contains(text(),'Sign in with your email address')]
  Stack Trace:
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
   at LFL.Automation.Framework.Actions.BaseActions.WaitFor(By by) in C:\agent\_work\3\s\Automation.Financial.Framework\Actions\BaseActions.cs:line 34
   at ClientPortalAutomationFinal.Pages.LoginPage.ConfirmLoginPage() in C:\agent\_work\3\s\ClientPortalAutomationFinal\Pages\LoginPage.cs:line 49
   at ClientPortalAutomationFinal.Steps.LoginSteps.GivenIsPresentedTheHomePage() in C:\agent\_work\3\s\ClientPortalAutomationFinal\Steps\LoginSteps.cs:line 29
   at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments, TimeSpan& duration)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
   at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
   at ClientPortalAutomationFinal.Features.LoginFeature.ScenarioCleanup()
   at ClientPortalAutomationFinal.Features.LoginFeature.LoginWithBadInput(String flag, String[] exampleTags) in C:\agent\_work\3\s\ClientPortalAutomationFinal\Features\Login.feature:line 8
--NoSuchElementException
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
   at OpenQA.Selenium.By.<>c__DisplayClass19_0.<XPath>b__0(ISearchContext context)
   at OpenQA.Selenium.By.FindElement(ISearchContext context)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
   at LFL.Automation.Framework.Actions.BaseActions.<>c__DisplayClass11_0.<WaitFor>b__0(IWebDriver drv) in C:\agent\_work\3\s\Automation.Financial.Framework\Actions\BaseActions.cs:line 34
   at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)

Based on this looks like the browser it's opening but not able to navigate the website not really sure. Hopefully someone has some idea of what could be the issue, thanks!

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Yuri
  • 13
  • 1
  • 5
  • Hi Yuri Valverde; is your test runner able to take screenshots? If not, I recommend you switch to a test runner which does, because they are *invaluable* for debugging failed tests. – Vince Bowdren Dec 28 '21 at 15:36
  • Thanks for the answer, the issue was that the Firefox version got updated on the host machine without me knowing so that was causing the issue for the page not to load, I matched the version that I have in my local machine and it worked. – Yuri Jan 13 '22 at 21:54

1 Answers1

0

This error message...

 OpenQA.Selenium.WebDriverTimeoutException : Timed out after 30 seconds
----> OpenQA.Selenium.NoSuchElementException : Unable to locate element: //h2[contains(text(),'Sign in with your email address')]

...implies that NoSuchElementException while trying to locate the element with the locator strategy.


Generally <h2> tags are header elements. Ideally, to locate any visible element you need to induce WebDriverWait for the ElementIsVisible() and you can use the following Locator Strategy:

  • Using XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementIsVisible(By.XPath("//h2[contains(., 'Sign in with your email address')]")));
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352