如何验证我们是否可以在 Selenium 中静态下拉菜单中选择多个选项?
借助 isMultiple() 方法,我们可以验证是否可以在 Selenium 中静态下拉菜单中选择多个选项。它返回布尔值 true 或 false。
示例
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import java.util.List;
import org.openqa.selenium.support.ui.Select;
public class OptionsMultiple{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "https://tutorialspoint.com/tutor_connect/index.php";
Select s = new Select(driver.findElement(By.xpath("//select[@name=’selType’]")));
// isMultiple() returns a boolean value
boolean result = s.isMultiple();
System.out.println(result);
driver.close();
}
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP