org.alfresco.webdrone
Class WebDrone

java.lang.Object
  extended by org.alfresco.webdrone.WebDrone
All Implemented Interfaces:
IWebDrone

public class WebDrone
extends Object
implements IWebDrone

An Alfresco web browser simulator that uses Selenium WebDriver as a base with added helper methods that are specific to Alfresco site and version.

Since:
1.0
Author:
Michael Suzuki

Constructor Summary
WebDrone(org.openqa.selenium.WebDriver driver, AlfrescoVersion alfrescoVersion)
          Constructor
WebDrone(org.openqa.selenium.WebDriver driver, AlfrescoVersion alfrescoVersion, long defaultWaitTime)
          Constructor
 
Method Summary
 boolean canResume()
          Waits for site pop up message to disappear to allow the drone to resume operations on the page.
 Object executeJavaScript(String js)
          Injects java script directly to the page to invoke a change on the page's java script
 org.openqa.selenium.WebElement find(org.openqa.selenium.By by)
          Helper method to find a WebElement.
 List<org.openqa.selenium.WebElement> findAll(org.openqa.selenium.By by)
          Helper method to find all WebElement on HTML page
 org.openqa.selenium.WebElement findAndWait(org.openqa.selenium.By criteria)
          Helper method to find and return a slow loading WebElement.
 org.openqa.selenium.WebElement findAndWait(org.openqa.selenium.By by, long millisecond)
          Helper method to find a WebElement with a time limit in milliseconds.
 org.openqa.selenium.WebElement findAndWaitById(String id)
          Helper method to find and return a slow loading WebElement by id.
 List<org.openqa.selenium.WebElement> findAndWaitForElements(org.openqa.selenium.By criteria)
          Helper method to find and return a slow loading collection of WebElement.
 List<org.openqa.selenium.WebElement> findAndWaitForElements(org.openqa.selenium.By criteria, long waitTime)
          Helper method to find and return a slow loading collection of WebElement.
 org.openqa.selenium.WebElement findById(String id)
          Helper method to find a WebElement by id using the WebDroneProperties to resolve the key value of the id.
 AlfrescoVersion getAlfrescoVersion()
          Gets the AlfrescoVersion that is used.
 HtmlPage getCurrentPage()
          Gets the current page in the form of a page object based on the Alfresco site type.
 String getCurrentUrl()
          Get the URL displayed on the browser.
 String getElement(String key)
          Gets the HTML element id value for the given key.
 String getPageSouce()
          The HTML source code of the page viewed.
 File getScreenShot()
          Grabs a screen shot of what the WebDriver is currently viewing.
 String getTitle()
          Title of the page.
 boolean isRenderComplete(long waitTime)
          Verify if loading of the page is complete using java script to validate state of the HTML DOM.
 void mouseOver(org.openqa.selenium.WebElement element)
          Recreating the action of hovering over a particular HTML element on a page.
 void navigateTo(String url)
          Navigate the browser to given URL.
 void quit()
          End Browser session.
 void setDefaultWaitTime(long defaultWaitTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebDrone

public WebDrone(org.openqa.selenium.WebDriver driver,
                AlfrescoVersion alfrescoVersion)
Constructor

Parameters:
drone - WebDriver browser drone.

WebDrone

public WebDrone(org.openqa.selenium.WebDriver driver,
                AlfrescoVersion alfrescoVersion,
                long defaultWaitTime)
Constructor

Parameters:
drone - WebDriver browser drone.
Method Detail

quit

public void quit()
Description copied from interface: IWebDrone
End Browser session.

Specified by:
quit in interface IWebDrone

navigateTo

public void navigateTo(String url)
Description copied from interface: IWebDrone
Navigate the browser to given URL.

Specified by:
navigateTo in interface IWebDrone
Parameters:
url - String URL

getCurrentPage

public HtmlPage getCurrentPage()
                        throws PageException
Description copied from interface: IWebDrone
Gets the current page in the form of a page object based on the Alfresco site type. If site type is of Share then the page returned will be a SharePage object.

Specified by:
getCurrentPage in interface IWebDrone
Returns:
HtmlPage page object of current view
Throws:
PageException

find

public org.openqa.selenium.WebElement find(org.openqa.selenium.By by)
                                    throws org.openqa.selenium.NoSuchElementException
Helper method to find a WebElement.

Parameters:
by - By criteria to identify HTML element
Returns:
WebElement HTML element
Throws:
org.openqa.selenium.NoSuchElementException

findById

public org.openqa.selenium.WebElement findById(String id)
                                        throws org.openqa.selenium.NoSuchElementException
Helper method to find a WebElement by id using the WebDroneProperties to resolve the key value of the id.

Parameters:
by - By criteria to identify HTML element
Returns:
WebElement HTML element
Throws:
org.openqa.selenium.NoSuchElementException

findAll

public List<org.openqa.selenium.WebElement> findAll(org.openqa.selenium.By by)
                                             throws org.openqa.selenium.NoSuchElementException
Helper method to find all WebElement on HTML page

Parameters:
by - By criteria to identify HTML element
Returns:
WebElement HTML element
Throws:
org.openqa.selenium.NoSuchElementException

findAndWait

public org.openqa.selenium.WebElement findAndWait(org.openqa.selenium.By by,
                                                  long millisecond)
Helper method to find a WebElement with a time limit in milliseconds. During the wait period it will check for the element every 100 millisecond.

Parameters:
by - By criteria to search by
millisecond - time limit
Returns:
WebElement HTML element

isRenderComplete

public boolean isRenderComplete(long waitTime)
Verify if loading of the page is complete using java script to validate state of the HTML DOM.

Parameters:
long - waitTime max time to look for an element
Returns:
true if page has been loaded

findAndWaitById

public org.openqa.selenium.WebElement findAndWaitById(String id)
Helper method to find and return a slow loading WebElement by id.

Parameters:
criteria - By search criteria
Returns:
WebElement HTML element

findAndWait

public org.openqa.selenium.WebElement findAndWait(org.openqa.selenium.By criteria)
Helper method to find and return a slow loading WebElement.

Parameters:
criteria - By search criteria
Returns:
WebElement HTML element

findAndWaitForElements

public List<org.openqa.selenium.WebElement> findAndWaitForElements(org.openqa.selenium.By criteria,
                                                                   long waitTime)
Helper method to find and return a slow loading collection of WebElement.

Parameters:
{{@link - By} search criteria
long - waitTime milliseconds to wait
Returns:
List WebElement HTML elements

findAndWaitForElements

public List<org.openqa.selenium.WebElement> findAndWaitForElements(org.openqa.selenium.By criteria)
Helper method to find and return a slow loading collection of WebElement.

Parameters:
{{@link - By} search criteria
Returns:
List WebElement HTML elements

setDefaultWaitTime

public void setDefaultWaitTime(long defaultWaitTime)

mouseOver

public void mouseOver(org.openqa.selenium.WebElement element)
Recreating the action of hovering over a particular HTML element on a page.

Parameters:
element - WebElement target

getElement

public final String getElement(String key)
Description copied from interface: IWebDrone
Gets the HTML element id value for the given key.

Specified by:
getElement in interface IWebDrone
Parameters:
key - String HTML element id
Returns:
String value of key

getCurrentUrl

public String getCurrentUrl()
Description copied from interface: IWebDrone
Get the URL displayed on the browser.

Specified by:
getCurrentUrl in interface IWebDrone
Returns:
String URL

executeJavaScript

public Object executeJavaScript(String js)
Injects java script directly to the page to invoke a change on the page's java script

Parameters:
js - String script

getTitle

public String getTitle()
Description copied from interface: IWebDrone
Title of the page.

Specified by:
getTitle in interface IWebDrone

getAlfrescoVersion

public AlfrescoVersion getAlfrescoVersion()
Description copied from interface: IWebDrone
Gets the AlfrescoVersion that is used.

Specified by:
getAlfrescoVersion in interface IWebDrone
Returns:
AlfrescoVersion

canResume

public boolean canResume()
Waits for site pop up message to disappear to allow the drone to resume operations on the page.

Returns:
true if message has gone

getPageSouce

public String getPageSouce()
The HTML source code of the page viewed.

Returns:
String of current HTML source

getScreenShot

public final File getScreenShot()
Grabs a screen shot of what the WebDriver is currently viewing. This is only possible on WebDriver that are UI based browser.

Returns:
File screen image of the page


Copyright © 2012. All Rights Reserved.