Java 想要为selenium web驱动程序中的多个命令编写一个代码
driver.get返回void,不能将其分配给WebElement的前两行。driver.getURL以指定的URL打开网页,该URL为空。 不能将其分配给WebElement。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
尝试将在浏览器中打开的页面中的任何元素分配给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();