【发布时间】:2018-09-18 06:26:52
【问题描述】:
我正在自动化一些需要注销的网站。我在这段代码中遇到了困难:
WebDriverWait wait = new WebDriverWait(d, 10);
WebElement Category_Body = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("user logout")));
Category_Body.click();
d.findElement(By.id("logout_user")).click();
Thread.sleep(1000);
HTML:
<a class="user logout" title="Sign out" data-target="#confirm_popup" data-toggle="modal"></a>
错误:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"user logout"}
【问题讨论】:
-
在
iframe吗? -
我也尝试了不同的方法来解决这个错误。不工作,请分享您的观点。
-
@NarendraR 它不在 iframe 中
-
使用 By.class('user') 或 By.cssSelector('.user.logout')
-
@DakshinamurthyKarra 对不起,这也不起作用
标签: java selenium xpath css-selectors webdriverwait