1

Does anyone know how to click log out button? I tried using driver.findElement(By.linkText("Log out"));

But it returned an error saying element is not found. Is it because the list is dynamically generated?

2 Answers 2

5

You should try using WebDriverWait to wait until elementToBeClickable it works for me as below :-

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

Hope it helps...:)

0

I assume, after click on arrow button, Log Out button appers in ur code. So to click on that log Out button, use the below portion as cssSelector:

a[data-gt*='menu_logout']>span>span._54nh

driver.findElement(By.cssSelector("a[data-gt*='menu_logout']>span>span._54nh"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.