Selenium JavaScript



This video will describe how to work with selenium by using Javascript Executor.




package myPackage;

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;

public class JavaScriptWorking {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();
driver.get("http://www.javascriptkit.com/javatutors/event2.shtml");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//driver.findElement(By.xpath("//*[@id='contentcolumn']/div[1]/table/tbody/tr/td[2]/form/input")).click();
//((JavascriptExecutor) driver).executeScript("inform()");
((JavascriptExecutor) driver).executeScript("document.getElementsByName('fd0')[0].click()");


}

}

1 comment:

  1. AD - 4 only For Appium


    Best place to learn Appium Android IOS Automation Testing Training in Chennai

    Go for Appium training in chennai for real time mobile automation testing training with real time project support.
    UI Automation Tools with real time scenarios You can contact 8122241286 for Best APPIUM and selenium Training in Chennai

    ReplyDelete