简体   繁体   中英

How to take runtime input in selenium while automation testing?

I'm trying to take data from user at run time while automating a Webapplication. I have searched a lot but I couldn't find anything. I have tried this method. (code mentioned below)

Scanner scanner_user = new Scanner(System.in);
    System.out.println("Enter your Email or Phone : ");
    String user = scanner_user.nextLine();
    System.out.println("our otp is " + user.toString());

but It doesn't work . it ask to enter data in console but it says read only view. please help me how can I take data at runtime.

You can use the below in this scenario user is passing the password manually through console.

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String password;   
                System.out.println("Please Enter the user password :: ");
                password= br.readLine();  
                driver.findElement(By.id("pwd")).sendKeys("password");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM