public boolean isJavascriptEnabled() { if (driver instanceof JavascriptExecutor) { return ((JavascriptExecutor) driver).isJavascriptEnabled(); } throw new UnsupportedOperationException("Underlying driver instance does not support executing javascript"); }
public boolean isJavascriptEnabled() { if (driver instanceof JavascriptExecutor) { return ((JavascriptExecutor) driver).isJavascriptEnabled(); } throw new UnsupportedOperationException("Underlying driver instance does not support executing javascript"); }
public WebElement find(WebDriver driver, String use) { if (!(driver instanceof JavascriptExecutor)) { throw new UnsupportedOperationException( "DOM lookups only work when the driver supports Javascript"); } JavascriptExecutor executor = (JavascriptExecutor) driver; if (!executor.isJavascriptEnabled()) { throw new UnsupportedOperationException( "DOM lookup failed: driver does not have JS enabled"); } return (WebElement) executor.executeScript(String.format("return %s", use)); } }
/** * Sets the value of an input field, as though you typed it in. * <p/> * <p>Can also be used to set the value of combo boxes, check boxes, etc. In these cases, * value should be the value of the option selected, not the visible text.</p> * * @param locator an <a href="#locators">element locator</a> * @param value the value to type */ public void type(String locator, String value) { if (controlKeyDown || altKeyDown || metaKeyDown) throw new SeleniumException("type not supported immediately after call to controlKeyDown() or altKeyDown() or metaKeyDown()"); if (shiftKeyDown) value = value.toUpperCase(); WebElement element = findElement(locator); if(driver instanceof JavascriptExecutor && ((JavascriptExecutor) driver).isJavascriptEnabled()) { callEmbeddedSelenium("replaceText", element, value); } else { element.sendKeys(value); } }