2024年4月19日发(作者:)

Selenium的常用api

1、文本框textbox

向文本框中填写信息

Java代码:

Type(r,)

("salutationText","abc");

2、取出某个文本框中已经填写的信息

getValue(locator)

2、判断文本框是否可编辑

BooleanisEditable(locator)

下拉框Dropdownlist

1)向下拉框中选值

Select

selectLocator,optionLocator

S.select(”typeSelect”,”label=Date”)

2)

取出某个下拉框中已经选择的值

getSelectedLabel(selectLocator)

ectedLabel("xpath=//SELECT@name='addSatution'")

3)取出某个下拉框中所有的选项

[]getSelectOptionsgetSelectOptionsgetSelectOptions

(selectLocatogetSelectOptionsr)

ectOptions("//div@id='mysearch_tips'/select")

按钮或链接

Button&Link

click(locator)

("link=Administration");

//("xpath=//input@checkfield='addIndicatorName'and@name='addBtn'")

;

单选框或多选框RadioBox&CheckBox

check(locator)

("otherPhoneFlag");

uncheck(locator)

k("otherPhoneFlag")

booleanisChecked(locator)

ked("otherPhoneFlag");

表格table

取出表中某个单元格的值,下标从0开始

getTable(tableCellAddress)

eg:le("//div@id='profiles-search'/div2/table.1.1");

其他others

取某个元素特定的属性值

getAttribute(attributeLocator)

ribute("xpath=//img@name='picName'@style")

取某元素的text的值

getText(locator)

t("link=Contacts")

取当前页面的title

getTitle()

le()