• [转贴]watin的一些例子


     Some WatiN Examples
    Below are some examples of WatiN codes for testing:
    // find div by id
    var div = browser.Div("divId");
     
    // find div by class
    var div = browser.Div(Find.ByClass("divClass"));
     
    // click a div
    browser.Div("divId").Click();
     
    // click a button
    browser.Button("buttonId").Click();
     
    // get <li></li> elements inside a div
    var lisCollection= browser.Div("divId").ElementsWithTag("li");
    // click the first <li></li>
    lisCollection.FirstOrDefault().Click();
    // click the one contains a particular inner text
    lisCollection.Where(li => li.Text.Contains("some text")).FirstOrDefault().Click();
     
    // get <a></a> elements inside a div
    var links = browser.Links.Filter(a => a.Parent.Parent.Parent.ClassName == "divClass");
    var links = browser.Links.Filter(a => a.Parent.Parent.Parent.Parent.Id == "divId");
     
    // select from a select dropdown
    browser.SelectList("selectId").Option("option text").Select();
     
    // assert a div exists
    Assert.IsTrue(browser.Div("divId").Exists);
     
    // assert header(s) with a particular text exists
    Assert.IsTrue(browser.ElementsWithTag("h1").Any(x => x.Text == "heading text"));
     
    // assert only one header with a particular text exists
    Assert.IsTrue(browser.ElementsWithTag("h3").Where(x => x.Text == "heading text").Count() == 1);
     
    // assert a particular text exists inside a table td
    Assert.IsTrue(browser.Table("tableId").TableCells.Any(x => x.Text == "text inside td"));

  • 相关阅读:
    webpack学习笔记--配置总结
    webpack学习笔记--多种配置类型
    webpack学习笔记--整体配置结构
    webpack学习笔记--其它配置项
    webpack学习笔记--配置devServer
    webpack学习笔记--配置plugins
    webpack学习笔记--配置resolve
    webpack学习笔记--配置module
    webpack学习笔记--配置output
    webpack学习笔记--配置entry
  • 原文地址:https://www.cnblogs.com/redmondfan/p/3711777.html
Copyright © 2020-2023  润新知