|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface BrowserMob
The main control interface for BrowserMob scripts - All scripts must start here first. This object allows the
script author to create both Real Bruwser User (RBU) and Virtual User (VU) scripts. This object is available as the
variable browserMob from within the a JavaScript-enabled script. This object is effectively the "starting
point" for all other scripts, as it serves as the interface for interacting with web sites (via openBrowser() and openHttpClient() as well as the mechanism for controlling transactions and steps (via
beginTransaction() and beginStep(String)).
filePath(String)),
simulating "user think time" (pause(long)), and parameterizing tests with unique data (getUserNum()
and getTxCount()).
| Method Summary | |
|---|---|
TransactionStep |
beginStep(java.lang.String stepLabel)
Starts a BrowserMob step using the first step number in sequence (must be called from within a transaction). |
TransactionStep |
beginStep(java.lang.String stepLabel,
int stepNbr)
Starts a BrowserMob step using the specified step number in sequence (must be called from within a transaction). |
Transaction |
beginTransaction()
Starts a BrowserMob transaction. |
void |
closeBrowser()
Terminates the active Selenium browser session. |
void |
endStep()
Stops the current step. |
void |
endTransaction()
Ends the current transaction. |
java.lang.String |
filePath(java.lang.String name)
Returns the local path for the specified file name. |
java.lang.String[] |
findRegexMatches(java.lang.String content,
java.lang.String regex)
A simple way to find one or more regular expression matches against some content. |
TransactionStep |
getActiveStep()
Returns the currently active step, which is useful for advanced use cases where the step object is being manipulated directly. |
Transaction |
getActiveTransaction()
Returns the currently active transaction, which is useful for advanced use cases where the transaction object is being manipulated directly. |
CSVTable |
getCSV(java.lang.String name)
Creates and returns a table of data backed by a Comma Separated Value file. |
File |
getFile(java.lang.String name)
Returns a wrapped handle to an uploaded file. |
int |
getTxCount()
Returns the count of transactions that have been completed (regardless of success or failure) for this particular RBU/VU. |
int |
getUserNum()
Returns the unique number for each independent RBU or VU in a load test. |
boolean |
isValidation()
Indicates if the current execution environment is an actual real time script playback or if this is simply a script validation run that is used during script development. |
void |
log(java.lang.String log)
Logs some text to the log buffer. |
Selenium |
openBrowser()
Starts a Selenium browser session. |
WebDriver |
openBrowserWebDriver()
Starts a WebDriver browser session. |
HttpClient |
openHttpClient()
Starts a basic HTTP client that is capabable of GET and POST requests, allowing the script author to simulate real web browsers. |
void |
pause(long pauseTimeInMs)
Instructs the script to pause for a specified ammount of time. |
void |
pause(long pauseTimeInMs,
boolean includeInTimeActive)
Instructs the script to pause for a specified ammount of time. |
void |
quickStop()
Normally when a load test is paused or the load level drops to fewer concurrent users, BrowserMob allows the actively running scripts to finish executing and complete the current transaction. |
void |
setDownstreamKbps(long downstreamKbps)
Sets an artificial kilobits-per-second value for all data transfered to (downstream) the RBU or VU. |
void |
setLatency(long latency)
Sets an artificial latency simulation for sending one full MTU (~1500 bytes on the internet). |
void |
setSimulatedBps(int simulatedBps)
Deprecated. Use setDownstreamKbps(long), setUpstreamKbps(long) (long)}, and setLatency(long) (long)} instead |
void |
setUpstreamKbps(long upstreamKbps)
Sets an artificial kilobits-per-second value for all data transfered from (upstream) the RBU or VU. |
void |
stopExpected()
Tells BrowserMob that the script is expecting that it could be stopped at any time and that if that happens, it should not be considered an error. |
boolean |
waitFor(com.browsermob.agent.api.WaitForCallback callback,
long timeoutInMs)
Wait for the user specified function to return true. |
void |
waitForNetworkTrafficToStop(long quietPeriodInMs,
long timeoutInMs)
Waits until no HTTP traffic associated with the current test has taken place for at least quietPeriodInMs. |
| Method Detail |
|---|
Selenium openBrowser()
WebDriver openBrowserWebDriver()
HttpClient openHttpClient()
Transaction beginTransaction()
TransactionStep beginStep(java.lang.String stepLabel)
stepLabel - a description of the step, to be used for various reporting.
TransactionStep beginStep(java.lang.String stepLabel,
int stepNbr)
stepLabel - a description of the step, to be used for various reporting.stepNbr - the actual step sequence number within the step description label
void endStep()
void pause(long pauseTimeInMs)
throws java.lang.InterruptedException
pauseTimeInMs - the time to pause (in milliseconds).
java.lang.InterruptedException - if the script is paused, stopped, or aborted during execution
void pause(long pauseTimeInMs,
boolean includeInTimeActive)
throws java.lang.InterruptedException
pauseTimeInMs - the time to pause (in milliseconds).includeInTimeActive - the time to pause (in milliseconds).
java.lang.InterruptedException - if the script is paused, stopped, or aborted during executionvoid endTransaction()
Transaction getActiveTransaction()
TransactionStep getActiveStep()
void closeBrowser()
void setSimulatedBps(int simulatedBps)
setDownstreamKbps(long), setUpstreamKbps(long) (long)}, and setLatency(long) (long)} instead
simulatedBps - the bits-per-second to simulate.void setDownstreamKbps(long downstreamKbps)
downstreamKbps - the kilobits-per-second to simulate.void setUpstreamKbps(long upstreamKbps)
upstreamKbps - the kilobits-per-second to simulate.void setLatency(long latency)
latency - the latency in milliseconds.int getUserNum()
int getTxCount()
java.lang.String filePath(java.lang.String name)
name - the name of the file used by the script - usually a simple name like "foo.txt".
void log(java.lang.String log)
log - the text to log.boolean isValidation()
pause(long) function to a shorter time period
when validating the script.
void stopExpected()
quickStop().
void quickStop()
stopExpected().
CSVTable getCSV(java.lang.String name)
name - the name of the CSV file, which you will be asked to upload by BrowserMob upon saving your script.
File getFile(java.lang.String name)
HttpPostRequest#addFileUpload(String, File).
name - the filename, which you will be asked to upload by BrowserMob upon saving your script.
void waitForNetworkTrafficToStop(long quietPeriodInMs,
long timeoutInMs)
quietPeriodInMs - the period of time that we expect to not see any HTTP traffic.timeoutInMs - the total time the function should wait before giving up and throwing an error.
java.lang.String[] findRegexMatches(java.lang.String content,
java.lang.String regex)
var matches = browserMob.findRegexMatches(resp.getBody(), '<span class="foo">([^<]*)<span>');
content - the content to match against.regex - the regular expression to match, which should include one and only one regular expression group.
boolean waitFor(com.browsermob.agent.api.WaitForCallback callback,
long timeoutInMs)
browserMob.waitFor(function() {
// Determine if the waitFor condition is satisfied and return a boolean value
return isConditionSatisfied;
}, 3000);
callback - the javascript function, in the form of function() { ... }timeoutInMs - the total time the function should wait before giving up and returning false.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||