说明:本文章主要是对select元素操作的讲解,非select元素的下拉框需要另外分析

1、select元素示例

[selenium]选取下拉框内容的方法

2、select下拉框选取的3种方法

WebElement selector = driver.findElement(By.id("Selector"));    
Select select = new Select(selector);
 选择select的option有以下三种方法
  • selectByIndex(int index) 通过index----index就是类似下表索引之类的,从0开始
  • selectByVisibleText(String text) 通过匹配到的可见字符------就是下拉框中我们肉眼直接看到的文字,如 <option value="1">orange</option>
  • selectByValue(String value) 通过匹配到标签里的value------通过元素获取才能看到,如option>

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-09-22
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-07-12
  • 2022-03-01
  • 2022-12-23
相关资源
相似解决方案