selenium components.
If we have a dedicated agent
machines with browser to run the
coded ui test with
out modifying the code.
For this i am using the system
variables. In each machine i will
create a system variable name:browser and
value is like "IE"
or "Chrome" or "Firefox"
ect
Ex: Agent-1 should run with IE browser
and Agent-2 should run
with Chrome browser...
Download the
Selenium components from below link
After
installing the cross-browser testing installer, verify that
Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowserProxy.dll
Microsoft.VisualStudio.TestTools.UITest.Extension.CrossBrowserProxy.dll
is found
in the following location:
"%ProgramFiles%\Common Files\microsoft
shared\VSTT\Cross
Browser Selenium Components" (for 32 bit
machines)
"%ProgramFiles(x86)%\Common Files\microsoft
shared\VSTT\Cross
Browser Selenium Components" (for 64 bit machines)
Download chrome driver from below link
Download selenium dot net bindings from:
Right click on the downloaded zip files.
Select "properties".
Under "General" tab, click on the "Unblock" button.
Now unzip both the files and copy the contents to the following path
(for the selenium-dotnet 2.43.1 binaries, copy the contents of net40 folder):
"%ProgramFiles%\Common Files\microsoft
shared\VSTT\Cross
Browser Selenium Components" (for 32 bit
machines)
"%ProgramFiles(x86)%\Common Files\microsoft
shared\VSTT\Cross Browser Selenium
Components" (for 64 bit machines)
Supported versions
This installer works with VS 2012 Update 4,
VS 2013 VS 2013 update 3
and VS 2013 Update 4.
Supported Browser versions
The following versions of browsers have been
verified and are
supported: Firefox 33.
Latest version of Chrome (version
38.0.2125.111 m as of 11/14/2014)
Setting
Environment Variables for Coded UI
Create environment
variable on each agent machine and set its value
as the desired browser name
(IE8/IE9/Chrome/Firefox) against which
you want to run your automated tests.
1.Go
to “My Computer” Right click and select “Properties”
2.Click
on “Advance System Settings”
3.Go
to “Advance Tab” and the click on “Environment Variables”
4.Under
“system variables” section click on “New”
5.Give
the “Variable Name” and “Variable Value”
6.Click
on “ok” and again click on “ok” and again click on “ok”.
7.Create
a Test Initialize method and read the value of the environment variable before
test starts on each agent machine.
This will return the name of the browser
that needs to be used
for playing back automation.
String browser;
[TestInitialize]
public void Init()
{
browser = Environment.GetEnvironmentVariable("LaunchBrowser");
}
8.Inside
your test method, set “BrowserWindow.CurrentBrowser”
value
as “browser” which holds the browser
name stored in
environment variable
Sample code…
[TestMethod]
public void CodedUITestMethod1()
{
BrowserWindow.CurrentBrowser = browser;
this.UIMap.RecordedMethod1();
this.UIMap.AssertMethod1();
}
Depending on the value stored in the environment variable, Coded UI launches the browser and runs the test against launched browser.