Selenium ide 实现简单的循环、条件语句
Selenium ide 本身是不支持if-else 和while-loop等功能的,通过添加goto_sel_ide.js和firefox浏览器的插件selenium ide:flow 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 我们一般会用到gotoIf,gotolabel和label这三个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