Selenium 4

Selenium 4, which will launch soon, will start using a new Selenium Protocol, called the W3C WebDriver Protocol.


These changes are aimed to offer a standard protocol which all browser vendors can implement, leading to a more stable Selenium ecosystem.

Updating your tests

With this new protocol, some restrictions apply to using capabilities to start a new test.
Before Selenium 4, you could add all our custom TestingBot capabilities to your test without any problem.


With Selenium 4, only browserName, browserVersion and platformName are allowed.


Please see the table below on how the capabilities need to be changed:


Capability < Selenium 4 Capability >= Selenium 4
browserName browserName
version browserVersion
platform platformName
selenium-version, chromedriverVersion,
extra, name and more
"tb:options" : {
  "selenium-version": '...',
  "chromedriverVersion": '...',
  "extra": '...',
  "name": '...'
}

Example

Before

import unittest
import sys

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestTestingBotClient(unittest.TestCase):
    def setUp(self):
      desired_cap = {
        'platform': 'Windows', 
        'browserName': 'firefox', 
        'version': 'latest-1',
        'selenium-version': '2.53.1',
        'screenrecorder': 'false'
      }

    self.driver = webdriver.Remote(
        command_executor='http://key:[email protected]/wd/hub',
        desired_capabilities=desired_cap)

    def test_google_example(self):
      self.driver.get("http://www.google.com")
      if not "Google" in self.driver.title:
          raise Exception("Unable to load google page!")
      elem = self.driver.find_element_by_name("q")
      elem.send_keys("TestingBot")
      elem.submit()

    def tearDown(self):
      self.driver.quit()

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

After

import unittest
import sys

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestTestingBotClient(unittest.TestCase):
    def setUp(self):
      desired_cap = {
        'platformName': 'Windows', 
        'browserName': 'firefox', 
        'browserVersion': 'latest-1',
        'tb:options': {
          'selenium-version': '2.53.1',
          'screenrecorder': 'false'
        }
      }

    self.driver = webdriver.Remote(
        command_executor='http://key:[email protected]/wd/hub',
        desired_capabilities=desired_cap)

    def test_google_example(self):
      self.driver.get("http://www.google.com")
      if not "Google" in self.driver.title:
          raise Exception("Unable to load google page!")
      elem = self.driver.find_element_by_name("q")
      elem.send_keys("TestingBot")
      elem.submit()

    def tearDown(self):
      self.driver.quit()

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