資源描述:
《Selenium常用API》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、Selenium-RC常用API?一.文本框Textbox? 1.向文本框中填寫信息?Java代碼??1.type(java.lang.String?locator,?java.lang.String?value) //eg.selenium.type("salutationText",?"abc");?? 2.取出某個(gè)文本框中已經(jīng)填寫的信息?Java代碼??1.java.lang.String??getValue(java.lang.String?locator) ??2.??3.??//eg
2、:selenium.getValue("xpath=//input@name='addProfileLastName'");?? 3.判斷某文本框是否可編輯?Java代碼??1.boolean?isEditable(java.lang.String?locator) //eg.selenium.isEditable("xpath=//input@name='addProfileLastName'");?? 二.下拉框Dropdownlist? 1.向下拉框中選值?Java代碼??1.selec
3、t(java.lang.String?selectLocator,?java.lang.String?optionLocator) //eg.selenium.select("typeSelect",?"label=Date");?? 2.取出某個(gè)下拉框中已經(jīng)選擇的值?Java代碼??1.java.lang.StringgetSelectedLabel(java.lang.String?selectLocator) //eg.?selenium.getSelectedLabel("xpath=/
4、/SELECT@name='addSatution'")?? 3.取出某個(gè)下拉框中所有的選項(xiàng)?Java代碼??1.java.lang.String[]??getSelectOptions?getSelectOptions?getSelectOptions(java.lang.String?selectLocato?getSelectOptionsr) //eg.?selenium.getSelectOptions("http://div@id='mysearch_tips'/select")?? 三.按鈕
5、或鏈接Button&Link? 單擊?Java代碼??1.click(java.lang.String?locator) //eg.?selenium.click("link=Administration"); //selenium.click("xpath=//input@checkfield='addIndicatorName'?and?@name='addBtn'");?? 四.單選框或多選框RadioBox&CheckBox? 1.選擇?Java代碼??1.check(java.la
6、ng.String?locator) //eg.?selenium.check("otherPhoneFlag");?? 1.不選?Java代碼??1.uncheck(java.lang.String?locator)??2.//eg.?selenium.uncheck("otherPhoneFlag");?? 2.判斷是否選擇?Java代碼??1.booleanisChecked(java.lang.String?locator) //eg.?selenium.isChecked("othe
7、rPhoneFlag");?? 五.表格Table? 1.取出表中某個(gè)單元格的值,下標(biāo)從0開(kāi)始? Java代碼??1.java.lang.String?getTable(java.lang.String?tableCellAddress) //eg.?selenium.getTable("http://div@id='profiles-search'/div2/table.1.1");?? 六.其他others? 1.取某個(gè)元素的特定屬性值?Java代碼??1.java.lang.String?get
8、Attribute(java.lang.String?attributeLocator) //eg.?selenium.getAttribute("xpath=//img@name='picName'@style")?? 2.取某元素的text值?Java代碼??1.java.lang.String?getText(java.lang.String?locator) //eg.?selenium.getText("link=Contacts")??