Skip to content

Crazy blog

No money, no honey, no funny…

Tag Archives: automation

Today, I research about create project test Coded UI on C# (Microsoft Visual Studio Ultimate 2010). The first time, it creates difficult code, and very hard to read. But I found that I can create the test so simple, don’t need generate code test of Microsoft. Please read this post for more detail about the simple Coded UI test automation

1. Create Test Project: File > New Project > C# Test Project
2. Delete file UnitTest1.cs in Solution Explorer
3. From menu, choose Test > New Test
4. Choose Coded UI Test + name the file as: RunGMail.cs
5. Add this library

using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;

6. Add this script to function CodedUITestMethod1():
BrowserWindow browser = BrowserWindow.Launch(new Uri(""));
HtmlEdit txtUsername = new HtmlEdit(browser);
txtUsername.SearchProperties[HtmlEdit.PropertyNames.Id] = "Email";
txtUsername.Text = "truongkimminh";
HtmlEdit txtPassword = new HtmlEdit(browser);
txtPassword.SearchProperties[HtmlEdit.PropertyNames.Id] = "Passwd";
txtPassword.Text = "your-password";
HtmlInputButton btnLogin = new HtmlInputButton(browser);
btnLogin.TechnologyName = "Web";
btnLogin.SearchProperties.Add(HtmlInputButton.PropertyNames.Name, "signIn");

7. Save and now press F5 to run Test

Tags: ,