执行以下代码时,我收到“找不到行”的错误消息。请告诉我哪里出错了。在这里,我试图获取登录失败超过 5 次的用户的姓名。
int count = 0;
if(driver.findElements(By.xpath("/html/body/div/form/div/div/span")).size()==1) {
count++;
if(count>=5)
System.out.println(user);
Scanner scanner_user1, scanner_pass1;
ChromeOptions options1 = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
WebDriver driver1 = new ChromeDriver(options1);
driver1.get("https://jamesweb.colanonline.net/");
driver1.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
scanner_user1 = new Scanner(System.in);
System.out.println("Enter your Email or Phone2 : ");
String user1 = scanner_user1.nextLine();
driver1.findElement(By.xpath("//*[@id=\"EmailId\"]")).sendKeys(user1);
Thread.sleep(2000);
scanner_pass1 = new Scanner(System.in);
System.out.println("Enter your Password2 : ");
String pass1 = scanner_pass1.nextLine();
System.out.println("after input : ");
driver1.findElement(By.xpath("//*[@id=\"Password\"]")).sendKeys(pass1);
scanner_user1.close();
scanner_pass1.close();
driver1.findElement(By.xpath("//*[@id=\"btnLogin\"]")).click();
}
else {
System.out.println("Login Passed");
}
}
执行代码时出现以下错误
Enter your Email or Phone2 :
FAILED: Login
java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
相关分类