答案 0 :(得分:5)
您应该尝试使用WebDriverWait
等待elementToBeClickable
它对我有用,如下所示: -
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement accountSettings = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Account Settings")));
accountSettings.click() //this will click on setting link to open menu
WebElement logOut = wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Log Out")));
logOut.click() // this will click on logout link
希望它有帮助...:)
答案 1 :(得分:0)
我假设,在点击箭头按钮后,“注销”按钮会在您的代码中显示。因此,要单击该注销按钮,请使用以下部分作为cssSelector:
一个[数据-GT * = 'menu_logout']>跨度> span._54nh
driver.findElement(By.cssSelector("a[data-gt*='menu_logout']>span>span._54nh"));