Coded UI and HTML: way easier

… than Silverlight:

SUT:

HtmlCodedUI01

Coded ui test:

HtmlCodedUI02

HtmlCodedUI04

Sure, no assertions, but that’s not the aim:

HtmlCodedUI03

Snippet

 [TestMethod]
        public void htmlTest() {
 
            var browser = BrowserWindow.Launch(new Uri("http://localhost:52478/page01.html"));
 
            var wb = new HtmlEdit(browser);
            wb.SearchProperties.Add(HtmlEdit.PropertyNames.Name, "firstname");
            Mouse.Click(wb);
            wb.Text = "this is my aunt";
 
            HtmlComboBox wl = new HtmlComboBox(browser);
            wl.SearchProperties.Add(HtmlComboBox.PropertyNames.Name, "myManyAunts");
            wl.SelectedItem = "Priscilla";
 
            Playback.Wait(3000);
        }
Snippet
<!DOCTYPE html>
<html>
<body>
    <form>
        First name:<br>
        <input type="text" name="firstname">
        <br>
        Last name:<br>
        <input type="text" name="lastname">
 
        <select name="myManyAunts">
            <option value="Daphne">Daphne</option>
            <option value="Maud">Maud</option>
            <option value="Priscilla">Priscilla</option>
        </select>
    </form>
 
</body>
</html>
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s