Class SeleniumVirtualUserScript
- java.lang.Object
-
- com.facilita.fc.runtime.VirtualUserScript
-
- com.facilita.fc.selenium.SeleniumVirtualUserScript
-
- All Implemented Interfaces:
DataDictionary
,SeleniumVirtualUserInterface
public abstract class SeleniumVirtualUserScript extends VirtualUserScript implements SeleniumVirtualUserInterface
A SeleniumVirtualUserScript
.Provides access to the
WebDriver
instance for aSeleniumVirtualUser
.
-
-
Field Summary
-
Fields inherited from class com.facilita.fc.runtime.VirtualUserScript
ct, isMainScript
-
-
Constructor Summary
Constructors Constructor Description SeleniumVirtualUserScript()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JavascriptExecutor
getJavascriptExecutor()
Get aJavascriptExecutor
for thisSeleniumVirtualUser
WebDriver
getUnderlyingWebDriver()
Get the underlyingWebDriver
instance for thisSeleniumVirtualUser
.SeleniumVirtualUser
getVU()
Gets the current VU instance, as the most specialised subclass ofVirtualUser
.WebDriver
getWebDriver()
Get theWebDriver
instance for thisSeleniumVirtualUser
.void
initialiseChromeDriver(java.lang.String pathToChromeDriver)
Create a newChromeDriver
instance for thisSeleniumVirtualUser
.void
initialiseFirefoxDriver()
Create a newFirefoxDriver
instance for thisSeleniumVirtualUser
.void
initialiseHtmlUnitDriver()
Create a newHtmlUnitDriver
instance for thisSeleniumVirtualUser
.void
initialiseHtmlUnitDriver(com.gargoylesoftware.htmlunit.BrowserVersion browserVersion)
Create a newHtmlUnitDriver
instance for thisSeleniumVirtualUser
, impersonating theBrowserVersion
specified.void
initialiseInternetExplorerDriver(java.lang.String pathToIEDriverServer)
Create a newInternetExplorerDriver
instance for thisSeleniumVirtualUser
.void
initialisePhantomJSDriver(java.lang.String pathToPhantomJSExe)
Create a newPhantomJSDriver
instance for thisSeleniumVirtualUser
.void
initialiseWebDriver(WebDriverType driverType)
Create a newWebDriver
instance for thisSeleniumVirtualUser
.void
initialiseWebDriver(WebDriver driver)
Create a newWebDriver
instance for thisSeleniumVirtualUser
.-
Methods inherited from class com.facilita.fc.runtime.VirtualUserScript
acceptCancellation, add, checkIfCancellationRequested, clearProgressPoint, createBackgroundScript, createBackgroundScript, endRequest, endRequest, endTiming, endTiming, endTransaction, endTransaction, endTransaction, error, error, error, error, error, exitVU, exitVU, exitVU, fail, failTiming, failTransaction, failTransaction, finalSequence, finishIterating, finishIteratingRequested, flushEventLog, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, get, get, getBackgroundScriptID, getBackgroundScriptIDs, getBackgroundScriptStatus, getBoolean, getBoolean, getCurrentIteration, getCurrentTimeInXml, getCurrentTransaction, getDataDictionary, getDataDictionary, getDataPath, getDataTable, getDouble, getDouble, getElapsedTime, getFilesDataPath, getFloat, getFloat, getGroupSize, getGroupSize, getGroupSizes, getIndex, getInitialDelay, getInjectorFamilyName, getInjectorName, getInt, getInt, getInteger, getInteger, getIsStopped, getIteration, getIterationDelay, getIterationForTime, getLastError, getLastTransaction, getList, getList, getLong, getLong, getMap, getMaxFailures, getMillisecondsSinceEpoch, getMillisecondsSinceEpoch, getName, getNumberOfErrors, getNumberOfFailures, getNumberOfIterations, getNumberOfWarmupIterations, getNumberOfWarnings, getPauseFactor, getProgressPoint, getRunPath, getSandboxPath, getScriptName, getSecondsSinceEpoch, getSecondsSinceEpoch, getService, getString, getString, getTimingElapsedTime, getTransactionData, getTransactionElapsedTime, getTransactionElapsedTime, getTransactionLoggingOn, getUniqueID, getUniqueID, getVirtualUser, getVUName, hasKey, isFinalScript, isFirstScript, isInitialScript, isIteratedScript, isLastIteration, isPacing, isReadOnly, keys, lastIterationDelay, logCurrentDataValues, nextIteration, nextScript, nextSequence, onBackgroundScriptCancellation, pause, pause, pre, raiseAlert, recordMetric, recordMetrics, recordTransaction, recordTransaction, recordTransaction, recordTransaction, requestToStopBackgroundScript, resume, resumeBackgroundScript, resumeTransaction, resumeTransaction, script, selectRandomEntryFromList, set, setBackgroundScriptID, setBoolean, setCancellationToken, setDouble, setFloat, setInt, setInteger, setList, setLong, setName, setNumberOfWarmupIterations, setPauseFactor, setProgressPoint, setProgressPoint, setProgressPoint, setString, setSynchronizationPoint, setTransactionLoggingOn, startBackgroundScript, startRequest, startTiming, startTransaction, startTransaction, stopBackgroundScriptImmediately, stopImmediately, suspend, suspendBackgroundScript, suspendTransaction, suspendTransaction, timeToPause, toString, tryToSuspend, unsetSynchronizationPoint, verify, verifyEQ, verifyEQ, verifyEQ, verifyEQ, verifyLE, verifyLE, verifyLE, verifyLE, verifyLT, verifyLT, verifyLT, verifyLT, waitFor, waitForBackgroundScriptToFinish, waitForBoolean, waitForDouble, waitForFloat, waitForInt, waitForList, waitForLong, waitForString, waitForSynchronizationPoint, warn, warn, warn, warn, whereAmI, writeMessage, writeMessage, writeMessage, writeMessage, writeSystemLog, writeSystemLog
-
-
-
-
Method Detail
-
getVU
public SeleniumVirtualUser getVU()
Description copied from class:VirtualUserScript
Gets the current VU instance, as the most specialised subclass ofVirtualUser
.If you have added methods to a custom Virtual User subclass, you can call them on the object returned from this method.
e.g.
MyCustomUser thisVU = getVU(); thisVU.MyCustomOperation();
- Overrides:
getVU
in classVirtualUserScript
- Returns:
- the current VU instance
-
getWebDriver
public WebDriver getWebDriver()
Description copied from interface:SeleniumVirtualUserInterface
Get theWebDriver
instance for thisSeleniumVirtualUser
.- Specified by:
getWebDriver
in interfaceSeleniumVirtualUserInterface
- Returns:
- The
WebDriver
instance for thisSeleniumVirtualUser
.
-
initialiseHtmlUnitDriver
public void initialiseHtmlUnitDriver() throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newHtmlUnitDriver
instance for thisSeleniumVirtualUser
.The
HtmlUnitDriver
will be set to use the defaultBrowserVersion
. If you need to impersonate a differentBrowserVersion
then you can callSeleniumVirtualUserInterface.initialiseHtmlUnitDriver(BrowserVersion)
instead.Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialiseHtmlUnitDriver
in interfaceSeleniumVirtualUserInterface
- Throws:
java.lang.Exception
- An error occurred
-
initialiseHtmlUnitDriver
public void initialiseHtmlUnitDriver(com.gargoylesoftware.htmlunit.BrowserVersion browserVersion) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newHtmlUnitDriver
instance for thisSeleniumVirtualUser
, impersonating theBrowserVersion
specified.Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialiseHtmlUnitDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
browserVersion
- TheBrowserVersion
to impersonate.- Throws:
java.lang.Exception
- An error occurred
-
initialiseFirefoxDriver
public void initialiseFirefoxDriver() throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newFirefoxDriver
instance for thisSeleniumVirtualUser
.Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialiseFirefoxDriver
in interfaceSeleniumVirtualUserInterface
- Throws:
java.lang.Exception
- An error occurred
-
initialiseInternetExplorerDriver
public void initialiseInternetExplorerDriver(java.lang.String pathToIEDriverServer) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newInternetExplorerDriver
instance for thisSeleniumVirtualUser
.In order to use the
InternetExplorerDriver
, you need to install the IE driver server (IEDriverServer.exe) on each injector in your test. You must then pass the full path of the driver server to this method, e.g:
For more information on setting up the IE driver server, please refer to the documentation on the selenium website.initialiseInternetExplorerDriver("C:/tools/SeleniumDrivers/IEDriverServer.exe");
Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialiseInternetExplorerDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
pathToIEDriverServer
- The full path to the IE driver server on the injector.- Throws:
java.lang.Exception
- An error occurred
-
initialiseChromeDriver
public void initialiseChromeDriver(java.lang.String pathToChromeDriver) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newChromeDriver
instance for thisSeleniumVirtualUser
.In order to use the
ChromeDriver
, you need to install the chrome driver server (chromedriver.exe) on each injector in your test. You must then pass the full path of the driver server to this method, e.g:
For more information on setting up the chrome driver server, please refer to the documentation on the selenium website.initialiseChromeDriver("C:/tools/SeleniumDrivers/chromedriver.exe");
Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialiseChromeDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
pathToChromeDriver
- The full path to the chrome driver server on the injector.- Throws:
java.lang.Exception
- An error occurred
-
initialisePhantomJSDriver
public void initialisePhantomJSDriver(java.lang.String pathToPhantomJSExe) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newPhantomJSDriver
instance for thisSeleniumVirtualUser
.In order to use the
PhantomJSDriver
, you need to install the PhantomJS on each injector in your test. You must then pass the full path ofphantomjs.exe
to this method, e.g:
For more information on PhantomJS, please refer to the PhantomJS website.initialisePhantomJSDriver("C:/tools/phantomjs-1.9.7-windows/phantomjs.exe");
Typically, this method is called from the
VirtualUser.pre()
method.- Specified by:
initialisePhantomJSDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
pathToPhantomJSExe
- The full path ofphantomjs.exe
- Throws:
java.lang.Exception
- An error occurred
-
getJavascriptExecutor
public JavascriptExecutor getJavascriptExecutor()
Description copied from interface:SeleniumVirtualUserInterface
Get aJavascriptExecutor
for thisSeleniumVirtualUser
- Specified by:
getJavascriptExecutor
in interfaceSeleniumVirtualUserInterface
- Returns:
- A
JavascriptExecutor
for thisSeleniumVirtualUser
-
initialiseWebDriver
public void initialiseWebDriver(WebDriverType driverType) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newWebDriver
instance for thisSeleniumVirtualUser
.This method provides a way to alter the type of
WebDriver
for this Virtual User. Valid driver types are as follows:- HtmlUnit
- FireFox
- Chrome
- InternetExplorer
- PhantomJS
e.g.
// Create a new FirefoxDriver for this Virtual User initialiseWebDriver(WebDriverType.FireFox);
- Specified by:
initialiseWebDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
driverType
- The web driver type to create- Throws:
java.lang.Exception
- An error occurred
-
initialiseWebDriver
public void initialiseWebDriver(WebDriver driver) throws java.lang.Exception
Description copied from interface:SeleniumVirtualUserInterface
Create a newWebDriver
instance for thisSeleniumVirtualUser
.This method provides a way to alter the type of
WebDriver
for this Virtual User.- Specified by:
initialiseWebDriver
in interfaceSeleniumVirtualUserInterface
- Parameters:
driver
- The type ofWebDriver
to be used by this Virtual User- Throws:
java.lang.Exception
- An error occurred
-
getUnderlyingWebDriver
public WebDriver getUnderlyingWebDriver()
Description copied from interface:SeleniumVirtualUserInterface
Get the underlyingWebDriver
instance for thisSeleniumVirtualUser
.This is useful if you need to call a method that is specific to the
WebDriver
type that you are using. For example, if you are using theHtmlUnitDriver
, you could use this method to call thesetJavascriptEnabled
method:HtmlUnitDriver htmlUnitDriver = (HtmlUnitDriver)getUnderlyingWebDriver(); htmlUnitDriver.setJavascriptEnabled(false);
- Specified by:
getUnderlyingWebDriver
in interfaceSeleniumVirtualUserInterface
- Returns:
- The underlying
WebDriver
instance for thisSeleniumVirtualUser
.
-
-