Class AbstractHtmlEngine

    • Method Detail

      • goToPage

        public void goToPage​(String url)
        Navigate to another URL from within the same already started browser
        Parameters:
        url - of the page to go
      • getCurrentUrl

        public String getCurrentUrl()
        Returns:
        the current URL
      • getPageSource

        public String getPageSource()
        Get page source as String
        Returns:
        page source
      • getWindowTitles

        public String[] getWindowTitles()
        Returns the titles of all windows that the browser knows about
        Returns:
        array of all window titles
      • goToWindow

        public void goToWindow​(String windowTitle)
        Going to window/tab with given title
        Parameters:
        windowTitle - window title or name (the value of "window.name" defined when the window was opened)
      • goToWindow

        public void goToWindow​(String windowTitle,
                               long timeoutInSeconds)
        Going to window/tab with given title
        Parameters:
        windowTitle - window title or name (the value of "window.name" defined when the window was opened)
        timeoutInSeconds - timeout (in seconds) for waiting the target window to appear
      • goToAnotherWindow

        public void goToAnotherWindow​(long timeoutInSeconds)
        Go to window/tab with same title. Note that order of same titled windows is not guaranteed.
        Parameters:
        timeoutInSeconds - timeout (in seconds) for waiting the target window to appear
      • goToMainWindow

        public void goToMainWindow()
        Go to main window/tab
      • goToFirstWindowWithoutTitle

        public void goToFirstWindowWithoutTitle()
        Go to first window/tab without title, skipping the main window
      • closeActiveWindow

        public void closeActiveWindow()
        Close the active window/tab
      • fireEvent

        public void fireEvent​(UiElement element,
                              String eventName)
        Explicitly simulate an event, to trigger the corresponding "onevent" handler.
        Parameters:
        element - the target element
        eventName - the name of the event to fire e.g. click, blur, focus, keydown, keyup, keypress...
      • reloadFrames

        public void reloadFrames()
      • retrieveBrowserFocus

        public void retrieveBrowserFocus()
        Retrieve the browser's focus. This is sometimes needed, for example right before using the RobotEngine
      • executeJavaScript

        public String executeJavaScript​(String javaScriptCommand)
         Gets the result of evaluating the specified JavaScript command. The command/snippet may have multiple lines,
         but only the result of the last line will be returned. 
        Note that, by default, the command will run in the context of the "selenium" object itself, so this will refer to the Selenium object.
        Use window to refer to the window of your application, e.g. var fooEl = window.document.getElementById('foo'); fooEl.name;
        Parameters:
        javaScriptCommand - the JavaScript command
        Returns:
        the result of the specified command. The command/snippet may have multiple lines, but only the result of the last line will be returned.
      • countElements

        public int countElements​(String xpath)
        Returns the number of HTML elements that match the specified xpath
        eg. "//table" would give the number of tables
        Parameters:
        xpath - the xpath expression to evaluate
        Returns:
        matched elements count
      • countElementsByCssSelector

        public int countElementsByCssSelector​(String cssSelector)
        Returns the number of HTML elements that match the specified css selector
        eg. "//table" would give the number of tables
        Parameters:
        cssSelector - the css selector expression to evaluate
        Returns:
        matched elements count
      • setCookie

        public void setCookie​(String cookieName,
                              String cookieValue)
        Parameters:
        cookieName - the name of the cookie. May not be null or an empty string.
        cookieValue - the cookie value. May not be null.
      • setCookie

        public void setCookie​(String name,
                              String value,
                              String domain,
                              String path,
                              Date expiry,
                              boolean isSecure)
        Parameters:
        name - the name of the cookie. May not be null or an empty string.
        value - the cookie value. May not be null.
        domain - the domain the cookie is visible to.
        path - the path the cookie is visible to. If left blank or set to null, will be set to "/".
        expiry - the cookie's expiration date; may be null.
        isSecure - whether this cookie requires a secure connection.
      • getCookies

        public Cookie[] getCookies()
        Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the result
        Returns:
        Cookies array
      • deleteCookieNamed

        public void deleteCookieNamed​(String cookieName)
        Delete the named cookie from the current domain.
        This is equivalent to setting the named cookie's expiration date to some time in the past.
        Parameters:
        cookieName - the name of the cookie. May not be null or an empty string.
      • deleteAllCookies

        public void deleteAllCookies()
        Delete all the cookies for the current domain
      • clickBrowserBackButton

        public void clickBrowserBackButton()
        Move back a single "item" in the browser's history.
      • clickBrowserForwardButton

        public void clickBrowserForwardButton()
        Move a single "item" forward in the browser's history. Does nothing if we are on the latest page viewed.
      • clickBrowserRefreshButton

        public void clickBrowserRefreshButton()
        Refresh the current page.