我的java代码没有错误,但在nextInt停止
我正在编写一个Java代码,它将在Chrome或Firefox中运行一个简单的自动化场景,具体取决于用户的输入。没有带下划线的错误,但程序卡在nextInt行(在调试器中看到了它),并且没有输出。有人能帮忙吗? 谢谢我的java代码没有错误,但在nextInt停止,java,selenium,automation,Java,Selenium,Automation,我正在编写一个Java代码,它将在Chrome或Firefox中运行一个简单的自动化场景,具体取决于用户的输入。没有带下划线的错误,但程序卡在nextInt行(在调试器中看到了它),并且没有输出。有人能帮忙吗? 谢谢 将您的系统.out放在扫描仪.nextInt()前面 然后,当键盘要求您输入数字时,在键盘上键入1或2。将您的系统.out放在扫描仪.nextInt()前面。 然后在键盘上输入1或2,当它要求你输入一个数字时。你有没有尝试过通过输入来取消勾选?你有没有输入什么?你有没有尝试过通过输
将您的
系统.out
放在扫描仪.nextInt()前面
然后,当键盘要求您输入数字时,在键盘上键入1或2。将您的
系统.out
放在扫描仪.nextInt()前面。
然后在键盘上输入1或2,当它要求你输入一个数字时。你有没有尝试过通过输入来取消勾选?你有没有输入什么?你有没有尝试过通过输入来取消勾选?你有没有输入什么?
package com.selenium;
import java.util.Scanner;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Main {
public static void main(String[] args) throws InterruptedException {
// environment variable
System.setProperty("webdriver.chrome.driver", "C:\\Automation\\libs\\Drivers\\chromedriver.exe");
//WebDriver chromeDriver = new ChromeDriver();
System.setProperty("webdriver.gecko.driver", "C:\\Automation\\libs\\Drivers\\geckodriver.exe");
WebDriver driver = null;
Scanner scanner = new Scanner(System.in);
int option = scanner.nextInt();
System.out.println("Please enter 1 for Chrome or 2 for Firefox " + option);
if (option == 1)
{
WebDriver driver1= new FirefoxDriver();
}
else if
(option == 2)
{
WebDriver driver2 = new ChromeDriver();
}
else
System.out.println("Please enter a correct number " + option);
String baseURL = "https://login.salesforce.com/?locale=eu";
driver.get(baseURL);
WebElement userName = driver.findElement(By.id("username"));
userName.sendKeys("Yan");
WebElement password = driver.findElement(By.id("password"));
password.sendKeys("123456");
WebElement rememberCheckbox = driver.findElement(By.id("rememberUn"));
rememberCheckbox.click();
WebElement bLogin = driver.findElement(By.id("Login"));
bLogin.click();
}
}
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter 1 for Chrome or 2 for Firefox " + option);
int option = scanner.nextInt();