org.unitils.selenium
Class WebDriverModule

java.lang.Object
  extended by org.unitils.selenium.WebDriverModule
All Implemented Interfaces:
org.unitils.core.Module

public class WebDriverModule
extends Object
implements org.unitils.core.Module

Since:
1.0.0
Author:
Jeroen Horemans, Thomas De Rycke, Willemijn Wouters

Field Summary
protected static String BASE_URL_KEY
           
protected static String BROWSER_NAME_KEY
           
protected static String CHROME_BINARY_KEY
           
protected static String CHROME_DRIVER_KEY
           
protected static String DOWNLOADPATH
           
protected static String FILETYPE
           
protected static String FIREFOX_BINARY_KEY
           
protected static String IE_BINARY_KEY
           
protected static String LIST_AUTOMATICALLY_DOWNLOAD
           
protected static String LOGGING_FILE_PROP
           
protected static String LOGGINGPROP_BROWSER
           
protected static String LOGGINGPROP_CLIENT
           
protected static String LOGGINGPROP_CONSOLE_ENABLED
           
protected static String LOGGINGPROP_DRIVER
           
protected static String LOGGINGPROP_IE
           
protected static String LOGGINGPROP_PERFORMANCE
           
protected static String LOGGINGPROP_PROFILER
           
protected static String LOGGINGPROP_SERVER
           
protected static String PACKAGENAME
           
protected static String PROXY_HOST_KEY
           
static String TARGETSUREFIREREPORTS
           
 
Constructor Summary
WebDriverModule()
           
 
Method Summary
 void afterInit()
           
protected  void checkChromeDriver(String bit, ClassLoader classLoader)
           
protected  void checkFirefoxDriver()
          This method checks if their is a system property 'webdriver.firefox.bin' and checks if it exists.
protected  void checkIEDriver(String bit, ClassLoader classLoader)
          This method checks if there is a system property 'webdriver.ie.driver' and checks if the location exists.
 boolean checkIfDriverIsAlreadyInSystem(String systemProp, String driver, String systemVarDriver)
           
 boolean checkIfDriverPropertyExistsInUnitilsProperties(String key, String driver, String systemKey)
           
 String copyDriverIntoNewTempFile(URL url, String name)
           
protected static String createLogNewDriver(String systemVarDriver, String absPath)
           
protected static String getAbsoluteDownloadPath(String path)
           
protected  Object getElement(org.openqa.selenium.WebDriver webdriver, Class<?> type)
          This is the actual method that creates an object of the correct type and initialises all the elements.
 org.unitils.core.TestListener getTestListener()
           
 void init(Properties configuration)
           
 void initBaseUrl(Object testObject)
          All the elements with the @BaseUrlString will be initialised with the base url value of the unitils.properties.
 void initElements(Object testObject)
          * Searches all the fields with the WebPage annotation and sets the correct elements.
 void initWebDriver(Object testObject)
          Initialises the webdriver.
