Input text to text field:
1. sendkeys()
2. javascript
1. sendkeys()
2. javascript
package automation.selenium; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class test1 { public static void main(String[] args) { WebDriver drv=new FirefoxDriver(); drv.navigate().to("http://www.google.com/"); try{ // WITH SENDKEYS //drv.findElement(By.id("lst-ib")).sendKeys("big data"); // WITHOUT SENDKEYS JavascriptExecutor jse = (JavascriptExecutor)drv; //jse.executeScript("document.getElementById('lst-ib').value='big data';"); // OR jse.executeScript("document.getElementById('lst-ib').setAttribute('value', 'big data');"); drv.findElement(By.id("lst-ib")).submit(); } catch(Exception e){ e.printStackTrace(); } } }