Selenium第一篇

Selenium ide 实现简单的循环、条件语句

Selenium ide 本身是不支持if-else while-loop等功能的,通过添加goto_sel_ide.jsfirefox浏览器的插件selenium ideflow control

1.  下载地址:http://wiki.openqa.org/display/SIDE/Contributed+Extensions+and+Formats
           
http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html

2.  简单的应用 if-else function 我们一般会用到gotoIfgotolabellabel这三个command,在selenium ide里按照command | target | value的顺序举个简单的例子:

Open| /Selenium_test.html

Type| //html/body/form/input| 15

storeValue| //html/body/form/input| n

gotoIf| ${n}<=10| target1

gotolabel| target2

label| target1

type| //html/body/form/input[2]|  n is smaller than or equals 10

gotolabel| testend

label| target2

type| //html/body/form/input[2]|  n is bigger than 10

label| testend

测试页面代码:

<html>

<head>

     <meta http-equiv="Content-Type" content="text/html;charset=gbk">

     <title>Selenium_Test</title>

</head>

 

<body>

     <form name="test">     

         </br>

         测试条件:<input type="text" name="input">

         </br>

         </br>

         返回结果:<input type="text" name="output">

     </form>

</body>

</html>

3.  While的简单应用:

Open| /Selenium_test.html

Type| //html/body/form/input|1

storeValue| //html/body/form/input| num

while| ${num}<3

type| //html/body/form/input[2]| javascript{ storedVars['num']}

store| javascript{parseInt(storedVars['num'])+1}| num

endWhile

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值