Package org.seleniuminspector

Examples of org.seleniuminspector.ElementInspector


public class JSFC_2257Test extends OpenFacesTestCase {
     @Test
    public void testTextAreaIsNotAffectedByOpenFacesValidation() throws Exception {
        testAppFunctionalPage("/requests/JSFC_2257.jsf");

        ElementInspector dmf = element("dfm0");
        dmf.assertElementExists(false);
        TextAreaInspector textArea = new TextAreaInspector("fm:ta");
        textArea.type("Some text");
        ElementInspector button = element("fm:bt");
        button.clickAndWait();
        textArea.assertValue("Some text");
        for (int i = 0; i < "Some text".length(); i++)
            textArea.keyPress(Keys.BACK_SPACE);
//        textArea.type("");
        dmf.assertElementExists(false);
        button.click();
        dmf.assertElementExists(true);
    }
View Full Code Here


        Selenium selenium = getSelenium();
        testAppFunctionalPage("/requests/JSFC-2662.jsf");
        sleep(10000);
        Assert.assertEquals("JSFC-2662", selenium.getTitle());

        ElementInspector suggestionField = element("formID:degree");
        suggestionField.keyDown(KeyEvent.VK_DOWN);
        suggestionField.keyDown(KeyEvent.VK_DOWN);

        //press 'enter'
        suggestionField.keyPress(13);
        //press 'delete' button
        suggestionField.keyPress(KeyEvent.VK_DELETE);
        //press 'end' button
        suggestionField.keyPress(KeyEvent.VK_END);
        assertFalse(window().document().isAlertPresent());
    }
View Full Code Here

    // JSFC-1903 Infinite recursion in JS on invoking Confirmation by "invokerID" attribute
     @Test
    public void testConfirmationWithInvokerId() {
        testAppFunctionalPage("/requests/JSFC-1903.jsf");
        ElementInspector button = element("button1");
        button.click();

        ConfirmationInspector confirmation = confirmation("form1:conf1");
        confirmation.cancelButton().click();
        button.click();
        confirmation.okButton().click();
        assertEquals("!", window().document().getAlert());
        acceptAlert();
    }
View Full Code Here

public class JSFC_2186Test extends OpenFacesTestCase {
     @Test
    public void testFloatingIconMessageIsHidedWhenTargetElementIsInvisible() throws InterruptedException {
        testAppFunctionalPage("/requests/JSFC-2186.jsf");

        ElementInspector iconMessage = element("fm:fim");
        iconMessage.assertElementExists(false);
        element("fm:btn").click();
        iconMessage.assertVisible(true);

        TabbedPaneInspector tabbedPane = tabbedPane("fm:tp");
        tabbedPane.tabSet().tabs().get(1).click();
        waitForFloatingIconMessageRepaint();
        iconMessage.assertVisible(false);
        ElementInspector inputText = element("fm:it");
        inputText.assertVisible(false);
        tabbedPane.tabSet().tabs().get(0).click();
        waitForFloatingIconMessageRepaint();
        iconMessage.assertVisible(true);
        inputText.assertVisible(true);
    }
View Full Code Here

    public ElementInspector hint() {
        return new ElementByLocatorInspector(id() + HintLabelRenderer.HINT_SUFFIX);
    }

    public void checkVisibilityAndContent(String value, String hint) {
        ElementInspector hintElement = hint();

        hintElement.assertVisible(false);
        assertVisible(true);
        assertText(value);

        mouseOver();
        sleep(250);
        hintElement.assertVisible(true);
        hintElement.assertText(hint);
    }
View Full Code Here

