为什么会有WatiN?
给用户提供一个.Net平台下,将Web测试自动化的便捷途径。
如何通过WatiN来进行自动化测试的呢?
摆事实,讲道理,乃严谨的科学态度,到底WatiN下的自动化测试如何便捷呢?
[Test]
public void SearchForWatiNOnGoogle()
{
// 打开IE浏览器,并来到Google站点
using (var browser = new IE("http://www.google.com"))
{
// 定位到搜索框,并输入WatiN
browser.TextField(Find.ByName("q")).TypeText("WatiN");
// 点击“搜索”按钮
browser.Button(Find.ByName("btnG")).Click();
// 验证搜索结果中是否包含关键字“WatiN”
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}
public void SearchForWatiNOnGoogle()
{
// 打开IE浏览器,并来到Google站点
using (var browser = new IE("http://www.google.com"))
{
// 定位到搜索框,并输入WatiN
browser.TextField(Find.ByName("q")).TypeText("WatiN");
// 点击“搜索”按钮
browser.Button(Find.ByName("btnG")).Click();
// 验证搜索结果中是否包含关键字“WatiN”
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}