Here is the link.
For Agent machine
- Install Firefox
- Install NUnit Adapter on Visual Studio
- Add Firefox path to PATH
1. Specific agent machine for compatibility
2. In Artifact paths of General Settings: Copy everything from Release folder to another folder (optional)
3. Define steps
3.1 Restore packages
3.2 Build and Package Test solution
/p:Configuration=Release /p:Platform=”Any CPU” /p:FrameworkPathOverride=”C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1″ /p:DeployOnBuild=true;PublishProfile=PackageToZip
3.3 Update Test parameters
echo Username::%Test.Username% > %system.teamcity.build.checkoutDir%\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo Password::%Test.Password% >> %system.teamcity.build.checkoutDir%\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo SiteUrl::%Test.SiteUrl% >> %system.teamcity.build.checkoutDir%\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
3.4 Run UI Test in command line
%system.teamcity.build.checkoutDir%\OmniaTest\UnitTest.CodeBase\bin\Release\TestWindow\vsTest.console.exe “%system.teamcity.build.checkoutDir%\OmniaTest\UnitTest.CodeBase\bin\Release\UnitTest.CodeBase.dll” /UseVsixExtensions:true
Turn on read/write permission for current user on: E:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
vsTest.console.exe %~dp0/UnitTest.CodeBase.dll /TestAdapterPath:”your packages path\Test\Dev\packages”
4. Define Parameters
5. Turn on console mode in the build agent
cs stop TCBuildAgent
ping 192.0.2.2 -n 1 -w 10000 > nul
As always, your UI Test is just focus on what happen on the UI, such as find the element and act on that element. Sometime, all of the steps passed, and you think that this testcase pass? For me, I am not really sure for that.
The answer is “yes”. Here I will show you step by step to setup a UI Test method in Firefox.
1. Install Selenium IDE and Selenium IDE Button extension on Firefox, when you done that, your browser will look like this:
Now, you can record your steps for your testcase. The recorded steps will looks like this:
Now, what we need is export that testcase as C# code:
Now, it is the time for us to hijack the UI to actually override its console error.
In here, we have a loop, trying to add your script to the page until it loaded. Since my page is so slow, my loop is base on second, but you can do the loop base on millisecond without any problem.
Now, in the login method, you just need to call to that method directly after you clicked on sign in button
Now, execute your steps and at the end, just read the errors for the final assert.
Ok, but what is “ReadErrors”? Ah, it is also an extension method to help us get all of console errors.
Yeah, everything seem finished. Now, you just need to run the test to see how it works.
To run the test, open command prompt and type:
Woa, for my testcase, I see this result:
When everything are ready, you should have an account and all the related apps like this:
In my case, my account is: email@example.com
And, if you want to add this account to your Visual Studio Online project. Go to “Members” and add new user:
In the popup, type the account there, but unlucky, you see something like “No identities found”:
Don’t worries, just go ahead and click on “Save changes”.
Then, use another browser (or another user on same browser) and access to your project link, my case: https://mysub.visualstudio.com/myproject
The login form will display for you to enter your account, but ops! What the hell is this?
Most of us will give-up at this time, but why? Why don’t you just go ahead and create a Microsoft account similar with O365 account and use it for both?
Then, go with some other steps and you are ready to use that account for your Visual Studio Online project.
Annoying, because they are still 2 difference users. So you still need to select a correct type when you want to access to any of them.