Class WebBrowserVirtualUser
- java.lang.Object
-
- com.facilita.fc.runtime.VirtualUser
-
- com.facilita.fc.web.WebBrowserVirtualUser
-
- All Implemented Interfaces:
com.facilita.fc.runtime.Commands
,DataDictionary
,com.facilita.fc.runtime.IMonitoredVU
,java.lang.Runnable
public class WebBrowserVirtualUser extends VirtualUser
Represents a Web Java Virtual User. When a test containing Web Java Virtual Users is run, aWebBrowserVirtualUser
object is created by the eggPlant Performance engine for every Virtual User in the test. TheseWebBrowserVirtualUser
objects runs scripts/workflows by creating instances of your script classes (which are subclasses ofWebBrowserScript
) and calling thescript()
method on them.Each instance of
WebBrowserVirtualUser
has a separateWebBrowser
object that can be used to send HTTP requests to a web server. This has two implications:- Each Virtual User has a different cache and
WebBrowser
settings - If a Virtual User is running a workflow containing multiple scripts, then changes to
the Virtual User's
WebBrowser
object in one script will affect the other scripts too
The
WebBrowser
object can be accessed from within yourscript()
method using theWebBrowserScript.getWebBrowser()
method.When developing Web scripts, it is recommended to customise the Web Java Virtual User type, by performing the following actions in eggPlant Performance Studio:
- Under Workspace/Virtual Users, right-click Web Java Virtual User, and then click New VU Type
- Type a name (which will be used as the class name) and a description
- Expand the newly-created custom Virtual User type, and the Source folder
- Edit the VU source file (the class which extends
WebBrowserVirtualUser
) by adding methods that can be called from any script which is based on your custom Virtual User, and/or overriding the methods inWebBrowserVirtualUser
.
WebBrowserScript
and will be the base class of any script files you create with the custom Virtual User type.- See Also:
WebBrowserScript
-
-
Constructor Summary
Constructors Constructor Description WebBrowserVirtualUser()
For internal use only.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
atStartOfIteration()
This method is called at the start of every iteration.void
attachLogMessageSender(com.facilita.fc.runtime.IMessageSender messageSender)
For internal use only.Protocol
getProtocol(java.lang.String key, java.lang.String defaultValue)
Gets aProtocol
by looking up aString
in this Virtual User's data dictionary.<T> T
getSoapService(java.lang.Class<T> soapServiceInterface, Url url, com.testplant.soap.SoapVersion soapVersion)
WebBrowser
getWebBrowser()
Gets theWebBrowser
belonging to this Virtual User.void
onStartFinalSection()
This method is called whenever the Virtual User is about to start executing the final sequence of scripts in its workflow.void
onStartInitialSection()
This method is called whenever the Virtual User is about to start executing the initial sequence of scripts in its workflow.protected void
onStartTransaction(java.lang.String id, java.lang.String tag)
This method is called whenever a transaction is started using theVirtualUser.startTransaction(String)
orVirtualUser.startTransaction(String, String)
methods.protected void
post()
This method is called after all scripts have finished executing.protected void
pre()
This method is called before any scripts are executed.void
prepareRequest(Request request)
This method is called immediately before aRequest
object is sent to the web server.void
processResponse(Response response)
This method is called immediately after aResponse
is returned from the web server.-
Methods inherited from class com.facilita.fc.runtime.VirtualUser
add, atEndOfIteration, clearProgressPoint, createBackgroundScript, createMonitorSnapshot, endRequest, endRequest, endRequest, endTiming, endTiming, endTiming, endTransaction, endTransaction, endTransaction, endTransaction, error, error, error, error, error, executeCommand, executeCommand, exitVU, exitVU, exitVU, fail, failAction, failTiming, failTiming, failTransaction, failTransaction, failTransaction, finalSequence, finishIterating, finishIteratingRequested, flushEventLog, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, formatDateTime, get, get, getBackgroundScriptIDs, getBackgroundScriptStatus, getBoolean, getBoolean, getContextState, getCurrentIteration, getCurrentScript, getCurrentTimeInXml, getCurrentTransaction, getDataDictionary, getDataDictionary, getDataPath, getDataTable, getDouble, getDouble, getElapsedTime, getFilesDataPath, getFloat, getFloat, getGroupSize, getGroupSize, getGroupSizes, getIndex, getIndexForEngineGroup, getInitialDelay, getInjectorFamilyName, getInjectorName, getInt, getInt, getInteger, getInteger, getIteration, getIterationDelay, getIterationForTime, getJmeterTestPlanName, getLastError, getLastTransaction, getList, getList, getLong, getLong, getMap, getMaxFailures, getMillisecondsSinceEpoch, getMillisecondsSinceEpoch, getName, getNumberOfErrors, getNumberOfFailures, getNumberOfIterations, getNumberOfWarmupIterations, getNumberOfWarnings, getPauseFactor, getProgressPoint, getRunPath, getSandboxPath, getSecondsSinceEpoch, getSecondsSinceEpoch, getService, getServices, getStartTime, getStartTimeSeconds, getString, getString, getTimingElapsedTime, getTimingElapsedTime, getTransactionData, getTransactionElapsedTime, getTransactionElapsedTime, getTransactionElapsedTime, getTransactionLoggingOn, getUniqueID, getUniqueID, getVUName, hasKey, isDebugMode, isFinalScript, isFirstScript, isInitialScript, isIteratedScript, isLastIteration, isPacing, isReadOnly, keys, lastIterationDelay, logCurrentDataValues, nextIteration, nextScript, nextSequence, nowSeconds, onDataDictionaryChanged, onEndTiming, onEndTransaction, onError, onException, onExitVU, onRaiseAlert, onResumeTransaction, onSetProgressPoint, onStartTiming, onSuspendTransaction, onWarn, onWriteMessage, openEventLog, pause, pause, pause, pause, raiseAlert, recordMetric, recordMetric, recordMetrics, recordMetrics, recordTransaction, recordTransaction, recordTransaction, recordTransaction, recordTransaction, recordTransaction, requestToStopBackgroundScript, resumeBackgroundScript, resumeTransaction, resumeTransaction, resumeTransaction, run, runAsBackgroundThread, selectRandomEntryFromList, set, setBoolean, setDebugMode, setDouble, setFloat, setInt, setInteger, setList, setLong, setName, setNumberOfWarmupIterations, setPauseFactor, setProgressPoint, setProgressPoint, setProgressPoint, setProgressPoint, setString, setSynchronizationPoint, setTransactionLoggingOn, setup, startBackgroundScript, startCustomVUWatcher, startRequest, startRequest, startTiming, startTransaction, startTransaction, startTransaction, stopBackgroundScriptImmediately, stopCustomVUWatcher, suspendBackgroundScript, suspendTransaction, suspendTransaction, suspendTransaction, timeToPause, toString, 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, writeMessage, writeMessage, writeMessage, writeMessage, writeSystemLog, writeSystemLog
-
-
-
-
Method Detail
-
getWebBrowser
public WebBrowser getWebBrowser()
Gets theWebBrowser
belonging to this Virtual User.- Returns:
- the
WebBrowser
belonging to this Virtual User
-
pre
protected void pre() throws java.lang.Exception
Description copied from class:VirtualUser
This method is called before any scripts are executed.Override this method in your custom Virtual User if you have code which should be run only once, before any scripts are executed.
This method initialises logging systems. If you override this method in a custom Virtual User, then a call to
super.pre()
must be made and must occur before any code that may cause an exception or write to a log.- Overrides:
pre
in classVirtualUser
- Throws:
java.lang.Exception
- An error occurred
-
post
protected void post() throws java.lang.Exception
Description copied from class:VirtualUser
This method is called after all scripts have finished executing.Override this method in your custom Virtual User if you have code which should be run only once, after all scripts have finished executing.
This method shuts down logging systems. If you override this method in a custom Virtual User, then a call to
super.post()
must be made at the end of the method. All exceptions thrown during the execution of this method must be caught and handled.- Overrides:
post
in classVirtualUser
- Throws:
java.lang.Exception
- An error occurred
-
onStartTransaction
protected void onStartTransaction(java.lang.String id, java.lang.String tag) throws java.lang.Exception
Description copied from class:VirtualUser
This method is called whenever a transaction is started using theVirtualUser.startTransaction(String)
orVirtualUser.startTransaction(String, String)
methods.Override this method in your custom Virtual User if you have code which should be run whenever a transaction is started.
- Overrides:
onStartTransaction
in classVirtualUser
- Parameters:
id
- the transaction identifiertag
- extra information which appears in the Info column- Throws:
java.lang.Exception
- An error occurred
-
atStartOfIteration
protected void atStartOfIteration()
Description copied from class:VirtualUser
This method is called at the start of every iteration.Override this method in your custom Virtual User if you have code which should be run at the start of every iteration.
The current iteration number can be obtained using
VirtualUser.getCurrentIteration()
.- Overrides:
atStartOfIteration
in classVirtualUser
-
onStartInitialSection
public void onStartInitialSection()
Description copied from class:VirtualUser
This method is called whenever the Virtual User is about to start executing the initial sequence of scripts in its workflow.Override this method in your custom Virtual User if you have code which should be run whenever the Virtual User starts executing the initial sequence of scripts.
- Overrides:
onStartInitialSection
in classVirtualUser
-
onStartFinalSection
public void onStartFinalSection()
Description copied from class:VirtualUser
This method is called whenever the Virtual User is about to start executing the final sequence of scripts in its workflow.Override this method in your custom Virtual User if you have code which should be run whenever the Virtual User starts executing the final sequence of scripts.
- Overrides:
onStartFinalSection
in classVirtualUser
-
attachLogMessageSender
public void attachLogMessageSender(com.facilita.fc.runtime.IMessageSender messageSender)
For internal use only.- Overrides:
attachLogMessageSender
in classVirtualUser
- Parameters:
messageSender
- the message sender
-
prepareRequest
public void prepareRequest(Request request)
This method is called immediately before aRequest
object is sent to the web server.If
Request.send()
orRequest.sendTopLevel()
is called within ascript()
method, this method will be called before the top-level request is sent to the web server. Therequest
parameter is a reference to theRequest
object on whichsend()
(orsendTopLevel()
) was called. It can be modified prior to sending.Override this method to modify every request (or a selection of requests based on criteria) before they are sent to the web server.
- Parameters:
request
- a request that is about to be sent to the web server- See Also:
processResponse(Response)
-
processResponse
public void processResponse(Response response) throws java.lang.Exception
This method is called immediately after aResponse
is returned from the web server.If
Request.send()
orRequest.sendTopLevel()
is called within ascript()
method, this method will be called before theResponse
object is returned. Theresponse
parameter is a reference to theResponse
object which is about to be returned by thesend()
(orsendTopLevel()
) method. It can be modified prior to returning.Override this method to modify every response (or a selection of responses based on criteria) after they are returned by the web server.
- Parameters:
response
- the response that has just arrived from the web server- Throws:
java.lang.Exception
- An error occurred when processing the response- See Also:
prepareRequest(Request)
-
getProtocol
public Protocol getProtocol(java.lang.String key, java.lang.String defaultValue) throws NoSuchValueException, NotAllowedException, BadValueException
Gets aProtocol
by looking up aString
in this Virtual User's data dictionary.e.g.
// Look in the data dictionary for the key "protocol1". If this key doesn't exist, then default to Protocol.HTTP Protocol protocol1 = getProtocol("protocol1", "http");
- Parameters:
key
- the key to look for in the data dictionarydefaultValue
- the default value to use if the specified key does not exist in this Virtual User's data dictionary- Returns:
- the
Protocol
, or aProtocol
relating to thedefaultValue
parameter - Throws:
NoSuchValueException
- Invalid protocol nameNotAllowedException
- The key could not be found in the data dictionaryBadValueException
- The key could not be found in the data dictionary
-
getSoapService
public <T> T getSoapService(java.lang.Class<T> soapServiceInterface, Url url, com.testplant.soap.SoapVersion soapVersion) throws NoSuchValueException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
- Throws:
NoSuchValueException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
-
-