How to enter dynamic values in any field at run time

Currently in my project i am passing Email id and Password field from sendkeys option but I want to enter value at run time please suggest how can I enter value in any field at run time.

Default Asked on September 2, 2015 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)

    Either you can take input from user and store in string , pass or else you can read from external file having separate email , password.

    Train Answered on September 2, 2015.

    Can you please provide me example to take input from user and store in string..

    Thanks in advance

    on September 3, 2015.
    Add Comment

    You can use the swing API of java for passing the input on run time.

    import java.util.concurrent.TimeUnit;

    import javax.swing.JOptionPane;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class validation {
    static WebDriver driver=null;
    static String UsrInput;

    public static void main(String[] args) {
    driver=new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    UsrInput =JOptionPane.showInputDialog(“Enter Input”);

    Let, me know if it works for you .

    Default Answered on September 11, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.