package wdscripts;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Javascript {
//create a variable for WebDriver class
public WebDriver driver;
@Test
public void testJavascript_Type() throws Exception {
//open URL
driver.get("http://www.bing.com/");
((JavascriptExecutor)driver).executeScript("arguments[0].value=\'Nagaraju\'", driver.findElement(By.id("sb_form_q")));
Thread.sleep(5000);
}
@BeforeClass
public void beforeClass() {
//instantiate FF browser
driver = new FirefoxDriver();
//maximize window
driver.manage().window().maximize();
//implicit wait
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
//close the browser
driver.quit();
}
}