Last active
August 29, 2015 14:22
-
-
Save lotosotol/5f29ad4cfb76cf5bce36 to your computer and use it in GitHub Desktop.
Selenium.Lecture_68
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.openqa.selenium.firefox.FirefoxProfile; | |
import org.openqa.selenium.firefox.internal.ProfilesIni; | |
public class javaScriptExecutor { | |
public static void main(String[] args) throws InterruptedException { | |
//running Firefox browser under "selenium1" profile: | |
ProfilesIni listprofiles = new ProfilesIni(); | |
FirefoxProfile profile = listprofiles.getProfile("selenium1"); | |
WebDriver driver = new FirefoxDriver(profile); | |
driver.navigate().to("http://www.w3schools.com/js/tryit.asp?filename=tryjs_event_onclick3"); | |
driver.manage().window().maximize(); | |
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS); | |
Thread.sleep(2000L); | |
//switching to the IFrame to work with it's elements: | |
driver.switchTo().frame("iframeResult"); | |
//driver.findElement(By.xpath("//h1")).click(); //this works, disabled in order to test the method below | |
((JavascriptExecutor) driver).executeScript("changeText(this)"); | |
Thread.sleep(3000L); | |
driver.close(); | |
System.out.println("DONE!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment