Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium WebDriver从Facebook注销_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium WebDriver从Facebook注销

Selenium WebDriver从Facebook注销,selenium,selenium-webdriver,Selenium,Selenium Webdriver,有人知道如何单击“注销”按钮吗?我尝试使用driver.findElement(By.linkText(“注销”) 但它返回一个错误,表示找不到元素。是因为列表是动态生成的吗 我假设,点击箭头按钮后,您的代码中会出现注销按钮。因此,要单击该注销按钮,请使用以下部分作为CSS选择器: [data gt*='menu\u logout']>span>span.\u 54nh driver.findElement(By.cssSelector("a[data-gt*='menu_logout']>

有人知道如何单击“注销”按钮吗?我尝试使用
driver.findElement(By.linkText(“注销”)

但它返回一个错误,表示找不到元素。是因为列表是动态生成的吗


我假设,点击箭头按钮后,您的代码中会出现注销按钮。因此,要单击该注销按钮,请使用以下部分作为CSS选择器:

[data gt*='menu\u logout']>span>span.\u 54nh

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

我假设,在点击箭头按钮后,您的代码中会出现注销按钮。因此,要单击该注销按钮,请使用以下部分作为CSS选择器:

[data gt*='menu\u logout']>span>span.\u 54nh

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

您应该尝试使用
WebDriverWait
等待
elementtobelickable
它对我有效,如下所示:-

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

希望它能帮助……:)

您应该尝试使用
WebDriverWait
等待
element可选择
它对我有效,如下所示:-

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
希望能有帮助……:)