Selenium

Selenium is an open-source framework for automating web applications. It enables you to automate browser actions, validate web page content, and conduct comprehensive testing of web applications to ensure their functionality and reliability.

1. Create a Selenium Script

To run automated tests with BitBar, create a Selenium test on your own computer using the Selenium documentation's WebDriver section as a guide.

Tip

When configuring your automated test runs in BitBar, you can generate sample scripts below. If you decide to use your test, not the sample one, then before running your test in BitBar, check that it functions correctly on your local machine.

2. Create an Automated Test in BitBar

  1. After logging into your BitBar account, click Automation on the left-hand menu, then select Create Automated Test. Alternatively, click the Create Automated Test button on the Automated Testing tile.

    Start creating an automated desktop test
  2. Click Desktop and select the Selenium Client Side test framework.

    Select Selenium test framework
  3. Configure your test run:

    1. Name your test project and test run.

    2. Select the nearest Hub Location for better performance.

    3. Update your test script with the Hub URL.

    4. Configure the operating system, browser, and screen resolution for your test run (these are known as capabilities).

    5. BitBar will generate script code in commonly used languages and provide a preview. Select the Show full sample script checkbox to utilize the script code generated by BitBar.

    6. Copy the code by clicking and then paste it into your Selenium script on your computer.

      Selenium-copy-to-clipboard.png

3. Capabilities Creator

To configure your test, select Capabilities Creator from the left-hand side menu.

  1. Click Desktop (Selenium).

  2. Enter the name of your project and test run.

  3. Select the Hub Location that is closest to you to improve performance.

  4. Update your test script with the Hub URL.

  5. Set the combination of the operating system, browser, and screen resolution for the test run (these and other settings are called capabilities).

  6. BitBar generates script code in popular languages and displays the code for preview.

    Tip

    If you are going to use a sample script generated by BitBar, select the Show full sample script check box.

4. Configure the Selenium Script

Important

It is essential that you insert your API key to the copied script code and that you modify the Selenium Grid address in your test.

Insert the API Key

  1. Get the API key from your BitBar account settings:

    1. Log in to BitBar, click the user icon and select My Account.

    2. Go to the My Integrations section, click API Access, and copy the API key value:

      Selenium-apiKey.png
  2. Set the API key as the value for the apiKey parameter:

    Table 2. API Key Configuration Samples

    Languages and Runtimes

    Sample

    Python

    capabilities = {
    	...
    	'bitbar:options': {
    		'apiKey': '<insert your BitBar API key here>',
    		...
    	}
    }
    

    Java

    MutableCapabilities capabilities = new MutableCapabilities();
    ...
    
    HashMap<String, String> bitbarOptions = new HashMap<String, String>();
    bitbarOptions.put("apiKey", "<insert your BitBar API key here>");
    ...

    C#

    DriverOptions capabilities = new DriverOptions();
    ...
    
    IDictionary<string, string> bitbarOptions = new Dictionary<string, string>();
    bitbarOptions.Add("apiKey", "<insert your BitBar API key here>");
    ...

    Ruby

    capabilities = Selenium::WebDriver::Remote::Capabilities.new({
    	...
    	'bitbar:options' => {
    		'apiKey' => '<insert your BitBar API key here>'
    		...
    	}
    })

    Node.js

    var capabilities = {
    	...
    	'bitbar:options': {
    		'apiKey': '<insert your BitBar API key here>',
    		...
    	}
    };


Set the Selenium Grid address

You need to modify the Selenium Grid address in your test's capabilities. The value to use depends on the target location where the tested browser will run:

  • EU: DESKTOP – https://eu-desktop-hub.bitbar.com/wd/hub

  • US: DESKTOP – https://us-west-desktop-hub.bitbar.com/wd/hub

Now, you are ready to run your test.

5. Run Your Test and View Results

Run your test as you would normally do this. The results will go to BitBar. You can view them on the Projects screen under the project and test run node, whose name you specified in capabilities.

See Also

Publication date: