Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.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
Java 想要为selenium web驱动程序中的多个命令编写一个代码_Java_Selenium_Selenium Webdriver - Fatal编程技术网

Java 想要为selenium web驱动程序中的多个命令编写一个代码

Java 想要为selenium web驱动程序中的多个命令编写一个代码,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,driver.get返回void,不能将其分配给WebElement的前两行。driver.getURL以指定的URL打开网页,该URL为空。 不能将其分配给WebElement。 尝试将在浏览器中打开的页面中的任何元素分配给element1,并检查其是否为null。问题是什么?错误类型不匹配无法从void转换为webelement如何解决此原始代码也是不够的。请详细阐述您的问题,公开预期结果和您遇到的问题met@urban这是答案,不是问题:P@drets:真的很抱歉,一定太早了。。。移除 W

driver.get返回void,不能将其分配给WebElement的前两行。

driver.getURL以指定的URL打开网页,该URL为空。 不能将其分配给WebElement。
尝试将在浏览器中打开的页面中的任何元素分配给element1,并检查其是否为null。

问题是什么?错误类型不匹配无法从void转换为webelement如何解决此原始代码也是不够的。请详细阐述您的问题,公开预期结果和您遇到的问题met@urban这是答案,不是问题:P@drets:真的很抱歉,一定太早了。。。移除
WebElement element1 = driver.get("http://staging.zingoy.com/");
      WebElement element11 = driver.get("http://staging.zingoy.com/login");

    if (element1!= null && element11!= null ){
    driver.findElement(By.xpath("/html/body/div[1]/nav/div/div/div[4]/div/span[2]/a[1]")).click();
    System.out.println("LOGin Enter text");
    try{
          WebDriverWait wait = new WebDriverWait(driver, 10);
          WebElement element = (WebElement) wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[1]/div[1]/div/div/div[2]/div/div[3]/div/form/div[2]/input")));
          element.click();
          System.out.println("Clicked on the element successfully");
        }catch(Throwable e){
          System.err.println("Error came while waiting for the element and clicking on it. "+e.getMessage());
        }

    driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div/div[2]/div/div[3]/div/form/div[2]/input")).sendKeys("mdimertest@gmail.com");
    driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div/div[2]/div/div[3]/div/form/div[3]/input")).sendKeys("12345600");
    driver.findElement(By.id("login_submit")).click();