描述了用户所会作出的操作。
Action 有两种形式: action和actionAndWait, action会立即执行,而actionAndWait会假设需要较长时间才能得到该action的相响,而作出等待,open则是会自动处理等待时间。
click | aCheckbox | |
clickAndWait | submitButton | |
clickAndWait | anyLink | |
open | /mypage | |
open | http://localhost/![]() | |
type | nameField | |
typeAndWait | textBoxThatSubmitsOnChan | |
select | dropDown | Australian Dollars |
select | dropDown | index=0 |
selectAndWait | currencySelector | value=AUD |
selectAndWait | currencySelector | label=Auslian D*rs |
selectWindow | myPopupWindow | |
selectWindow | null | |
pause | 5000 | |
pause | 2000 | |
fireEvent | textField | focus |
fireEvent | dropDown | blur |
waitForCondition | var value=selenium.getText("foo"); value.match(/bar/); | 3000 |
waitForValue | finishIndication | isfinished |
| | |
store | Mr John Smith | fullname |
store | $.{title} $.{firstname} $.{suname} | fullname |
store | javascript.{Math.round(Math.PI*100)/100} | PI |
storeValue | inputLocator | variableName |
把指定的input中的值保存到变量中
storeValue | userName | userID |
type | userName | $.{userID} |
storeText | currentDate | expectedStartDate |
verifyValue | startDate | $.{expectedStartDate} |
storeAttribute(.{}elementLocator@attributeName,variableName.{})
把指定元素的属性的值赋予给变量
storeAttribute | input1@class | classOfInput1 |
verifyAttribute | input2@class | $.{classOfInput1} |
storeAttribute
String taskName = selenium.GetAttribute("minblogBody@defvalue");
Console.WriteLine(taskName);
将id为minblogBody的defvalue值存储到taskName中,并打印taskName
chooseCancelOnNextConfir | | |
- 如果已经运行过该命令,当下一次又有confirm对话框出现时,也会同样地再次选择Cancel
answerOnNextPrompt(answerString)
- 在下次JavaScript弹出prompt提示框时,赋予其anweerString的值,并选择确定
answerOnNextPrompt | Kangaroo | |
允许用户去检查当前状态。两种模式: Assert 和 Verify,当Assert失败,则退出测试;当Verify失败,测试会继续运行。
verifyLocation | /mypage | |
assertLocation | /mypage | |
verifyTitle | My Page | |
assertTitle | My Page | |
verifyValue | nameField | John Smith |
assertValue | document.forms[2].nameField | John Smith |
verifySelected | dropdown2 | John Smith |
verifySelected | dorpdown2 | value=js*123 |
assertSelected | document.forms[2].dropDown | label=J*Smith |
assertSelected | document.forms[2].dropDown | index=0 |
verifySelectOptions | dropdown2 | John Smith,Dave Bird |
assertSelectOptions | document.forms[2].dropdown | Smith,J,Bird,D |
verifyText | statusMessage | Successful |
assertText | //div[@id='foo']//h1 | Successful |
verifyTextPresent | You are now logged in | |
assertTextPresent | You are now logged in | |
selenium.IsTextPresent("beisen:分享测试01")
verifyAttribute | txt1@class | bigAndBlod |
assertAttribute | document.images[0]@alt | alt-text |
verifyAttribute | //img[@id='foo']/alt | alt-text |
verifyElementPresent | submitButton | | |
assertElementPresent | //img[@alt='foo'] | | assertElementNotPresent(elementLocator) |
verifyTable | myTable.1.6 | Submitted |
assertTable | results0.2 | 13 |
verfyVisible | postcode | |
assertVisible | postcode | |
verfyNotVisible | postcode | |
assertNotVisible | postcode | |
verifyEditable | shape | |
assertEditable | colour | |
answerOnNextPrompt | Joe | |
click | id=delegate | |
verifyPrompt | Delegate to who? | |
参数和变量的声明范围由简单的赋值到JavaScript表达式赋值。
Store,storeValue 和storeText 为下次访问保存值。
在Selenium内部是用一个叫storeVars的map来保存变量名。
联系客服