Selenium WebDriver tests failure in TFS build process - c#

I use ChromeDriver for web application testing. Unit tests work OK locally on my machine. But when I start automated test run on build server it fails with an exception on new ChromeDriver():
System.ComponentModel.Win32Exception: The system cannot find the file specified.
All required binaries exist in TestResults\Out folder. Sample console program with ChromeDriver works fine on build machine. I tried to start build service in interactive (console) mode, but it did not help either.
Any suggestions?

Related

Selenium webdriver integration with Jenkins

How can I integrate selenium webdriver c# - MSunit tests to run on the Jenkins server as part of CI/CD
you need to use step Windows Batch Script and write there the exact command which is executing your tests locally (not from IDE but from local command promot or powershell)
after that if you need to publish test results consume plugin for MSunit and give the path of generated test rauls file to it.

Unable to execute CodedUI tests from VSTS

I have created a CodedUI project in VS2017, i am able to execute the tests on my machine directly in VS2017.
I can easily bind test methods to VSTS online Test case. However, when i build and deploy the project and the assemblies on VSTS online and try to lauchn them from VSTS, i always got errors related to Deploying a Test agent on target machine(s) to be able to execute the test.
Just for information, the web pages we want to test are on a on-premise website, so not accessible from internet.
Do someone know how to make this work, ie how to set up the test machine, how to set up the Test agent on that machine (the microsoft documentation is not reallly clear about that), and what we need to make VSTS be able to communicate with our on-premise test machine.
The easy way is that you can setup a private build agent that can access test machine, then build the project through this private agent: Deploy an agent on Windows.
If you want to use Hosted agent, your test machine need to be accessible from internet.

Use TeamCity to run Selenium test, but not headless

I have done some research on this, but still confused.
Im using Selenium 3 (C#) with a Chromedriver, Nunit 2.6.4, Visual Studio 2015, TFS and TeamCity 9.
I would like to run a Selenium test, using TeamCity, but I want to physically see the test run. I dont want it to run as a background process. I've seem some say something about running the user agent not as a windows service or to run it manually with some script. But this is where I get confused.
Do I have to add additional code to the project or do it some other way, like a batch file. Or is there another way to run the test in a non headless browser?
Im pretty new to this, so please be gentle.
Thanks in advance.
David
If you are running the TeamCity agent as a service they use a "hidden" desktop and you can't see them run.
You can run the the TeamCity agent as a process by opening cmd as administartor, change directory to BuildAgent\bin and write agent.bat start. Then you should be able to see the tests run. Remember to stop the service first
Go to The agent's service.properties and then set "web.app=true". It will be under the agent directory as "D:\BuildAgent3" if agent is installed on D drive.
Restart your agent..
From Now onwards, you should see the browser running in headful mode.
It worked for us in past, but later on we moved on to a Selenium Grid and hence this setting is not in use for us.
Let me know if it helps..!

Detect if my tests are running on Visual Studio Team Services

I've wrote a lot of integration tests for an API I'm working on.
If I run the integration tests locally I want to self host the API and run the integration tests against it.
However I have a build definition on VS Team services that runs the integration test after the API was deployed, I want to run the tests against the deployed API, but to do that I have to change my code so it no longer self host it and instead tested against the deployed API.
Is there a way to detect at runtime where my tests are being run?
Thanks
Just probe for one of the VSTS predefined build variables. For example:
if (Environment.GetEnvironmentVariable("SYSTEM_DEFINITIONID") != null)
{
Console.WriteLine("Running from VSTS...");
}
If you are using VSTS Hosted Build agent to run the build and test, the machine name of these agents has a format like "TASKAGENTX-XXXX". You can use it (Environment.MachineName) to determine if the test is ran on VSTS or your local machine.
By the way, what is the difference between the testing run on your local machine and VSTS? Is it just a different URL? If yes, you can add a config file to your project and update your tests to read the URL in the config file for testing. And then use SlowCheetah to perform a transformation to switch the URL when build and test from VSTS.

Unit testing a c# Windows 10 IoT core application (Error : DEP0700)

I'm trying to write some unit tests for a windows 10 IoT core application I have written for my Raspberry Pi (arm architecture). I have added a new Unit Test App project to my solution and added namespace reference. When I try to run the tests from test explorer however, I get:
Error : DEP0700 : Registration of the app failed. Windows cannot install package 29113fce-56cd-4094-9a21-ee91498c14b2 because the package requires architecture ARM, but this computer has architecture x64.
Deploying the test app to the remote machine (Pi) results in Tests running printing to the screen, however nothing happens. The tests still don't run on my machine and when i select tests on the output console it displays nothing.
Does anyone have any experience unit testing a Windows 10 IoT core application or can see anything immediately obvious I've done wrong?
There are two ways you can run the tests:
Run the whole application in local machine (x86) and also the tests. If the app is UWP, and does not use much of RPi-specific functionality, this should be the easiest way.
Do the remote testing, with application running on RPi. To do that, you need to install Remote Debugging Tools for Visual Studio on the target RPi board. This article describes it in more detail.

Categories