Package com.thoughtworks.selenium

Examples of com.thoughtworks.selenium.Selenium

  • link=textPattern: Select the link (anchor) element which contains text matching the specified pattern.
  • css=cssSelectorSyntax: Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.

    Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).

  • Without an explicit locator prefix, Selenium uses the following default strategies:

    Element Filters

    Element filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.

    Filters look much like locators, ie.

    filterType=argument

    Supported element-filters are:

    value=valuePattern

    Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.

    index=index

    Selects a single element based on its position in the list (offset from zero).

    String-match Patterns

    Various Pattern syntaxes are available for matching string values:

    If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern.

    For commands that return multiple values (such as verifySelectOptions), the string being matched is a comma-separated list of the return values, where both commas and backslashes in the values are backslash-escaped. When providing a pattern, the optional matching syntax (i.e. glob, regexp, etc.) is specified once, as usual, at the beginning of the pattern.


        //JSFC-1953
        @Ignore
         @Test
        public void disabledTestFPMessages() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/foldingpanel/foldingPanelAjax.jsf");
            FoldingPanelInspector fp2 = foldingPanel("form2:fp2");
            fp2.toggle().click();
            OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
            selenium.type("form2:input2", "");
            selenium.click("form2:submitForm2");
            waitForPageToLoad();
            fp2.toggle().click();
            selenium.click("form2:submitForm2");
            waitForPageToLoad();
            assertFalse(selenium.isElementPresent("form1:input2"));
            assertFalse(selenium.isTextPresent("\"input2\": Value is required."));
            assertFalse(selenium.isTextPresent("Validation Error"));
        }
    View Full Code Here


        }

        @Ignore
         @Test
        public void disabledTestPagingValidation() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datatable/dataTableAjax.jsf");
            selenium.type("form2:dataTable2:0:inputProfession2", "");
            selenium.click("form2:dataTable2:paginator2--nextPage");
            OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
            assertEquals("John Smith", selenium.getValue("form2:dataTable2:0:inputName2"));
            assertTrue(selenium.isTextPresent("\"inputProfession2\": Value is required."));
            assertTrue(selenium.isTextPresent("Validation Error"));
            assertEquals("1", selenium.getValue("form2:dataTable2:paginator2--pageNo"));
        }
    View Full Code Here

        }

        @Ignore
         @Test
        public void disabledTestPagingClientValidation() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datatable/dataTableAjax.jsf");
            selenium.type("form1:dataTable1:0:inputProfession", "");
            selenium.click("form1:dataTable1:paginator1--nextPage");
            assertTrue(selenium.isTextPresent("\"inputProfession1\": Value is required."));
            assertTrue(selenium.isTextPresent("Validation Error"));
            assertEquals("1", selenium.getValue("form2:dataTable2:paginator2--pageNo"));
        }
    View Full Code Here

        protected void waitForPageToLoad() {
            ServerLoadingMode.getInstance().waitForLoad();
        }

        protected void assertPageAvailable(String pageUrl, String expectedPageTitle) {
            Selenium selenium = getSelenium();
            openAndWait(pageUrl);
            assertEquals("Checking page has loaded successfully: " + pageUrl, expectedPageTitle, selenium.getTitle());
        }
    View Full Code Here

            openAndWait(pageUrl);
            assertEquals("Checking page has loaded successfully: " + pageUrl, expectedPageTitle, selenium.getTitle());
        }

        protected void assertNoAlert(String messagePrefix) {
            Selenium selenium = getSelenium();
            if (selenium.isAlertPresent()) {
                fail(messagePrefix + " " + selenium.getAlert());
            }
        }
    View Full Code Here

         * @return unique item name to create
         */
        protected String getUniqueName(String originalName) {
            String result = originalName;
            int index = 0;
            Selenium selenium = getSelenium();
            while (selenium.isTextPresent(result)) {
                result = originalName + index++;
            }
            return result;
        }
    View Full Code Here

            }
            return result;
        }

        protected boolean isMessageTextPresent(String text) {
            Selenium selenium = getSelenium();
            return selenium.isElementPresent("//span[contains(text(),'" + text + "')]") ||
                    selenium.isElementPresent("//li[contains(text(),'" + text + "')]");
        }
    View Full Code Here

            waitForPageToLoad();
            isPassedStandardInputs(clientValidationFormName);
        }

        private void fillDataStandardInputs(String formName) {
            Selenium selenium = getSelenium();
            selenium.type(formName + "inputSecret", "password");
            selenium.type(formName + "inputText", "item 1");
            selenium.type(formName + "inputTextarea", "text");
            selenium.click(formName + "selectBooleanCheckbox");
            selenium.click("//*[@value='item 1'][@name='" + formName + "selectManyCheckbox']");
            selenium.addSelection(formName + "selectManyListbox", "label=dogs");
            selenium.addSelection(formName + "selectManyMenu", "label=dogs");
            selenium.select(formName + "selectOneListbox", "label=dogs");
            selenium.select(formName + "selectOneMenu", "label=dogs");
            selenium.click("//*[@value='item 1'][@name='" + formName + "selectOneRadio']");
        }
    View Full Code Here

            element(formName + "DateConv2Message").assertText("");
            element(formName + "NumberConvMessage").assertText("");
        }

        private void isFailedStandardValidators(String formName) {
            Selenium selenium = getSelenium();
            assertTrue(selenium.getText(formName + "RequiredMessage").contains("Validation Error"));

            ElementInspector doubleRangeMsg = element(formName + "ValidDRMessage");
            assertTrue(
                    doubleRangeMsg.text().contains("Validation Error: Specified attribute is not between the expected values of 0.001 and 0.999.") ||
                            doubleRangeMsg.text().contains("Validation Error: Specified attribute is not between the expected values of 0,001 and 0,999.") ||
                            doubleRangeMsg.text().equals("Validation Error"));

            ElementInspector longRangeMsg = element(formName + "ValidLRMessage");
            assertTrue(
                    longRangeMsg.text().contains("Validation Error: Specified attribute is not between the expected values of 10 and 100.") ||
                            longRangeMsg.text().equals("Validation Error"));


            element(formName + "ValidLMessage").assertContainsText("Validation Error");
            if (formName.equals("serverValidation:")) {
                assertSubstringIgnoreCase("serverValidation:intConv: 'Non-integer value' must be a number consisting of one or more digits.", selenium.getText(formName + "IntConvMessage"));
                assertSubstringIgnoreCase("serverValidation:doubleConv: 'Non-double value' must be a number consisting of one or more digits.", selenium.getText(formName + "DoubleConvMessage"));
                assertSubstringIgnoreCase("serverValidation:byteConv: '2V0' must be a number between 0 and 255.", selenium.getText(formName + "ByteConvMessage"));
                assertSubstringIgnoreCase("serverValidation:shortConv: '999999999' must be a number consisting of one or more digits.", selenium.getText(formName + "ShortConvMessage"));
                assertSubstringIgnoreCase("serverValidation:floatConv: '2V0' must be a number consisting of one or more digits.", selenium.getText(formName + "FloatConvMessage"));
                assertSubstringIgnoreCase("serverValidation:dateConv: '12/02/2007' could not be understood as a date.", selenium.getText(formName + "DateConvMessage"));
                assertSubstringIgnoreCase("serverValidation:dateConv2: '12/02/2007' could not be understood as a date and time.", selenium.getText(formName + "DateConv2Message"));
                assertSubstringIgnoreCase("serverValidation:numberConv: 'Not Number' is not a number pattern.", selenium.getText(formName + "NumberConvMessage"));
            } else {
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "IntConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "DoubleConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "ByteConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "ShortConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "FloatConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "DateConvMessage"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "DateConv2Message"));
                assertSubstringIgnoreCase("Conversion error", selenium.getText(formName + "NumberConvMessage"));
            }
        }
    View Full Code Here

    * @author Darya Shumilina
    */
    public class FoldingPanelClientSideEvents extends OpenFacesTestCase {
         @Test
        public void testFoldingPanelClientSideEvents() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/foldingpanel/foldingPanel.jsf");

            // onclick
            element("formID:clickID").click();
            assertTrue(selenium.isTextPresent("onclick works"));
            assertTrue(selenium.isTextPresent("click"));

            // ondblclick
            element("formID:doubleclickID").doubleClick();
            assertTrue(selenium.isTextPresent("ondblclick works"));
            assertTrue(selenium.isTextPresent("dblclick"));

            // onmousedown
            element("formID:mousedownID").mouseDown();

            assertTrue(selenium.isTextPresent("onmousedown works"));
            assertTrue(selenium.isTextPresent("mousedown"));

            // onmouseover
            element("formID:mouseoverID").mouseOver();
            assertTrue(selenium.isTextPresent("onmouseover works"));
            assertTrue(selenium.isTextPresent("mouseover"));

            // onmousemove
            element("formID:mousemoveID").mouseMove();
            assertTrue(selenium.isTextPresent("onmousemove works"));
            assertTrue(selenium.isTextPresent("mousemove"));

            // onmouseout
            element("formID:mouseoutID").mouseOut();
            assertTrue(selenium.isTextPresent("onmouseout works"));
            assertTrue(selenium.isTextPresent("mouseout"));

            // onmouseup
            element("formID:mouseupID").mouseUp();
            assertTrue(selenium.isTextPresent("onmouseup works"));
            assertTrue(selenium.isTextPresent("mouseup"));

            //todo: implement if JSFC-2689 fixed
    /*
        //onfocus

        //onblur
    */

            // onkeydown
            ElementInspector contentKeyDown = element("formID:content_keydownID");
            contentKeyDown.keyDown(KeyEvent.VK_M);
            assertTrue(selenium.isTextPresent("onkeydown works"));
            assertTrue(selenium.isTextPresent("keydown"));

            // onkeyup
            ElementInspector contentKeyUp = element("formID:content_keyupID");
            contentKeyUp.keyUp(KeyEvent.VK_M);
            assertTrue(selenium.isTextPresent("onkeyup works"));
            assertTrue(selenium.isTextPresent("keyup"));

            // onkeypress
            ElementInspector contentKeyPress = element("formID:content_keypressID");
            contentKeyPress.keyPress(KeyEvent.VK_M);
            assertTrue(selenium.isTextPresent("onkeypress works"));
            assertTrue(selenium.isTextPresent("keypress"));

            // onstatechange
            foldingPanel("formID:statechangeID").toggle().click();
            assertTrue(selenium.isTextPresent("onstatechange works"));
            //todo: uncomment if JSFC-2691 and JSFC-1439 fixed
            /*assertTrue(selenium.isTextPresent("statechange"));*/
        }
    View Full Code Here

    TOP

    Related Classes of com.thoughtworks.selenium.Selenium

    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.