Package org.openqa.selenium

Examples of org.openqa.selenium.JavascriptExecutor


    // Method scroll in TalbeElement class has a bug
    //
    private void scrollTable(TableElement tbl, int value) {
        WebElement actualElement = tbl.findElement(By
                .className("v-table-body-wrapper"));
        JavascriptExecutor js = tbl.getCommandExecutor();
        js.executeScript("arguments[0].scrollTop = " + value, actualElement);
    }
View Full Code Here


    }

    private void scrollUp() {
        WebElement actualElement = getDriver().findElement(
                By.className("v-table-body-wrapper"));
        JavascriptExecutor js = new TestBenchCommandExecutor(getDriver(),
                new ImageComparison(), new ReferenceNameGenerator());
        js.executeScript("arguments[0].scrollTop = " + 30, actualElement);
    }
View Full Code Here

        Assert.assertEquals("Measured sizes cleaned on toggle", 204,
                getMeasuredSizesMapSize());
    }

    private int getMeasuredSizesMapSize() {
        JavascriptExecutor jsExec = (JavascriptExecutor) getDriver();
        Number result = (Number) jsExec
                .executeScript("return window.vaadin.getMeasuredSizesCount();");
        return result.intValue();
    }
View Full Code Here

            waitForLoad(driver);
        }

        private void waitForLoad(WebDriver driver) {
            if(JavascriptExecutor.class.isInstance(driver)) {
                JavascriptExecutor executor = (JavascriptExecutor)driver;
                executor.executeAsyncScript(
                    "var callback = arguments[arguments.length - 1];" +
                    "var el = document.querySelector('body');" +
                    "if (window.angular) {" +
                        "angular.element(el).injector().get('$browser').notifyWhenNoOutstandingRequests(callback);" +
                    "} else {callback()}");
View Full Code Here

    @Test
    public void testStelenessAndJavascriptOnWebDriver() {
        WebElement stale = browser.findElement(By.className("stale"));
        makeStale.click();
        JavascriptExecutor executor = (JavascriptExecutor) browser;
        installator.install();
        executor.executeScript("Graphene.jQuery(arguments[0]).trigger('blur')", stale);
    }
View Full Code Here

    @Test
    public void testStelenessAndJavascriptOnWebElement() {
        WebElement inStale = browser.findElement(By.className("stale")).findElement(By.className("in-stale"));
        makeStale.click();
        JavascriptExecutor executor = (JavascriptExecutor) browser;
        installator.install();
        executor.executeScript("Graphene.jQuery(arguments[0]).trigger('blur')", inStale);
    }
View Full Code Here

        p.body("    };");
        p.body("</h:outputScript>");
    }

    public static Document getDocument(WebDriver browser) throws SAXException, IOException, ParserConfigurationException {
        final JavascriptExecutor executor = (JavascriptExecutor) browser;

        String responseText = (String) executor.executeScript("return __response");

        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        return dBuilder.parse(new ByteArrayInputStream(responseText.getBytes()));
    }
View Full Code Here

        p.body("    };");
        p.body("</h:outputScript>");
    }

    public static Document getDocument(WebDriver browser) throws SAXException, IOException, ParserConfigurationException {
        final JavascriptExecutor executor = (JavascriptExecutor) browser;

        String responseText = (String) executor.executeScript("return __response");

        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        return dBuilder.parse(new ByteArrayInputStream(responseText.getBytes()));
    }
View Full Code Here

        this.contextRoot = getContextRoot();
        ShowcaseLayout layout = loadLayout();
        if (runInPortalEnv) {
            webDriver.get(String.format("%s://%s:%s/%s", contextRoot.getProtocol(), contextRoot.getHost(),
                contextRoot.getPort(), "portal/classic/showcase"));
            JavascriptExecutor js = (JavascriptExecutor) webDriver;
            String setTextQuery = "document.querySelector(\"input[id$='portalForm:%s']\").value = '%s';";
            js.executeScript(String.format(setTextQuery, "seleniumTestDemo", getDemoName()));
            js.executeScript(String.format(setTextQuery, "seleniumTestSample", getSampleName()));
            js.executeScript("document.querySelector(\"a[id$='portalForm:redirectToPortlet']\").click()");
        } else {
            if (layout == ShowcaseLayout.MOBILE) {
                webDriver.get(this.contextRoot.toExternalForm() + "mobile/"); // because of '#' in URLs
            }
            webDriver.get(contextRoot.toExternalForm() + addition);
View Full Code Here

        }

        @Override
        public void perform() {
            String jQueryCmd = String.format("jQuery(arguments[0]).trigger('%s')", event);
            JavascriptExecutor js = (JavascriptExecutor) driver;
            js.executeScript(jQueryCmd, element);
        }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.JavascriptExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.