protected  void killWebDriver(Object testObject)
          All the webdrivers (all the fields with the TestWebDriver of the testObject will be killed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKAGENAME

protected static final String PACKAGENAME
See Also:
Constant Field Values

BROWSER_NAME_KEY

protected static final String BROWSER_NAME_KEY
See Also:
Constant Field Values

BASE_URL_KEY

protected static final String BASE_URL_KEY
See Also:
Constant Field Values

PROXY_HOST_KEY

protected static final String PROXY_HOST_KEY
See Also:
Constant Field Values

DOWNLOADPATH

protected static final String DOWNLOADPATH
See Also:
Constant Field Values

FILETYPE

protected static final String FILETYPE
See Also:
Constant Field Values

LIST_AUTOMATICALLY_DOWNLOAD

protected static final String LIST_AUTOMATICALLY_DOWNLOAD
See Also:
Constant Field Values

FIREFOX_BINARY_KEY

protected static final String FIREFOX_BINARY_KEY
See Also:
Constant Field Values

IE_BINARY_KEY

protected static final String IE_BINARY_KEY
See Also:
Constant Field Values

CHROME_DRIVER_KEY

protected static final String CHROME_DRIVER_KEY
See Also:
Constant Field Values

CHROME_BINARY_KEY

protected static final String CHROME_BINARY_KEY
See Also:
Constant Field Values

LOGGINGPROP_CONSOLE_ENABLED

protected static final String LOGGINGPROP_CONSOLE_ENABLED
See Also:
Constant Field Values

LOGGINGPROP_PERFORMANCE

protected static final String LOGGINGPROP_PERFORMANCE
See Also:
Constant Field Values

LOGGINGPROP_BROWSER

protected static final String LOGGINGPROP_BROWSER
See Also:
Constant Field Values

LOGGINGPROP_CLIENT

protected static final String LOGGINGPROP_CLIENT
See Also:
Constant Field Values

LOGGINGPROP_DRIVER

protected static final String LOGGINGPROP_DRIVER
See Also:
Constant Field Values

LOGGINGPROP_PROFILER

protected static final String LOGGINGPROP_PROFILER
See Also:
Constant Field Values

LOGGINGPROP_SERVER

protected static final String LOGGINGPROP_SERVER
See Also:
Constant Field Values

LOGGING_FILE_PROP

protected static final String LOGGING_FILE_PROP
See Also:
Constant Field Values

LOGGINGPROP_IE

protected static final String LOGGINGPROP_IE
See Also:
Constant Field Values

TARGETSUREFIREREPORTS

public static final String TARGETSUREFIREREPORTS
See Also:
Constant Field Values
Constructor Detail

WebDriverModule

public WebDriverModule()
Method Detail

init

public void init(Properties configuration)
Specified by:
init in interface org.unitils.core.Module

afterInit

public void afterInit()
Specified by:
afterInit in interface org.unitils.core.Module

initWebDriver

public void initWebDriver(Object testObject)
Initialises the webdriver. The method searches if there are fields with the TestWebDriver and uses the browser choice (in unitils.properties) to create the driver.

Parameters:
testObject -

getAbsoluteDownloadPath

protected static String getAbsoluteDownloadPath(String path)

killWebDriver

protected void killWebDriver(Object testObject)
All the webdrivers (all the fields with the TestWebDriver of the testObject will be killed.

Parameters:
testObject -

initBaseUrl

public void initBaseUrl(Object testObject)
All the elements with the @BaseUrlString will be initialised with the base url value of the unitils.properties.

Parameters:
testObject -

initElements

public void initElements(Object testObject)
* Searches all the fields with the WebPage annotation and sets the correct elements.

Parameters:
testObject -

checkChromeDriver

protected void checkChromeDriver(String bit,
                                 ClassLoader classLoader)

checkFirefoxDriver

protected void checkFirefoxDriver()
This method checks if their is a system property 'webdriver.firefox.bin' and checks if it exists. Otherwise it will check the unitils.properties if their is a property FIREFOX_BINARY_KEY in the unitils.properties.


checkIEDriver

protected void checkIEDriver(String bit,
                             ClassLoader classLoader)
This method checks if there is a system property 'webdriver.ie.driver' and checks if the location exists. If this doesn't exist than he looks if you've defined another IE driver ( IE_BINARY_KEY in your unitils.properties. The last option is that it uses the driver that is given by unitils-selenium.

Parameters:
bit -
classLoader -

checkIfDriverIsAlreadyInSystem

public boolean checkIfDriverIsAlreadyInSystem(String systemProp,
                                              String driver,
                                              String systemVarDriver)

checkIfDriverPropertyExistsInUnitilsProperties

public boolean checkIfDriverPropertyExistsInUnitilsProperties(String key,
                                                              String driver,
                                                              String systemKey)

copyDriverIntoNewTempFile

public String copyDriverIntoNewTempFile(URL url,
                                        String name)

getElement

protected Object getElement(org.openqa.selenium.WebDriver webdriver,
                            Class<?> type)
This is the actual method that creates an object of the correct type and initialises all the elements.

Parameters:
webdriver -
type -
Returns:
Object

getTestListener

public org.unitils.core.TestListener getTestListener()
Specified by:
getTestListener in interface org.unitils.core.Module

createLogNewDriver

protected static String createLogNewDriver(String systemVarDriver,
                                           String absPath)


Copyright © 2014. All Rights Reserved.