美文网首页
selenium 下拉框元素操作

selenium 下拉框元素操作

作者: TungChiu | 来源:发表于2018-06-25 17:15 被阅读0次

1、new一个select对象

Select select = driver.findElement(By.id("id"));

2、通过select去选择下拉选择,有3个方法

(1)通过下标index,从0开始

select.selectByIndex(0);

(2)通过value属性值

select.selectByValue("test");

(3)通过文本值

select.selectByVisibleText("选项一");

注意:如果是input标签,就只能点击去操作了

相关文章

网友评论

      本文标题:selenium 下拉框元素操作

      本文链接:https://www.haomeiwen.com/subject/olgyyftx.html