Forum Discussion

littlebear's avatar
littlebear
Contributor
4 months ago

ADO Microsoft-Hosted Agent unable to navigate control

Hello,

I am trying to get an ADO pipeline to run a Keyword test, and it is failing to do so.

The Keyword test has one enabled step, to navigate to https://www.subzero-wolf.com/ in the Chrome browser. This step functions perfectly when it is run locally on my computer (there's not much that could go wrong). The pipeline has three steps in it: one which installs the Visual Studio Test Platform; one which installs the test runner, in this case I am using TestExecute; and the final VSTest step, which is in charge of running the Keyword Tests. 

The first two steps succeed just fine, but on the last step the pipeline throws the error that the test was "Unable to navigate to the https://... page"

 

The pipeline agent is an MS-Hosted agent, called 'windows-latest'. I have a feeling that there is something wrong with the environment we are running the test in, but I don't have enough knowledge to determine what should be added or removed. I would be happy to provide you with any further information I can give you about the state of the pipeline. 

Thank you for your assistance!

  • Hi everyone, I have the solution.

    The Chrome "Choose your user" menu was popping up before the browser could load, and my test was not taking that into account.

    The SmartBear support work around for this as of 8/15/2024 is to add a PowerShell command in between the InstallTestCompleteAdapter step and the VSTest step. This tells Chrome that you are using a particular user, so you go immediately to the browser:

    - powershell: 
        $chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe" 
        Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Google\Chrome -Name PasswordManagerEnabled -Value 0 
        Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Google\Chrome -Name PrivacySandboxPromptEnabled -Value 0 
        Start-Process $chromePath -ArgumentList "--profile-directory=Default", "--no-first-run", "--disable-search-engine-choice-screen" 
        if (Test-Path -Path $chromePath) { 
            $chromeVersion = (Get-Item $chromePath).VersionInfo.ProductVersion 
            Write-Host "Chrome version: $chromeVersion" 
        }
        else{ 
        Write-Host "Chrome not found at the default location." 
        } 
        Start-Sleep -Seconds 60 
        Stop-Process -Name 'chrome' 
        Start-Process $chromePath -ArgumentList "--profile-directory=Default", "--no-first-run", "--disable-search-engine-choice-screen" 
      displayName: "Chrome Set Up"

    In my file, which can be seen in another thread, this code would start on line 23 and end on line 38. 

    Good luck!

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Have you looked at the test results file that was generated? It might give you more information.

    It's also helpful to mention the parameters or settings used in the pipe line - it could be a configuration issue.

    • littlebear's avatar
      littlebear
      Contributor

      Thank you for your advice.

      Looking at the test results file generated by ADO, it doesn't have any problems visible as I go line by line, except for the strange error that is thrown above. Is there a different test results file I should look at?

      As to the parameters or settings, this is the YAML file in its entirety: 

      While I attach this YAML file, the problem doesn't seem to be here, because these steps work are working as they're supposed to. Even VSTest is doing its job when it reports that the test failed. It is when, in the VSTest step, the job tries to run a test in the virtual environment that we cannot even open a browser to navigate to a website.

  • If you run the first two steps from the pipeline and then try to get to the website manually from that machine, does it work?

  • Unfortunately, since I am using an MS-hosted agent, I don't have access to the machine itself. The test does run correctly on my machine, which has the same capabilities as the first two steps of the job ought to give to the MS-hosted machine.

  • Hi everyone, I have the solution.

    The Chrome "Choose your user" menu was popping up before the browser could load, and my test was not taking that into account.

    The SmartBear support work around for this as of 8/15/2024 is to add a PowerShell command in between the InstallTestCompleteAdapter step and the VSTest step. This tells Chrome that you are using a particular user, so you go immediately to the browser:

    - powershell: 
        $chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe" 
        Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Google\Chrome -Name PasswordManagerEnabled -Value 0 
        Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Google\Chrome -Name PrivacySandboxPromptEnabled -Value 0 
        Start-Process $chromePath -ArgumentList "--profile-directory=Default", "--no-first-run", "--disable-search-engine-choice-screen" 
        if (Test-Path -Path $chromePath) { 
            $chromeVersion = (Get-Item $chromePath).VersionInfo.ProductVersion 
            Write-Host "Chrome version: $chromeVersion" 
        }
        else{ 
        Write-Host "Chrome not found at the default location." 
        } 
        Start-Sleep -Seconds 60 
        Stop-Process -Name 'chrome' 
        Start-Process $chromePath -ArgumentList "--profile-directory=Default", "--no-first-run", "--disable-search-engine-choice-screen" 
      displayName: "Chrome Set Up"

    In my file, which can be seen in another thread, this code would start on line 23 and end on line 38. 

    Good luck!