Open topic with navigation
Selenium is an open-source tool for automating browser-based applications. Selenium scripts test your website by simulating user behavior – they navigate through web pages, click links, submit forms, and verify that the expected text or elements are present on the pages.
AlertSite Enterprise lets you use Selenium scripts to ensure your critical business transactions are working correctly. You can upload Selenium scripts and run them from AlertSite’s global monitoring locations, measuring the transaction response time. Selenium scripts run in real browsers – Chrome and Firefox – so they accurately model real user experience.
Browsers: Chrome (recommended), Firefox*. (The browser to use is specified in the Selenium script.)
* Firefox support is in beta and there are some known issues.
Selenium 1.0 (RC) and Selenium Grid are not supported.
Private locations support Selenium monitors starting from Private Node Server v. 2.0.
Note: Selenium monitors are full-page monitors and consume credits at the Full Page rate.
It is easy to reuse your Selenium scripts written in Java to create AlertSite monitors. All you need to do is to add two small code snippets into your working Java code, then export your project as a runnable JAR file.
Check out the step-by-step tutorials:
As a result, you will get a JAR file that can be run using this command:
java -jar filename.jar
Before you upload it to AlertSite, make sure it is played back successfully on your computer.
See also Guidelines for Selenium Scripts.
Once you have a runnable JAR file, you can upload it to AlertSite:
Select Web and click Upload and Monitor.
If you have multiple AlertSite plans, select the plan to be used for this monitor.
Note: For the VM Node plan (monitoring from private locations only), make sure you use Private Node Server 2.0, because earlier versions do not support Selenium.
Name your monitor and select the run interval (default is 5 minutes).
On the next screen, you can run a test on demand to verify your JAR file. This is only required if your Selenium monitor will run from AlertSite’s global locations. If you selected the VM Node plan for your monitor, skip this test.
Click Test on Demand. AlertSite will run your script from one of its locations.
If everything is OK, you should see that “Test completed successfully”.
If the test on demand fails with an error, you need to fix the errors in your Selenium script and upload a new JAR file. A successful test on demand is required before you can proceed.
When you are ready to continue, click No thanks, I'm done.
The next screen is the monitor configuration, where you can select locations for the monitor, configure timeouts and other parameters.
Note: By default, new Selenium monitors are disabled. You need to enable the monitor manually by setting Monitoring to On.
Some useful configuration options are:
For more information about these and other settings, see Selenium Monitor Settings.
Your Selenium monitor will now run at the configured intervals. The data should appear on AlertSite dashboards in about 5-10 minutes.
AlertSite locations have the Firefox and Chrome browsers installed. Each Selenium script begins the run with a clear browser cache. The script launches and closes a browser, navigates to web pages and simulates user actions on the pages. As the script runs, AlertSite tracks which pages are opened and measures the response time for each web page. Individual pages are reported as monitor steps.
The monitor status in AlertSite is determined by the exit code of the JAR file rather than the status of individual web pages. The JAR file must return status 0 if all tests were successful and a status > 0 on error, as shown here. This means that if an error occurred during the script (for example, a page could not be loaded), but the script returned exit code 0, the monitor status will be OK.
Page errors (like HTTP errors or loading timeouts) are indicated in the monitor run details and in reports, but do not affect the monitor status and your SLA metrics.
AlertSite does not specifically track the status of JUnit test cases (@Test methods) in your JAR file, but you may be able to see this information in the run log.
In addition to the overall OK/error status, Selenium monitoring results include:
Clicking next to individual pages in test run results opens the Run View with waterfall charts and content breakdown. Here you can see the slowest and largest objects that affect your web page response time.
AlertSite can save the console output from Selenium monitors to help with troubleshoot monitor status 20 “Selenium-specific error”. The monitor needs to have the Capture Level option set to enable this. The console output will be available as the Run Log in the monitor run results.
The run log includes:
System.out.println()in your Selenium Java code. You can use this to annotate the script execution progress.
Output produced by the JUnit framework (if you created your Selenium script using JUnit). This typically includes error details such as the name of the failed test method, the error message and the exact line number in the Selenium script where the error occurred.
Note: To include JUnit output in the AlertSite run log, your
main() method must contain this line:
Here is a sample run log that shows the error details:
You can also have this log attached to email alerts. To do this, select the Attach server response to email alerts option for your email alert recipients.
The following features are not supported for Selenium monitors:
Support for Selenium Firefox monitors is currently in beta. The following issues are known to exist:
Selenium Run Log may include the following warnings at the beginning:
[AppClassLoader@18b4aac2] warning Cannot access resource for -Xlintfile:META-INF/Xlint.properties
[URLClassLoader@180bc464] warning Cannot access resource for -Xlintfile:META-INF/Xlint.properties
You can ignore these warnings. They do not affect the functionality of your Selenium scripts.