package javasrc.playground;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import junit.framework.TestCase;
// Good doc: http://code.google.com/p/selenium/wiki/GettingStarted
public class WebDriverJavaScriptTest extends TestCase {
public void testJsExecutor() {
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://www.javascriptkit.com/javatutors/alert2.shtml");
WebElement elem = driver.findElement(By.name("B3"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.confirm = function(msg){return true;};");
elem.click();
}
}
