2
votes

I am trying to run selenium UI tests through vsts release pipeline usingVisual Studio Test tasks from vsts release. My tests are getting recognized but not getting executed. getting same error for all tests.

I have tried updating the chrome drive used the old chrome driver still no luck. Initially I was using the chromedrive.exe file in my sln but then I removed that and add a nuget reference form Selenium.Chrome.Webdriver 2.45. tests are running fine on my local machine but when I deploy on vsts agent server I am getting an error

this the error I am getting in my VsTest log

Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on port 4620
Only local connections are allowed.
Failed   _MenuConfirmation
Error Message:
 OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:4580/session/1315de45cb967b450b25cef659f6/window/current/size timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
Stack Trace:
at 
OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWindow.set_Size(Size value)
at abc.AutomatedTests.BaseTestingClass.CommonInit() in D:\teams\build4\_work\1\s\src\abc.AutomatedTests\BaseTestingClass.cs:line 43
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)   

In my basetestingclass.cs I have code to launch the browser and set its size.

[SetUp]
public void CommonInit()
    {
        driver = new SeleniumDriver (browser).getdriver();
        driver.Navigate().GoToUrl(url);
        driver.Manage().Window.Size = new Size { Width = 1920, Height = 1080 };
        //driver.Manage().Window.Maximize();
    }

In my prior tries I was getting same error for Maximize() code.

This is was added in mu csproj after the nuget addition

 <Import Project="..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets" Condition="Exists('..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets')" />

and this in packages.

<package id="Selenium.Chrome.WebDriver" version="2.45" targetFramework="net452" />

I want to Run the selenium tests In my VSTS pipeline using the Visual Studio Test. Also I have Visual Studio Test Platform Installer task prior to test execution task in my pipeline and my tests are getting recognized successfully.

I tried most of the available solution but still the same error. hence asking again.

1

1 Answers

0
votes

The error message indicates that the agent you are running the UI tests on can't reach the URL you've specified.

Are you using a hosted agent in the release pipeline in AzDO? If so, it won't have line of sight to your localhost URL. Check that by changing your URL to google.com or bing.com and it should be able to run the test successfully.

Install a self-hosted agent on your machine instead: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops#install

Or follow this: https://www.azuredevopslabs.com/labs/vstsextend/selenium/.

You'll want to make sure that the appropriate NuGet packages for Selenium are also getting restored but I don't think that's specifically related to this error you're getting.