Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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 XPATH_Selenium_Variables_Xpath_Webdriver_Variable Assignment - Fatal编程技术网

赋值的左侧必须是变量Selenium webdriver XPATH

赋值的左侧必须是变量Selenium webdriver XPATH,selenium,variables,xpath,webdriver,variable-assignment,Selenium,Variables,Xpath,Webdriver,Variable Assignment,我正在使用SeleniumWebDriver自动化网站,下面是代码,代码失败并显示错误消息 赋值的左侧必须是用于标识的变量 登录字段使用XPATH,我使用XPATH,因为ID和 名称已失败,使用XPATH时出现以下错误 消息已填充,请帮助更正代码 这似乎是个打字错误。你能把双引号(“)改为单引号(”)吗 Eclipse中出现错误的代码是driver.findElement(By.id(“/*[@id=“ap\u email”]”)testtest@gmail.com“”;XPATH=“//*[@

我正在使用SeleniumWebDriver自动化网站,下面是代码,代码失败并显示错误消息

赋值的左侧必须是用于标识的变量 登录字段使用XPATH,我使用XPATH,因为ID和 名称已失败,使用XPATH时出现以下错误 消息已填充,请帮助更正代码


这似乎是个打字错误。你能把双引号(“)改为单引号(”)吗


Eclipse中出现错误的代码是driver.findElement(By.id(“/*[@id=“ap\u email”]”)testtest@gmail.com“”;XPATH=“//*[@id=“ap\u电子邮件”您好,Buaban-感谢您的更新,是的,是xpath的双引号,我已改为单引号和By.xpath,而不是By.id,效果很好。非常感谢。@Rajkumar,欢迎您。您可以单击“接受我的答案”以结束此问题吗?
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");