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.


         @Test
        @Ignore
        // todo: investigate why this test fails on build server (but works locally)
        public void testContentResizeOnWindowResize() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/borderlayoutpanel/borderLayoutPanel1ft.jsf");

            // window resizing was added before window size measurement to overcome strange intermittent size measuremt failures
            window().evalExpression("resizeBy(5, 5)");
            sleep(2000);
            Dimension windowSize = window().size();

            ElementInspector content = element("formID:borderLayoutPanel0::content");
            int width = content.evalIntExpression("offsetWidth");
            int height = content.evalIntExpression("offsetHeight");
            content.assertExpressionEquals("offsetWidth", windowSize.width / 2 - 6, 1);
            content.assertExpressionEquals("offsetHeight", windowSize.height / 2 - 5, 1);
            window().evalExpression("resizeBy(-100, -100)");
            sleep(2000);
            selenium.waitForCondition("window.document.getElementById('textDiv').innerHTML == \"window resized\"", "10000");
            content.assertExpressionEquals("offsetWidth", width - 50);
            content.assertExpressionEquals("offsetHeight", height - 50);
        }
    View Full Code Here


    public class JSFC_1727Test extends OpenFacesTestCase {

        // JSFC-1927 Non modal popup hides after submit
         @Test
        public void testNonModalPopupStateSaving() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/requests/JSFC-1727.jsf");

            ElementInspector popupLayer = element("form1:p");
            popupLayer.assertVisible(false);

            selenium.click("//input[@value='Show']");
            popupLayer.assertVisible(true);

            ElementInspector submit = element("form1:submit");
            submit.clickAndWait();
            popupLayer.assertVisible(true);

            selenium.click("//input[@value='Hide']");
            popupLayer.assertVisible(false);
            submit.clickAndWait();
            popupLayer.assertVisible(false);
        }
    View Full Code Here

        public void testRegExpValidator() {
            final String messageText = "its not correct number";
            final String validateButtonLocator = "//input[@value='Validate']";
            final String validatorFieldLocator = "form1:regExpValidatorField";

            Selenium selenium = getSelenium();
            testAppFunctionalPage("/requests/JSFC_1105.jsf");
            assertFalse(isMessageTextPresent(messageText));

            selenium.click(validateButtonLocator);

            assertFalse(isMessageTextPresent(messageText));
            selenium.type(validatorFieldLocator, "asd12313");

            selenium.click(validateButtonLocator);
            assertTrue(isMessageTextPresent(messageText));
            selenium.type(validatorFieldLocator, "123");

            selenium.click(validateButtonLocator);
            assertFalse(isMessageTextPresent(messageText));
            selenium.type(validatorFieldLocator, "123.5");

            selenium.click(validateButtonLocator);
            assertFalse(isMessageTextPresent(messageText));
            selenium.type(validatorFieldLocator, "123.5asd");

            selenium.click(validateButtonLocator);
            assertTrue(isMessageTextPresent(messageText));
        }
    View Full Code Here

    public class JSFC_1746Test extends OpenFacesTestCase {

        // JSFC-1746 Exception after "Clear selection" for Data Table
         @Test
        public void testNoExceptionAfterClientClearSelection() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datatable/tableDemo.jsf");
            selenium.click("form1:clearSelectionLink");
            selenium.click("//input[@value='Show Checked Users (via form submit) ->']");
            waitForPageToLoad();
            assertEquals("Table Demo", selenium.getTitle());
        }
    View Full Code Here

        //todo: test is not completed; there is problem with 'end' key pressing in selenium
         @Test
        @Ignore
        public void testUnexpectedAlertByKeyboardActions() throws InterruptedException {
            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);
    View Full Code Here

    * @author Pavel Kaplin
    */
    public class JSFC_2321Test extends OpenFacesTestCase {
         @Test
        public void testGlobalMessagesAreShown() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/requests/JSFC-2321.jsf");
            element("fm:btn").clickAndWait();
            assertTrue(selenium.isTextPresent("Some message"));
        }
    View Full Code Here

    public class JSFC_2294Test extends OpenFacesTestCase {

         @Test
        @Ignore
        public void testThereIsNoJSErrorOnAjaxTreeTableReloading() {
            Selenium selenium = getSelenium();
            liveDemoPage("/treetable/TreeTable_selectionAndKeyboard.jsf");
            assertTrue(selenium.getLocation().endsWith("/treetable/TreeTable_selectionAndKeyboard.jsf"));
            TreeTableInspector treeTable = treeTable("form1:requestsTreeTable");
            treeTable.bodyRow(1).click();
            treeTable.bodyRow(1).doubleClick();
            OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
            treeTable.bodyRow(2).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
    View Full Code Here

    ////                        return (Boolean)javascriptExecutor.executeScript("return (document._ajaxInProgressMessage.style.display=='none' ? true : false);");
    ////                    }
    ////                });
    //        sleep(2000);
            sleep(500); // wait a little while Ajax request starts asynchronously
            Selenium selenium = SeleniumHolder.getInstance().getSelenium();
            selenium.waitForCondition("var value = window.document._ajaxInProgressMessage ? window.document._ajaxInProgressMessage.style.display : 'none'; value == 'none';", "30000");
            sleep(2000);
        }
    View Full Code Here

        public void evaluate() throws Throwable {

            try {
                fNext.evaluate();
            } finally {
                Selenium selenium = SeleniumHolder.getInstance().getSelenium();
                selenium.stop();
            }
        }
    View Full Code Here

        public StartBrowserRun(Statement next) {
            fNext = next;
        }

        public void evaluate() throws Throwable {
            Selenium selenium = SeleniumHolder.getInstance().getSelenium();
            selenium.start();

            fNext.evaluate();
        }
    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.