2、常用Actions
1)open(url)
接收一個(gè)參數(shù)url,即command=open, target=url
2)type(locator,value)
給locator指定的元素或?qū)傩再x值以value
3)click(locator)
單擊一個(gè)鏈接、按鈕、checkbox或radio等等,locator即元素定位
4)clickAndWait(locator)
單擊一個(gè)鏈接、按鈕等等元素,單擊后等待新的頁面加載
我們的表單提交,可以用這個(gè)方法來單擊submit按鈕。
類似的方法還有selectAndWait、typeAndWait、focusAndWait……
5)verifyLocation(pattern)
校驗(yàn)當(dāng)前頁面的路徑(url)是否與pattern匹配,關(guān)于pattern的解釋,我們?cè)谙旅婢唧w說明。
6)verifyValue(locator, pattern)
校驗(yàn)指定元素的值是否與指定pattern匹配
7)verifyVisible(locator)
校驗(yàn)指定元素是否可見,如果當(dāng)前元素的style="display:none",即不可見。
8)verifyTextPresent(pattern)
校驗(yàn)當(dāng)前頁面是否出現(xiàn)該文字
9)verifyChecked(locator)
用于校驗(yàn)checkbox是否被選中
10)verifyAttribute(locator, pattern)
校驗(yàn)指定的元素屬性值,是否匹配pattern
例如:verifyAttribute(link=All Search Results for "bike"@href, 'glob:*/search/bike?c=0*')
即校驗(yàn)指定的link的href屬性是否匹配"glob:*/search/bike?c=0*"
11)fireEvent(locator,eventName)
用于調(diào)用locator指定的元素的指定eventName的事件,例如:
fireEvent(userLoginName,blur),即調(diào)用文本框userLoginName的失去焦點(diǎn)事件
以上是較為常用的幾個(gè)方法,還有許多方法的詳細(xì)介紹可以參見:http://seleniumhq.org/projects/core/reference.html