        Actions click = new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.id("formID:singleSelectionTreeTableID:0:categoryID")))
                .click();
        click.build().perform();

        ElementInspector emptyElement = element("empty");
        ElementInspector treeTable = element("formID:singleSelectionTreeTableID");
        treeTable.focus();
        for (int i = 1; i < 26; i++) {
            if (i == 1 || i == 4 || i == 16 || i == 19 || i == 21 || i == 24) {
                //click right arrow to expand first TreeTable node
                Actions right = new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
                right.build().perform();
                OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
            }
            //get selected index value
            emptyElement.assertText(String.valueOf(i - 1));
            //click down arrow
            Actions down = new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN);
            down.build().perform();
        }
        //check mouse selection for the same TreeTable
        element("formID:singleSelectionTreeTableID:1:categoryID").click();
        emptyElement.assertText("3");
        element("formID:singleSelectionTreeTableID:4_1:nameID").click();
        emptyElement.assertText("22");

        /*Check TreeTable with defined 'nodePath' and 'nodeData' attributes*/
        element("formID:singleNodePathSelectionTreeTableID:3:categoryID").click();
        ElementInspector selectionNodePath = element("selectionNodePathID");
        String indexBeforeSubmitNodePathTreeTable = selectionNodePath.text();

        element("formID:singleNodeDataSelectionTreeTableID:1:categoryID").keyPress(KeyEvent.VK_RIGHT);
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        treeTable.keyPress(KeyEvent.VK_DOWN);
        ElementInspector selectionNodeData = element("selectionNodeDataID");
        String indexBeforeSubmitNodeDataTreeTable = selectionNodeData.text();
        element("formID:submitID").clickAndWait();

        selectionNodePath.assertText(indexBeforeSubmitNodePathTreeTable);
        selectionNodeData.assertText(indexBeforeSubmitNodeDataTreeTable);
    }
View Full Code Here

     */
    //todo: add checking multiple selection functionality with the 'Ctrl' key
     @Test
    public void testMultipleSelectionAndKeyboardNavigation() {
        testAppFunctionalPage("/components/treetable/treeTableMultipleSelection.jsf");
        ElementInspector categoryOutput = element("formID:multipleSelectionTreeTableID:0:categoryID");
        Actions click= new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.id("formID:multipleSelectionTreeTableID:0:categoryID")))
                .click();
        click.build().perform();
//        categoryOutput.click();

        TreeTableInspector multipleSelectionTreeTable = treeTable("formID:multipleSelectionTreeTableID");
        multipleSelectionTreeTable.focus();
        /*check keyboard navigation and selection*/
        //select root nodes
        for (int i = 0; i < 5; i++) {
            createEvent(multipleSelectionTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }
        ElementInspector emptyElement = element("empty");
        emptyElement.assertText("  0 1 2 3 4 5");

        for (int i = 0; i < 6; i++) {
            multipleSelectionTreeTable.getElementsByTagName("img").get(i).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        }

        categoryOutput.click();
        for (int i = 0; i < 25; i++) {
            createEvent(multipleSelectionTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }


        emptyElement.assertText("  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24");
        for (int i = 0; i < 6; i++) {
            multipleSelectionTreeTable.getElementsByTagName("img").get(i).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        }

        categoryOutput.click();
        for (int i = 0; i < 5; i++) {
            createEvent(element("formID:multipleSelectionTreeTableID"), null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }
        emptyElement.assertText("  0 3 15 18 20 23");

        /*check 'nodePaths' and 'nodeDatas' attributes*/
        //verify is attributes took right initial values
        ElementInspector nodePathsOutput = element("formID:nodePathsID");
        nodePathsOutput.assertText("Document BrowsingNetwork Access");
        ElementInspector nodeDataOutput = element("formID:nodeDatasID");
        nodeDataOutput.assertText("Document BrowsingDocument Deletion");
        ElementInspector selectionNodePathsDiv = element("selectionNodePathsID");
        selectionNodePathsDiv.assertText("  1 5");
        ElementInspector selectionNodeDataDiv = element("selectionNodeDatasID");
        selectionNodeDataDiv.assertText("  1 4");

        //check root nodes
        element("formID:multipleNodePathsSelectionTreeTableID:0:categoryID").click();
        TreeTableInspector multipleNodePathsTreeTable = treeTable("formID:multipleNodePathsSelectionTreeTableID");
        Actions down = new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.xpath(multipleNodePathsTreeTable.getXPath())))
                .sendKeys(Keys.ARROW_DOWN);
        down.build().perform();
//        multipleNodePathsTreeTable.keyPress(Keys.ARROW_DOWN);
        element("formID:multipleNodeDatasSelectionTreeTableID:0:categoryID").click();
        TreeTableInspector multipleNodeDataTreeTable = treeTable("formID:multipleNodeDatasSelectionTreeTableID");
        down = new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.xpath(multipleNodeDataTreeTable.getXPath())))
                .sendKeys(Keys.ARROW_DOWN);
        down.build().perform();
