Skip to main content

Posts

Showing posts with the label disable js

Test Enabling/Disabling JavaScript on a browser

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverBackedSelenium; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; import com.thoughtworks.selenium.Selenium; public class TestJS { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("javascript.enabled", false); WebDriver driver = new FirefoxDriver(profile); Selenium selenium = new WebDriverBackedSelenium(driver, "http://www.somedomain.com"); selenium.open("/dp/gotopage/"); driver.findElement(By.id("prodImage")).click(); boolean result = driver.findElement(By.className("imageWarningMessage")).isEnabled(); if (result) System.out.println("Result is: "+driver....