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.


    * @author Darya Shumilina
    */
    public class DynamicImageTest extends OpenFacesTestCase {
         @Test
        public void testReRenderThroughA4J() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/dynamicimage/dynamicImage_a4j.jsf");
            String oldValue = selenium.getHtmlSource();
            selenium.click("formID:refresher");
            RichFacesAjaxLoadingMode.getInstance().waitForLoad();
            String newValue = selenium.getHtmlSource();
            assertFalse(newValue.equals(oldValue));
        }
    View Full Code Here


            open(TEST_APP_URL_PREFIX, testAppPageUrl, htmlSubstringOfAValidPage, 5);
        }

        @Override
        protected void assertPageAvailable(String pageUrl, String expectedPageTitle) {
            Selenium selenium = getSelenium();
            open("", pageUrl, getUtilJsUrlSubstring(), 5);
            assertEquals("Couldn't open page (unexpected page title): " + pageUrl, expectedPageTitle, selenium.getTitle());
        }
    View Full Code Here

                boolean failIfNotLoaded) {
            String fullPageUrl = applicationUrl + pageUrl;
            if (htmlSubstringOfAValidPage == null)
                return true;

            Selenium selenium = getSelenium();
            String htmlSource;
            try {
                htmlSource = selenium.getHtmlSource();
            } catch (SeleniumException e) {
                String pageTitle;
                try {
                    pageTitle = selenium.getTitle();
                } catch (Exception ex) {
                    pageTitle = "<exception on selenium.getTitle(): " + ex.getMessage() + ">";
                }
                try {
                    String alert = selenium.getAlert();
                    if (failIfNotLoaded)
                        throw new RuntimeException("Couldn't open the page (failed getting HTML source of a page). " +
                                "Alert dialog has popped up: " + alert + "; page URL: " + fullPageUrl +
                                "; Page title: " + pageTitle, e);
                    else
    View Full Code Here

    */
    public class DateChooserValidationTest extends OpenFacesTestCase {

         @Test
        public void testClientValidationOff() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datechooser/dateChooserValid.jsf");
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(false);
            dateChooser("testForm:dateChooserOff").field().type("wrong");
            assertConversionErrorOccured(false);
            element("testForm:submitBtn").clickAndWait();
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(true);
        }
    View Full Code Here

            assertConversionErrorOccured(true);
        }

         @Test
        public void testClientValidationOnSubmit() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datechooser/dateChooserValid.jsf");
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(false);
            dateChooser("testForm:dateChooserOnSubmit").field().type("wrong");
            assertConversionErrorOccured(false); // no global message is shown upon just typing, it'll be shown after submission attempt
            element("testForm:submitBtn").click();
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(true);
        }
    View Full Code Here

            assertConversionErrorOccured(true);
        }

         @Test
        public void testClientValidationDefault() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/datechooser/dateChooserValid.jsf");
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(false);
            dateChooser("testForm:dateChooserDefault").field().type("wrong");
            assertConversionErrorOccured(false); // no global message is shown upon just typing, it'll be shown after submission attempt
            element("testForm:submitBtn").click();
            assertEquals("DateChooser Valid", selenium.getTitle());
            assertConversionErrorOccured(true);
        }
    View Full Code Here

        }

         @Test
        @Ignore
        public void testChangeLocaleFromBinding() {
            Selenium selenium = getSelenium();
            liveDemoPage("/datechooser/DateChooser.jsf");
            assertPageContainsErrorIcon(false);

            DateChooserInspector defaultDateChooser = dateChooser("dcForm:dcDefault");
            defaultDateChooser.field().clear();
            defaultDateChooser.field().type("Oct 17, 2006sdfsdf");
            DateChooserInspector mMddDateChooser = dateChooser("dcForm:dcMMdd");
            mMddDateChooser.field().clear();
            mMddDateChooser.field().type("10/17/2006");
            assertPageContainsErrorIcon(true);
            defaultDateChooser.field().clear();
            defaultDateChooser.field().type("Oct 10, 2006");
            mMddDateChooser.field().clear();
            mMddDateChooser.field().type("10/17/2006");
            assertPageContainsErrorIcon(false);
            tabSet("dcForm:localeSelector").setTabIndex(1, OpenFacesAjaxLoadingMode.getInstance());
            assertEquals("Date Chooser \u2014 OpenFaces Demo", selenium.getTitle());
            assertPageContainsErrorIcon(false);
            defaultDateChooser.field().clear();
            defaultDateChooser.field().type("Oct 17, 2006sdfsdf");
            mMddDateChooser.field().clear();
            mMddDateChooser.field().type("10/17/2006");
    View Full Code Here

         *                          properties/function calls that should be evaluated, e.g. "checked", "_getContent().isVisible()"
         * @return the result of expression evaluation converted to boolean value according to JavaScript rules
         * @see #evalExpression
         */
        public boolean evalBooleanExpression(String elementExpression) {
            Selenium selenium = getSelenium();
            String fullExpression = "!!(" + getElementReferenceExpression() + "." + elementExpression + ")";
            try {
                return Boolean.parseBoolean(getEval(fullExpression));
            } catch (RuntimeException e) {
                throw new RuntimeException("Error evaluating Selenium expression: " + fullExpression, e);
    View Full Code Here

        //JSFC-1954
        @Ignore
         @Test
        public void disabledTestFPClientValidation() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/foldingpanel/foldingPanelAjax.jsf");
            foldingPanel("form1:fp1").toggle().clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
            selenium.type("form1:input1", "");
            selenium.click("form1:sumbitForm1");
            assertTrue(selenium.isTextPresent("\"input1\": Value is required."));
            assertTrue(selenium.isTextPresent("Validation Error"));
        }
    View Full Code Here

        //JSFC-1954
        @Ignore
         @Test
        public void disabledTestTPClientValidation() throws Exception {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/tabbedpane/tabbedPaneAjax.jsf");
            tabbedPane("form1:tp1").tabSet().tabs().get(1).click();
            OpenFacesAjaxLoadingMode.getInstance().waitForLoad();
            selenium.type("form1:input2", "");
            selenium.click("form1:submitForm");
            assertTrue(selenium.isTextPresent("\"input2\": Value is required."));
            assertTrue(selenium.isTextPresent("Validation Error"));
        }
    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.