【发布时间】:2020-04-26 09:57:21
【问题描述】:
我正在尝试登录网站并尝试单击登录按钮。该按钮的 HTML 节点是
<button data-purpose="header-login" type="button" class="btn btn-quaternary">Log In</button>
我的代码是
WebDriver driver = new FirefoxDriver();
driver.get("https://www.udemy.com");
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[type='button']"))).click();
O/P- `Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.cssSelector: button[type='button'] (tried for 30 second(s) with 500 milliseconds interval)
但是,当我在代码中将 cssSelector("button[type='button']") 替换为 cssSelector("button[class='btn btn-quaternary']") 时,它完全可以正常工作。
类型是错误的属性选择吗?
【问题讨论】: