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, aWebBrowserVirtualUserobject is created by the eggPlant Performance engine for every Virtual User in the test. TheseWebBrowserVirtualUserobjects runs scripts/workflows by creating instances of your script classes (which are subclasses ofWebBrowserScript) and calling thescript()method on them.Each instance of
WebBrowserVirtualUserhas a separateWebBrowserobject that can be used to send HTTP requests to a web server. This has two implications:- Each Virtual User has a different cache and
WebBrowsersettings - If a Virtual User is running a workflow containing multiple scripts, then changes to
the Virtual User's
WebBrowserobject in one script will affect the other scripts too
The
WebBrowserobject 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.
WebBrowserScriptand 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 voidatStartOfIteration()This method is called at the start of every iteration.voidattachLogMessageSender(com.facilita.fc.runtime.IMessageSender messageSender)For internal use only.ProtocolgetProtocol(java.lang.String key, java.lang.String defaultValue)Gets aProtocolby looking up aStringin this Virtual User's data dictionary.<T> TgetSoapService(java.lang.Class<T> soapServiceInterface, Url url, com.testplant.soap.SoapVersion soapVersion)WebBrowsergetWebBrowser()Gets theWebBrowserbelonging to this Virtual User.voidonStartFinalSection()This method is called whenever the Virtual User is about to start executing the final sequence of scripts in its workflow.voidonStartInitialSection()This method is called whenever the Virtual User is about to start executing the initial sequence of scripts in its workflow.protected voidonStartTransaction(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 voidpost()This method is called after all scripts have finished executing.protected voidpre()This method is called before any scripts are executed.voidprepareRequest(Request request)This method is called immediately before aRequestobject is sent to the web server.voidprocessResponse(Response response)This method is called immediately after aResponseis 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 theWebBrowserbelonging to this Virtual User.- Returns:
- the
WebBrowserbelonging to this Virtual User
-
pre
protected void pre() throws java.lang.ExceptionDescription copied from class:VirtualUserThis 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:
prein classVirtualUser- Throws:
java.lang.Exception- An error occurred
-
post
protected void post() throws java.lang.ExceptionDescription copied from class:VirtualUserThis 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:
postin classVirtualUser- Throws:
java.lang.Exception- An error occurred
-
onStartTransaction
protected void onStartTransaction(java.lang.String id, java.lang.String tag) throws java.lang.ExceptionDescription copied from class:VirtualUserThis 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:
onStartTransactionin 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:VirtualUserThis 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:
atStartOfIterationin classVirtualUser
-
onStartInitialSection
public void onStartInitialSection()
Description copied from class:VirtualUserThis 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:
onStartInitialSectionin classVirtualUser
-
onStartFinalSection
public void onStartFinalSection()
Description copied from class:VirtualUserThis 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:
onStartFinalSectionin classVirtualUser
-
attachLogMessageSender
public void attachLogMessageSender(com.facilita.fc.runtime.IMessageSender messageSender)
For internal use only.- Overrides:
attachLogMessageSenderin classVirtualUser- Parameters:
messageSender- the message sender
-
prepareRequest
public void prepareRequest(Request request)
This method is called immediately before aRequestobject 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. Therequestparameter is a reference to theRequestobject 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 aResponseis returned from the web server.If
Request.send()orRequest.sendTopLevel()is called within ascript()method, this method will be called before theResponseobject is returned. Theresponseparameter is a reference to theResponseobject 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 aProtocolby looking up aStringin 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 aProtocolrelating to thedefaultValueparameter - 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:
NoSuchValueExceptionjava.lang.NoSuchMethodExceptionjava.lang.SecurityExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.IllegalArgumentExceptionjava.lang.reflect.InvocationTargetException
-
-