Creating the Selenium script
There are several ways to develop your Selenium script:
- You can write it from scratch in Java, Python, Ruby etc. Please refer to this article for a list of file types that Blazemeter supports.
- You can use Selenium IDE for script creation. Selenium IDE is a Chrome or Firefox add-on which has a recording option for actions on the browser.
- Use our own Blazemeter Chrome Extension to record a scenario that results in a YAML file that can be uploaded onto BlazeMeter.
Blazemeter uses Taurus to run Selenium scripts so it needs to be wrapped into a Taurus configuration file (yml). When using the Chrome Extension this is already done automatically and you only need to fine tune your YAML to run with the proper concurrency, ramp-up, hold-for and/or iterations as explained in this article. Do not set the concurrency to more than 5 users per engine as Selenium scripts are typically not meant for performance testing as explained here.
More information about the Selenium executor in Taurus can be found in this article.
The Selenium web driver runs a physical browser on the load server machine, either Chrome or Firefox. The versions of these browsers are preset and may vary as new versions are published.
The drivers to integrate Selenium with the browsers are Chromedriver for Chrome and Geckodriver for Firefox. By default, Taurus will download ChromeDriver and GeckoDriver when running tests. When the versions of the web drivers are updated, it is reflected in the Taurus changelog
If your Selenium script requires a different version of Chromedriver or Geckodriver, add following section to your yml script:
e.g. to explicitly use chrome driver 2.44 the download-link is https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip
Be aware that the webdriver/geckdriver version you select needs to be compatible with the chrome browser/Firefox version in use. For Chrome, check this compatibility page. For Firefox check this compatibility page.
Current Chrome browser version in use: Google Chrome 70.0.3538.110
Current FireFox version in use: Mozilla Firefox 63.0.3
There are 2 options to start a Selenium test:
Option 1: Via Taurus CLI
To run the Selenium script in Blazemeter, initiate the prepared yml file from the command line in the following way: bzt youryamlfile.yml -cloud
Blazemeter test and report will be created automatically - for more information, read this article
Option 2: Via BlazeMeter UI
To run the selenium script in Blazemeter through the UI, start a new test via New Test Create. You can create the scenario using a selenium script or a YAML configuration file.
Option 1: Uploading a Selenium script:
1. Upload the script to BlazeMeter
2. configure your load configuration as described here: Load Configuration
3. Run the test
Option 2: Upload a YAML file
When uploading a YAML file, the scenario configuration and load configuration should be configured in the YAML, as you can't override any of these configuration from BlazeMeter.
The green arrow next to the file name defines your main running file - make sure it points to the correct file.
The Test type field automatically adapts according to the main running file you use, Selenium or YAML.
It is also possible to include your Selenium yml file in End User Experience Monitoring if you want to find out what the real user experience (UX) is while running a performance test.
Once everything is set, you can start the test by pressing the Run Test button:
If your Selenium script uses a specific runner (such as TestNG, JUnit, etc.), then it's important that the runner not be configured as the executor. Consider the following example, where the user intends to execute a Selenium TestNG script:
Will Result in Error
- executor: testng
The above test will fail, likely with a driver error such as the following:
IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
This occurs because if TestNG is specified as the executor, Taurus will not understand that the test is supposed to be a Selenium test.
Therefore when executing a Selenium test, ensure the executor is always set to "selenium" and any runner is designated as the "runner" in the YAML file, such as in the following example:
Will Run Successfully
- executor: selenium
This will ensure that the TestNG script will still be properly identified as a Selenium test.