//        multipleNodeDataTreeTable.keyPress(Keys.ARROW_DOWN);

        //check root + expanded child nodes
        element("formID:multipleNodePathsSelectionTreeTableID:4:categoryID").click();

        //click right arrow
        Actions right = new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.xpath(multipleNodeDataTreeTable.getXPath())))
                .sendKeys(Keys.ARROW_RIGHT);
        right.build().perform();
//        multipleNodePathsTreeTable.keyPress(Keys.ARROW_RIGHT);
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        for (int i = 0; i < 3; i++) {
            createEvent(multipleNodePathsTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }

        click= new Actions(getDriver()).moveToElement(
                getDriver().findElement(By.id("formID:multipleNodeDatasSelectionTreeTableID:2:categoryID")))
                .click();
        click.build().perform();
//        element("formID:multipleNodeDatasSelectionTreeTableID:2:categoryID").click();
        multipleNodeDataTreeTable.keyPress(Keys.ARROW_RIGHT);
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        for (int i = 0; i < 3; i++) {
            createEvent(multipleNodeDataTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }
        element("formID:submitID").clickAndWait();
        nodePathsOutput.assertText("Document DeletionSemen SemenychIvan IvanychNetwork Access");
        nodeDataOutput.assertText("Document CreationAdministratorIvan IvanychDocument Modification");
        selectionNodePathsDiv.assertText("  4 5 6 7");
        selectionNodeDataDiv.assertText("  2 3 4 5");
        //todo: checking with collapsed child node should be added after fix of 'JSFC-2603'
    }
View Full Code Here

        treeTable.focus();
//        Actions dpwn = new Actions(getDriver()).moveToElement(
//                getDriver().findElement(By.xpath(treeTable.bodyRow(0).getXPath())))
//                .sendKeys(getDriver().findElement(By.xpath(treeTable.bodyRow(0).getXPath())), Keys.ARROW_DOWN);
//        dpwn.build().perform();
        ElementInspector emptyElement = element("empty");
        //down arrow
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, false);
        emptyElement.assertText("  0");

        //'End' button
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_END, false);
        emptyElement.assertText("  6");

        //up arrow
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_UP, false);
        emptyElement.assertText("  5");

        //'Home' button
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_HOME, false);
        emptyElement.assertText("  0");

        //left arrow
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_LEFT, false);

        //right arrow
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_RIGHT, false);

        //'minus' sign
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_SUBTRACT, false);

        //'plus' sign
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_ADD, false);

        //'Shift' + down arrow
        for (int i = 0; i < 6; i++) {
            createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true);
        }
        emptyElement.assertText("  0 1 2 3 4 5 6");
        //'Shift' + up arrow
        for (int i = 0; i < 6; i++) {
            createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_UP, true);
        }
        emptyElement.assertText("  0");

        //'Shift' + 'End'
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_END, true);
        emptyElement.assertText("  0 1 2 3 4 5 6");

        //'Shift' + 'Home'
        createEvent(treeTable, null, EventType.KEY, "keypress", KeyEvent.VK_HOME, true);
        emptyElement.assertText("  0");
    }
View Full Code Here

     //
     @Test
    public void testActionPhase() {
        testAppFunctionalPage("/components/ajax/ajax.jsf");
        element("form1:resetBtn").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        ElementInspector counter = element("form1:counter");
        counter.assertText("0");

        // check operation with <h:commandButton> -- a special implementation case
        element("form1:btn1").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("1"); // check direct embedding
        element("form1:btn2").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("2"); // check attaching with "for" attribute
        element("form1:btn3").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("3"); // standalone invokation

        // check operation with <h:commandButton> -- a special implementation case
        element("form1:link1").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("4"); // check direct embedding
        element("form1:link2").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("5"); // check attaching with "for" attribute
        element("form1:link3").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("6"); // standalone invokation

        // check operation with <h:inputText> -- a non-default event, delay

        InputTextInspector inputText = inputText("form1:input1");
        inputText.typeKeys("1");
        sleep(100);
        inputText.typeKeys("2");
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        counter.assertText("7"); // check direct embedding
        inputText = inputText("form1:input2");
        inputText.typeKeys("1");
        sleep(100);
        inputText.typeKeys("2");
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        counter.assertText("8"); // check attaching with "for" attribute
        inputText = inputText("form1:input3");
        inputText.typeKeys("1");
        sleep(100);
        inputText.typeKeys("2");
        OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
        counter.assertText("9"); // standalone invokation

        // check operation with <h:graphicImage> -- a case for a typical JSF component without special implementation cases
        element("form1:image1").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("10"); // check direct embedding
        element("form1:image2").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("11"); // check attaching with "for" attribute
        element("form1:image3").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("12"); // standalone invokation

        // check operation with HTML tags
        element("div2").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("13"); // check attaching with "for" attribute
        element("div3").clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
        counter.assertText("14"); // standalone invokation
    }
