Zalenium

Applies to CrossBrowserTesting SaaS, last modified on January 10, 2023

For this document, we provide example test located in our Zalenium GitHub Repository.

Zalenium's main goal is to allow anyone to have a disposable and flexible Selenium Grid infrastructure. A Selenium Grid that scales up and down dynamically with this solution based on docker-selenium to run your tests is started in seconds. When you need a different browser, Zalenium is easily integrated with the CrossBrowserTesting platform, so you can perform tests on a wide variety of OS/Device/Browser combinations, all from one test.

Let's walk through getting setup

  1. Start by installing docker, a standalone container image that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

  2. Use docker to pull selenium and zalenium using the commands:

    docker pull elgalu/selenium
    docker pull dosel/zalenium
  3. Start Zalenium with the command:

    export CBT_USERNAME="YOUR_USERNAME"
    export CBT_AUTHKEY="YOUR_AUTHKEY"
    export CBT_URL= "http://YOUR_USERNAME:[email protected]:80"
    docker run --rm -ti --name zalenium -p 4444:4444 \
    -e CBT_USERNAME -e CBT_AUTHKEY -e CBT_URL \
    -v /tmp/videos:/home/seluser/videos \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --privileged dosel/zalenium start --cbtEnabled true

  4. Navigate to http://localhost:4444/grid/dashboard to view your Zalenium Dashboard

  5. Create an empty file called /zalenium/test/selenium_test.py with the following content:

    Python

    import unittest
    from selenium import webdriver
    import requests, time
    import os

    class SeleniumCBT(unittest.TestCase):
    def setUp(self):
    caps = {}
    caps['name'] = 'Zalenium Test'
    caps['browserName'] = 'Chrome'
    caps['version'] = '72'
    caps['platform'] = 'Windows 10'
    caps['screenResolution'] = '1366x768'
    caps['record_video'] = 'true'

    try:
    self.driver = webdriver.Remote(
    desired_capabilities = caps,
    command_executor = "http://localhost:4444/wd/hub")


    except Exception as e:
    raise e

    def test_CBT(self):
    self.driver.get("http://crossbrowsertesting.github.io/login-form.html")
    self.driver.find_element_by_xpath("//*[@id=\"username\"]").send_keys("[email protected]")
    self.driver.find_element_by_xpath("//*[@type=\"password\"]").send_keys("test123")
    self.driver.find_element_by_xpath("//*[@id=\"submit\"]").click()

    print("The title is ", self.driver.title)
    time.sleep(10)

    self.driver.quit()

    if __name__ == '__main__':
    unittest.main()

  6. Now you are ready to run your test using the command:

    python selenium_test.py
    Note: You will need to use your Username and Authkey to run your tests on CrossBrowserTesting To get yours, sign up for a free trial or purchase a plan.

Use the local connection

If you would like to test behind your firewall or access non-public sites, you can use our local connection tool through our Zalenium integration. Simply add the following parameter to your configuration:

--startTunnel true

Conclusion

As you can probably make out from our test, we visit a simple login page and display the title.

We kept it short and sweet for our purposes, but there is so much more you can do with Zalenium! Being built on top of Selenium means the sky is the limit as far as what you can do. If you have any questions or concerns, feel free to contact Support.

See Also

Test Frameworks and Tools

Highlight search results