zoukankan      html  css  js  c++  java
  • watiJuserGuide部分内容(转载)

     

    UserGuide中现有的内容

    创建一个IE浏览器实例

     IE ie = new IE();
     
    启动一个IE浏览器实例

     IE ie = new IE();
     ie.start();
     
    启动一个IE浏览器实例并访问Google

     IE ie = new IE();
     ie.start("http://www.google.com");

    使用当前已经打开的IE浏览器

     根据URL指定
     
     IE ie = new  IE();
     ie.attach(url,"http://www.google.com")
     
     根据标题指定
     
     IE ie = new IE();
     ie.attach(title,"Google");
     
    IE导航
     ie.goTo("http://www.mysite.com");用IE浏览器访问www.mysite.com
     
     ie.navigate("http://www.mysite.com");功能同上
     
     ie.forward(); 相当于浏览器中的“前进”
     
     ie.back(); 相当与浏览器中的“后退”


    窗口焦点、位置、大小以及模式的设置

     ie.bringToFront(); //将窗口置于其他浏览器窗口之前
     ie.focus(); //设定焦点为指定的ie窗口
     
     ie.maximize(); //将窗口最大化,知道占满整个屏幕
      ie.minimize(); //将窗口最小化
     ie.restore(); //将窗口的大小设为上一次的大小。
     
      ie.fullScreen(true); //打开窗口的全屏幕模式
      ie.fullScreen(false); //禁止窗口的全屏幕模式
     
      ie.theatreMode(true); //打开窗口的剧院(Theatre)模式
      ie.theatreMode(false); //禁止窗口的剧院模式
     
      ie.visible(false); //将窗口从桌面上隐藏起来
      ie.visible(true); //恢复窗口可见
     
      ie.left(100); /将窗口到屏幕的左边距设为100
      ie.top(200); //将窗口到屏幕的上边距设为200

    得到页面中name="button1"的按钮

      ie.button(name,”button1”);
     
    得到页面中name="deleteButton"的所有按钮集合
      ie.buttons(name,”deleteButton”);

    得到上面这个集合中的第二个元素,即页面中第二个name="deleteButton"的按钮
     ie.buttons(name,”deleteButton”).get(1); 
    // OR
      ie.buttons(name,”deleteButton”).button(1);
     
    得到页面中name="deleteButton",value="delete"的所有按钮集合中的第三个按钮
      Button button = ie.buttons(name,”deleteButton”).buttons(value,”Delete”).button(2);
     
    得到页面中<MYTAG>的HTML元素
     例如<MYTAG>My Text1</MYTAG>
     ie.htmlElement(tag,”MYTAG”);
     
    假如有
     <MYTAG myattr1=”attribute1”>My Text1</MYTAG>
      <MYTAG myattr2=”attribute2”>My Text2</MYTAG>
    则可以通过如下方式得到第一个元素
      ie.htmlElement(attribute(“myattr1”,"attribute1"));
      其中htmlElement()中的参数还可以换成以下方式
      tag(String tagName)
      attribute(String name, String value)
      index(int index)
     text(String text)
     name(String value)
     value(String value)
     caption(String value)
     id(String value)
     title(String value)
     alt(String value)
     src(String value)
     action(String value)
     method(String value)
     url(String value)
     href(String value)
     xpath(String expression)
     
    超链接
     假如页面中有如下链接
     <a href="googlehttp://google.com">Google</a>
     则可以通过text,url和xpath三种方式得到该链接,并可以使用正则表达式作为参数,click()表示模拟点击该链接
     ie.link(text,"Google").click();
     
     ie.link(text,"/oogl/").click();
     
     ie.link(url,"http://google.com").click();
     
     ie.link(url,"/google.com/").click();
     
     ie.link(xpath, "//A[@url='http://google.com']").click();
     
    多选框
     假如页面中有如下多选框
     Check Me: <input name="checkme" value="1" type="checkbox">
     则可以通过如下方式来实现勾选该多选框
     ie.checkbox(name,"checkme").set();
     
     ie.checkbox(value,"1").set();
     
     ie.checkbox(xpath, "//INPUT[@name='checkme' and @value='1']").set();
     还可以调用clear()来取消多选框的选中状态
     
    单选框
     假如页面中有如下单选框
     Click Me: <input name="clickme" id="1" type="radio">
     则可以通过如下方式来实现勾选该多选框
     ie.radio(name,"clickme").set();
     
     ie.radio(id,"1").set();
     
     ie.radio(xpath, "//INPUT[@name='clickme' and @id='1']").set();
     还可以调用clear()来取消单选框的选中状态
     
    按钮
     假如页面中有如下按钮
     <input type = "submit" value = "ClickTheButton" name="b1"></input>
     可以通过如下方式得到该按钮
     ie.button(name, "b1").click();
     
     ie.button(value,"ClickTheButton").click();
     默认会根据按钮的value值来寻找该按钮,如
     ie.button("ClickTheButton").click();
     
    下拉列表
     假如页面中有如下下拉列表
     <select name = "selectme" > <option name="1">O1<option name="2">O2</select>
     可以通过如下方式选中该下拉列表中的选项
     //(finds the option in the select list with name 1)
     ie.selectList(name, "selectme").option(name,"1").select();
     
     //(finds the second option in the list)
     ie.selectList(name, "selectme").option(index,1).select();
     
     //(返回当前下拉列表是否可用,即disable的状态)
     ie.selectList(name, "selectme").disabled();
     
     可以使用clearSelection()方法清除下拉列表的选中状态。
     
    图片
     假如页面中有如下图片元素
     <img src = images/square.jpg id=square title="square_image">
     可以通过如下方式实现点击该图片
     ie.image(src, "/square/").click();
     
     ie.image(title, "square_image").hasLoaded();
     
     ie.image(id,"square").width();
     
     ie.image(xpath, "//IMAGE[@id='square']").click();
     
    文本框和多行文本区域
     假如页面中有如下文本框
     <input name="username" type="text">
     可以通过如下方式得到文本框的值,或设置其值
     ie.textField(name, "username").set("myusername");
     
     ie.textField(name, "username").value();

    得到子浏览器
     当当前浏览器打开一个新的浏览器窗口时,可以使用如下方法得到新的窗口
     IE ie = new IE().start("www.mysite.com");
     //lets click a link that causes a new window to popup
     ie.link(name, "mylink").click();
     //now lets get a handle on the child browser;
     IE new_ie = ie.childBrowser();

     

  • 相关阅读:
    从零到一,使用实时音视频 SDK 一起开发一款 Zoom 吧
    七牛云助你度寒冬 | 每天 10:24, 新用户抢全额免单
    (下)挖掘传统行业日志大数据的无限价值
    (上)挖掘传统行业日志大数据的无限价值
    8.27 直播| 挖掘传统行业日志大数据的无限价值
    千亿级数量下日志分析系统的技术架构选型
    七牛云工程效率部测试服务如何为 70 万+ 客户保驾护航?
    云计算的新墨菲定律
    如何建设高吞吐量的日志平台
    新一代智能视频云发展现状分析:五大要素成关键
  • 原文地址:https://www.cnblogs.com/keeping/p/1833326.html
Copyright © 2011-2022 走看看