Selenium
1.使用XPath进行元素定位
语法:以”/”开始,该路径表示一个元素的绝对路径,/AAA;/AAA/BBB
以“//”开始,表示选择文档所有满足双斜线之后的元素//BB;//DDD/BBB
星号“*”,选择所有由星号之前的路径所定位的元素
[i],i表示元素在选择集中的位置;/AAA[last()] 表示选择集中的最后一个元素
@,确定属性,//@d 选择所有的属性id;//BBB[@id]选择有id属性的BBB元素;//BBB[not(@*)]选择没有属性的BBB
//BBB[@id='b1'] 选择包含属性id且其值为‘b1’的BBB元素
|将多个路径合并在一起 //CCC|//BBB 选择所有的CCC和BBB元素
2.一个测试套件(test suite)由多个测试用例(test case)串连组成
3.Command
Action和ActionAndWait(waitForPageToLoad) 执行操作后会刷新页面则用后者
check(locator) 勾选复选框或单选框,不会触发单击动作,而onClick会触发
4.Opera测试:需要OperaDriver,至少需要安装Java Runtime Environment 1.5或更高版本
5.Iphone测试:运行在一个UIWebView上(webkit浏览器),
6.Andriod测试需安装Andriod SDK 方法1.使用远程WebDriver服务器 方法2.使用Andriod测试框架
7.对Selenium进行扩展:
1.Action
Selenium.prototype.doTypeReprated = function(location, text) {...}; 会自动注册d
oTypeRepratedAndWai操作
2.Accessors/Assertions
Selenium.prototype.assertValueRepeated = ..; 会自动注册verifyValueRepeated和WaitForValueRepeated操作
3.通过原型生成其他命令:
Selenium.prototype.getTextLength = ...; 会自动生成storeTextLength/assertTextLength/assertnotTextLength/verifyTextLength/verifynotTextLength/waitforTextLength/waitfornotTextLength
4.定位方式
Selenium1扩展:google Selenium RC user-extension
Selenium1扩展:使用JavaScriptExector(Java)