Selenium WebDriver从Facebook注销 [英] Selenium WebDriver Log Out from Facebook
本文介绍了Selenium WebDriver从Facebook注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何单击注销按钮吗?我尝试使用driver.findElement(By.linkText("Log out"));
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?
推荐答案
您应该尝试使用WebDriverWait
等到elementToBeClickable
对我有用,如下所示:-
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
希望有帮助...:)
这篇关于Selenium WebDriver从Facebook注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文