RE: 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.

VerveQA Default Asked on September 2, 2015 in Selenium WebDriver.
Add Comment
3 Answers

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);
driver.get(“http://www.google.com”);
UsrInput =JOptionPane.showInputDialog(“Enter Input”);
driver.switchTo().defaultContent();
driver.findElement(By.id(“lst-ib”)).sendKeys(UsrInput);
}
}

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.