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.


         * @return the evaluated value
         * @see #evalBooleanExpression
         * @see #evalIntExpression
         */
        public String evalExpression(String elementExpression) {
            Selenium selenium = getSelenium();
            String fullExpression = getElementReferenceExpression() + "." + elementExpression;
            try {
                return selenium.getEval(fullExpression);
            } catch (RuntimeException e) {
                throw new RuntimeException("Error evaluating Selenium expression: " + fullExpression, e);
            }
        }
    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(selenium.getEval(fullExpression));
            } catch (RuntimeException e) {
                throw new RuntimeException("Error evaluating Selenium expression: " + fullExpression, e);
            }
        }
    View Full Code Here

        public String adaptColorString(String color) {
            if (color == null || color.trim().length() == 0)
                return color;
            String adaptedColor = adaptedColorStrings.get(color);
            if (adaptedColor == null) {
                Selenium selenium = getSelenium();
                adaptedColor = selenium.getEval("var referenceEl = document.createElement('div'); referenceEl.style.color = '" + color + "';" +
                        "this.page().getCurrentWindow().O$.getElementStyleProperty(referenceEl, 'color');");
                adaptedColorStrings.put(color, adaptedColor);
            }
            return adaptedColor;
        }
    View Full Code Here

        public String adaptFontWeightString(String fontWeight) {
            if (fontWeight == null || fontWeight.trim().length() == 0)
                return fontWeight;
            String adaptedFontWeight = adaptedFontWeightStrings.get(fontWeight);
            if (adaptedFontWeight == null) {
                Selenium selenium = getSelenium();
                adaptedFontWeight = selenium.getEval("var referenceEl = document.createElement('div'); referenceEl.style.fontWeight = '" + fontWeight + "';" +
                        "this.page().getCurrentWindow().O$.getElementStyleProperty(referenceEl, 'font-weight');");
                adaptedFontWeightStrings.put(fontWeight, adaptedFontWeight);
            }
            return adaptedFontWeight;
        }
    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

        public static LoadingMode getInstance() {
            return loadingMode;
        }

        public void waitForLoad() {
            Selenium selenium = SeleniumHolder.getInstance().getSelenium();
            selenium.waitForPageToLoad("30000");
            sleep(1000);
        }
    View Full Code Here

    */
    public class ScrollPositionTest extends OpenFacesTestCase {

         @Test
        public void testScrollPositionByPageLoading() {
            Selenium selenium = getSelenium();
            testAppFunctionalPage("/components/scrollfocus/scrollPosition.jsf");
            assertEquals("600", selenium.getEval("window.pageYOffset"));
            assertEquals("700", selenium.getEval("window.pageXOffset"));
        }
    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.