View Full Code Here

    protected void checkStyles(boolean makeSubmit, boolean isFocused, boolean isDisabled, String pageUrl, boolean isDropDown) {
        Selenium selenium = getSelenium();
        testAppFunctionalPage(pageUrl);

        ElementInspector submitElement = element("formID:submit");

        if (makeSubmit) {
            submitElement.clickAndWait();
        }
        DropDownFieldInspector dropDown = dropDownField("formID:styled");

        ElementInspector button = dropDown.button();
        ElementInspector field = dropDown.field();
        DropDownPopupInspector popup = dropDown.popup();
        List<ElementInspector> items = popup.items();

        if (isFocused) {
            if (isDropDown)
                field.focus();
            else
                dropDown.focus();
        } else {
            if (isDropDown)
                field.fireEvent("onblur");
            else
                dropDown.fireEvent("onblur");
        }

        if (!isDisabled) {
            dropDown.assertExpressionEquals("offsetWidth", 230, 5);

            if (isFocused) {
                dropDown.assertStyle("border: 1px solid yellow;");
            }

            if (!isDropDown) {
                dropDown.assertStyle("background: GreenYellow; font-weight: bold;");
            }

            if (isDropDown) {
                button.assertStyle("border: 1px solid blue; background: PowderBlue;");

                button.childNodes().get(0).assertAttributeStartsWith("src", "dropdown_arrow.gif");

                field.assertStyle("background: GreenYellow; font-weight: bold;");

                button.mouseDown();
                button.assertStyle("border: 1px solid OrangeRed; background: PaleVioletRed;");
                button.mouseUp();

                if (!isFocused) {
                    field.fireEvent("onblur");
                }
            }

            if (!isDropDown) {
                dropDown.keyDown(KeyEvent.VK_DOWN);
                if (!isFocused) {
                    dropDown.fireEvent("onblur");
                }
            }

            ElementInspector item2 = items.get(2);
            if (isDropDown)
                item2.assertStyle("font-size: 18px;");
            else
                item2.childNodesByName("td").get(0).assertStyle("font-size: 18px;");
            item2.assertStyle("color: Teal;");

            popup.assertStyle("border: 1px dotted red");

            TableInspector itemsTable = popup.itemsTable();
            ElementInspector firstFooterCell = itemsTable.subElement("tfoot[0]/tr[0]/td[0]");
            firstFooterCell.assertStyle("color: silver");

            itemsTable.subElement("thead[0]/tr[0]").assertStyle("text-decoration: underline");
            ElementInspector firstHeaderCell = itemsTable.subElement("thead[0]/tr[0]/td[0]");
            firstHeaderCell.assertStyle("color: red");

            items.get(1).assertStyle("background: bisque;");

            items.get(2).subElement("td[0]").assertStyle("border-right: 1px solid blue; border-bottom: 2px dotted DarkOliveGreen");

            firstHeaderCell.assertStyle("border-right: 2px dashed springgreen; border-bottom: 2px solid fuchsia");
            firstFooterCell.assertStyle("border-right: 3px solid black; border-top: 2px solid green");

            selenium.mouseMove("formID:styled");
            if (isDropDown) {
                if (!isFocused) { // focusedStyle has higher prioriry than rolloverStyle
View Full Code Here

TOP

Related Classes of org.seleniuminspector.ElementInspector

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.