标签:
Commands (命令)
1. Element Locators (元素定位器)
2. String Matching Patterns (字符串匹配模式)
3. Select Option Specifiers (Select选项指定器)
描述了用户所会作出的操作。
Action 有两种形式: action和actionAndWait, action会立即执行,而actionAndWait会假设需要较长时间才能得到该action的相响,而作出等待,open则是会自动处理等待时间。
| click | aCheckbox |
|
| clickAndWait | submitButton |
|
| clickAndWait |
anyLink
|
|
selenium.Click("id=login");
| open | /mypage |
|
| open | http://localhost/ |
|
selenium.Open("/");
| type | nameField | John Smith |
| typeAndWait | textBoxThatSubmitsOnChange | newValue |
selenium.Type("id=UserName", userName);
| select | dropDown | Australian Dollars |
| select | dropDown | index=0 |
| selectAndWait | currencySelector | value=AUD |
| selectAndWait | currencySelector | label=Auslian D*rs |
selenium.GoBack();
selenium.Close();
| 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 target: aa@bb存储元素 value: 变量 存储aa的bb值到变量中
String taskName = selenium.GetAttribute("minblogBody@defvalue");
Console.WriteLine(taskName);
将id为minblogBody的defvalue值存储到taskName中,并打印taskName
storteText
target://*[@id=‘ul_80185794-3209-4e6b-8cea-af39348c5cdd‘]/li[1]/span[6]/a[1]
value:bind
echo
${bind}
将路径为target里的值保存在bind变量中,并输出bind的值。
| chooseCancelOnNextConfirmation |
|
|
- 如果已经运行过该命令,当下一次又有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来保存变量名。
| store | Mr | title |
| storeValue | nameField | surname |
| store | $.{title} $.{suname} | fullname |
| type | textElement | Full name is: $.{fullname} |
| store | javascript.{‘merchant‘+(new Date()).getTime()} | merchantId |
| type | textElement | javascript.{storedVars[‘merchantId‘].toUpperCase()} |
标签:
原文地址:http://www.cnblogs.com/test-pofour/p/5765397.html