赋值的左侧必须是变量 Selenium webdriver XPATH
The left-hand side of an assignment must be a variable Selenium webdriver XPATH
我正在使用 Selenium webdriver 自动化网站,下面是代码,代码失败并显示错误消息
The left-hand side of an assignment must be a variable for identifying
the login field using the XPATH, I am using XPATH since the ID and
name are already failed and when I use the XPATH the below error
message is populated, please help to correct the code
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 FirstClass {
private static final String SeleniumWait = null;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"C:\Users\Documents\Selenium\chromedriver_win32\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.amazon.com/");
driver.findElement(By.id("nav-link-accountList")).click();
driver.findElement(By.id("signin")).click();
WebDriverWait wait = new WebDriverWait(driver, 60);// 1 minute
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("//*
[@id="ap_email"]")));
//chrome.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("//*
[@id="ap_email"]")).sendKeys("testtest@gmail.com");
/*driver.findElement(By.id("ap_assword")).sendKeys("Teachme100$");
driver.findElement(By.id("signInSubmit")).click();
//driver.close();*/
/*WebElement ap_email = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id("ap_email")));*/
}
public static String getSeleniumwait() {
return SeleniumWait;
}
}
好像打错了。你能把双引号 (") 改成单引号 (') 吗?
driver.findElement(By.id("//*[@id='ap_email']")).sendKeys("testtest@gmail.com");
我正在使用 Selenium webdriver 自动化网站,下面是代码,代码失败并显示错误消息
The left-hand side of an assignment must be a variable for identifying the login field using the XPATH, I am using XPATH since the ID and name are already failed and when I use the XPATH the below error message is populated, please help to correct the code
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 FirstClass {
private static final String SeleniumWait = null;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"C:\Users\Documents\Selenium\chromedriver_win32\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.amazon.com/");
driver.findElement(By.id("nav-link-accountList")).click();
driver.findElement(By.id("signin")).click();
WebDriverWait wait = new WebDriverWait(driver, 60);// 1 minute
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("//*
[@id="ap_email"]")));
//chrome.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("//*
[@id="ap_email"]")).sendKeys("testtest@gmail.com");
/*driver.findElement(By.id("ap_assword")).sendKeys("Teachme100$");
driver.findElement(By.id("signInSubmit")).click();
//driver.close();*/
/*WebElement ap_email = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id("ap_email")));*/
}
public static String getSeleniumwait() {
return SeleniumWait;
}
}
好像打错了。你能把双引号 (") 改成单引号 (') 吗?
driver.findElement(By.id("//*[@id='ap_email']")).sendKeys("testtest@gmail.com");