不能在网页上 select 个元素
Cant select elements on Webpage
我在尝试 select 菜单时遇到主要问题 dropdown.I 上的两个元素已经尝试过 xpaths、link 文本和 css select或者但它不会 select 密码按钮或注销按钮。
用于密码按钮的 Xpaths:"//*[@id='app']/header/div[3]/nav/ul/li/a"
CSS 用于注销按钮:["data-logged-in-log-out-button"]
用于注销按钮的 XPath:"//*[@id='app']/header/div[3]/nav/ul/a"
我得到的 select 密码错误是:
org.openqa.selenium.WebDriverException: unknown error: Element ... is not clickable at point (989, 233).
Other element would receive the click: ...
你能试试吗-
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class A {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("url here");
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Log Out")));
driver.findElement(By.linkText("Log Out")).click();;
}
}
如果还是不行,请尝试-
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class A {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("url here");
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", driver.findElement(By.linkText("Log Out")));
}
}
请尝试使用以下 XPath 以及显式等待条件。
XPath:
//*[contains(text(),'Log out')]
我在尝试 select 菜单时遇到主要问题 dropdown.I 上的两个元素已经尝试过 xpaths、link 文本和 css select或者但它不会 select 密码按钮或注销按钮。
用于密码按钮的 Xpaths:"//*[@id='app']/header/div[3]/nav/ul/li/a"
CSS 用于注销按钮:["data-logged-in-log-out-button"]
用于注销按钮的 XPath:"//*[@id='app']/header/div[3]/nav/ul/a"
我得到的 select 密码错误是:
org.openqa.selenium.WebDriverException: unknown error: Element ... is not clickable at point (989, 233). Other element would receive the click: ...
你能试试吗-
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class A {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("url here");
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Log Out")));
driver.findElement(By.linkText("Log Out")).click();;
}
}
如果还是不行,请尝试-
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class A {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("url here");
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", driver.findElement(By.linkText("Log Out")));
}
}
请尝试使用以下 XPath 以及显式等待条件。
XPath:
//*[contains(text(),'Log out')]