Automated testing for web application with Visual Studio CodedIUTest without recordings

Author: Ferran Sánchez

If you want to do testing on a web application you can have an alternative with CodedIUTest tool of Visual Studio but without recordings. In this methodology you can use objects such as HtmlHyperlink, HtmlInputButton and HtmlEdit to access to their characteristics directly (see

It is known that the recording tool of Visual Studio provides internet explorer as default browser. The key point to work with a different browser is to initialize a static variable BrowserWindow to select the browser and launch web page. For example, if you want to work with Chrome you must write: BrowserWindow.CurrentBrowser = “chrome”;

After that, you can begin the automated testing web. The following example shows this possibility providing data source like a .csv file for data input parameters.

Also, to work with a different browser you must take into account the next preconditions:

1 – Configuration of “Selenium Components for Coded IU Cross”:

2 – Troubleshoot: If you have some error when you run tests on Chrome browser, you can download another version on

public class CodedUITest1
	// Static var for launch the browser window
	BrowserWindow browser;
	public CodedUITest1()
	// Initialize browser and web page
	public void MyTestInitialize()
		BrowserWindow.CurrentBrowser = "chrome";
		browser = BrowserWindow.Launch(new Uri(""));
		browser.Maximized = true;
		browser.CloseOnPlaybackCleanup = false;
	[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\dataAmazon.csv", "dataAmazon#csv", DataAccessMethod.Sequential), DeploymentItem("dataAmazon.csv"), TestMethod]
	public void CodedUITesAmazonHandcoding()
		// Assert Vender tab string
		HtmlHyperlink VenderTabString = new HtmlHyperlink(browser);
		VenderTabString.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Vender");
"Vender", VenderTabString.InnerText.Trim());

		HtmlHyperlink VenderTab = new HtmlHyperlink(browser);
		VenderTab.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Vender");
		// Assert "Vender tus productos" string
		HtmlSpan labelVender = new HtmlSpan(browser);
		labelVender.SearchProperties[HtmlSpan.PropertyNames.InnerText] = "Vende tus productos en Amazon";
		Assert.AreEqual("Vende tus productos en Amazon", labelVender.InnerText.Trim());
		// Assert Ofertas tab string
		HtmlHyperlink OfertasTabString = new HtmlHyperlink(browser);
		OfertasTabString.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Ofertas");
		Assert.AreEqual("Ofertas", OfertasTabString.InnerText.Trim());

		// Assert Ayuda tab string
		HtmlHyperlink AyudaTabString = new HtmlHyperlink(browser);
		AyudaTabString.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Ayuda");
		Assert.AreEqual("Ayuda", AyudaTabString.InnerText.Trim());
		HtmlHyperlink AyudaTab = new HtmlHyperlink(browser);
		AyudaTab.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Ayuda");
		// Verify "contraseña" wrong
		HtmlHyperlink IdLink = new HtmlHyperlink(browser);
		IdLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id, "nav-link-yourAccount");
		//Assert "Contraseña" string
		HtmlLabel labelCont = new HtmlLabel(browser);
		labelCont.SearchProperties[HtmlLabel.PropertyNames.InnerText] = "Contraseña";
		Assert.AreEqual("Contraseña", labelCont.InnerText.Trim());

		HtmlEdit MailInput = new HtmlEdit(browser);
		MailInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "ap_email");
		MailInput.Text = TestContext.DataRow["user"].ToString().Trim();
		HtmlEdit PasswordInput = new HtmlEdit(browser);
		PasswordInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "ap_password");
		PasswordInput.Text = TestContext.DataRow["password"].ToString().Trim();

		HtmlInputButton IniciarButton = new HtmlInputButton(browser);
		IniciarButton.SearchProperties.Add(HtmlInputButton.PropertyNames.Id, "signInSubmit");