gpt4 book ai didi

java - Selenium 中的下拉 CSS 选择器

转载 作者:行者123 更新时间:2023-12-02 11:38:50 24 4
gpt4 key购买 nike

我有以下页面: http://live.guru99.com/index.php/mobile.html 。我需要单击 Selenium 下拉列表中的“按名称排序”,尝试使用以下代码执行此操作:

public void f() {

verifyTitle(baseUrl, "Home page");
driver.findElement(By.cssSelector(".level0 ")).click();
verifyTitle(driver.getCurrentUrl(), "Mobile");

Select dd = new Select(driver.findElement(By.cssSelector("select[title=Sort By][css=1]")));
dd.selectByVisibleText("Name");

}

这段代码有什么问题?引号位置正确吗?

最佳答案

尝试使用以下代码:

Select dd = new Select(driver.findElement(By.cssSelector("select[title='Sort By']")));
dd.selectByVisibleText("Name");

希望对你有帮助!

关于java - Selenium 中的下拉 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48725191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com