See the following sections for more information:
Here's an example of how you might set a job's name to "My test":
|Sets the pass/fail status of the job. Options are |
"sauce:job-name=My awesome job"
|Sets the job name|
|Sets the job tags in a comma-separated list.|
|Sets the job’s build name.|
"sauce: stop network"
"sauce: start network"
Stops and restart the VM’s network connection (Mac OSX only).
|Sets a Sauce breakpoint in the test. Test execution will pause at this point, waiting for manual control by clicking in the test’s live video.|
|Logs the given line in the job’s Selenium commands list.|
|Sets one or more job information fields to the values sent in the JSON-formatted dictionary.|
Spaces are Sensitive
Note the space required in
job-info, not used in the other methods.
Setting the pass/fail status of your tests is important for getting the most out of your analytics, as Selenium has only three built-in states: In Progress, Error, and Complete.
This code is from a sample Java test script using TestNG. You can find the full version in our Test Frameworks repository.
Providing Context for Selenium Commands
One of the most difficult aspects of troubleshooting Selenium tests can be matching commands to browser actions. The
sauce:context method provides you with a way to inject text into the command log to associate with a specific command, essentially adding a comment.
For example, in the command log on the left, it's hard to immediately see which command is responsible for following a link to the page, which one submitted a comment, and which one asserted that the comment was valid. In the screenshot on the right, each set of commands has been provided with a context.
TestBase.java script, assign a context with each step of the test is set using the
The following code examples are from the Java-TestNG-Selenium framework in our GitHub repository.
In your test script, specify the text you want associated with each step of the test: