• watir学习系列--Watir API介绍


    文本框:
             <INPUT id="email" name="_fmu.u._0.e" value="" />
         方法1: ie.text_field(:id,'email').set("文本内容")
         方法2: ie.text_field(:name, 'email').set("文本内容")
         方法3: ie.text_field(:name,"email").clear

    下拉框:
             <SELECT name="cert_no">
               <OPTION value="身份证">身份证</OPTION>
             </SELECT>
        方法1: ie.select_list(:name,"cert_no").select("身份证")
        方法2: ie.select_list(:name,"cert_no").clearSelection

    超链接:
               <a href = "http://www.google.cn/">google</a> 
        方法1:ie.link(:text,"google").click
        方法2:ie.link(:url,"http://www.google.cn/").click

    复选框:
              <input type = "checkbox" name = "checkme" value = "1"> 
        方法1: ie.checkbox(:name,"checkme").set
        方法2: ie.checkbox(:name,"checkme").clear
        方法3: values = ie.checkbox(:name,"checkme").value
                          <input type = "checkbox" name = "checkme" value = "2"> 
         #多个同名的复选框处理
        方法1: ie.checkbox(:name,"checkme","2").set
        方法2: ie.checkbox(:name,"checkme","2").clear

    单选框:
              <input type = "radio" name = "clickme" id = "1"> 
         方法1: ie.radio(:name, "clickme").set
         方法2: ie.radio(:name, "clickme").clear

    一般按钮:
              <input type = "button" name = "clickme" value = "Click Me"> 
         方法1: ie.button(:value, "Click Me").click
         方法2: ie.button(:name,"clickme").click

    submit按钮:
              <form action = "submit" name = "submitform" method = "post">
                 <input type = "submit" value = "Submit"></input>
              </form> 
        方法: ie.button(:value."Submit").click

    图片按钮:
              <form action ="submit" name = "doitform" method = "post">
                 <input type = "image" src = "images/doit.gif" name = "doit">
              </form> 
        方法:ie.button(:name, "doit").click

    Form中无按钮:
              <form action = "login" name = "loginform" method = "get">
                  <input name = "username" type = "text"></input>
              </form> 
        方法1:ie.form(:name,"loginform").submit
        方法2:ie.form(:action,"login").submit

    获取隐含对象值:                                                                                
              <INPUT type=hidden value="您的Email" name="field1">                  
         方法:values = ie.hidden(:name,'field1').value                                             
                                                                                                   
    获取窗口对象:                                                                                  
        方法1: ie2 = Watir::IE.attach(:url,'http://www.google.cn/')   #根据URL获取            
        方法2: ie3 = Watir::IE.attach(:title,'Google')                #根据窗口标题获取
        方法3: ie4 = Watir::IE.attach(:title, /google.cn/)              #正则表达式匹配获取  
                                                                                                   
    URL编码:                                                                                       
           require 'cgi'                                                                          
           string =  "URL编码"                                                                     
           string = CGI::escape(string)                                                            
           puts string                 # 转换结果: URL%B1%E0%C2%EB                                 
                                                                                                   
    URL解码:                                                                                       
          require 'cgi'                                                                            
           string =  "URL%BD%E2%C2%EB"                                                             
           string = CGI::unescape(string)                                                          
           puts string                  # 转换结果:URL解码                                        

  • 相关阅读:
    Echarts饼图页面加载后默认凸出某块
    垂直居中及水平垂直居中方案(共15种)
    CSS Flex布局
    iview04
    重写react-navigation的stackNaviagtor产生的默认导航栏header样式
    RN 去掉Text组件文本的内边距
    RN项目导入到 最新的Android studio
    React Native 设置APP名称、logo图标、启动页
    react native 规避8081端口被占用,同时运行多个RN项目
    Android studio 的SDK默认安装路径找不到AppData文件
  • 原文地址:https://www.cnblogs.com/vickyyu/p/3210731.html
Copyright © 2020-2023  润新知