Helium Automated Browser Testing
Helium is a tool that makes it easy to test websites and automate browsers.
It's designed to be very simple to use and integrate.
Helium can be used as a Java or Python library and integrates with the Selenium Framework.
Setting up Helium
There's a very good tutorial on how to set up Helium on the Helium Repository page.
Install Helium (it pulls in Selenium as a dependency):
pip install helium selenium
Once you've got everything set up, it's easy to run your first test with Helium on TestingBot:
Running your first test
Below is an example on how to run a simple test on Firefox. When the test has finished, the test name and success state is sent to TestingBot so you can see the test success/failures in our dashboard.
To send the test success state back to us, please install our Python plugin:
pip install testingbotclient
Python Example:
import unittest
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from helium import *
from testingbotclient import TestingBotClient
class HeliumOnTestingBot(unittest.TestCase):
def setUp(self):
options = Options()
options.browser_version = 'latest'
options.platform_name = 'WIN11'
options.set_capability('tb:options', {
'key': 'API_KEY',
'secret': 'API_SECRET',
'name': 'My First Test'
})
self.driver = webdriver.Remote(
command_executor='https://hub.testingbot.com/wd/hub',
options=options
)
set_driver(self.driver)
def test_tb(self):
go_to('https://testingbot.com')
click('Log in')
write('my@email.com', into='Email')
write('myPassword', into='Password')
click(Button('Sign in'))
def tearDown(self):
if hasattr(self._outcome, 'errors'):
# Python <= 3.10
result = self.defaultTestResult()
self._feedErrorsToResult(result, self._outcome.errors)
status = not (result.errors or result.failures)
else:
# Python 3.11+
result = self._outcome.result
status = all(test is not self for test, _ in result.errors + result.failures)
session_id = self.driver.session_id
self.driver.quit()
tb_client = TestingBotClient('API_KEY', 'API_SECRET')
tb_client.tests.update_test(session_id, name=self._testMethodName, passed=status)
if __name__ == '__main__':
unittest.main()
Java Example:
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static com.heliumhq.API.*;
public class WebDriverTest {
private WebDriver driver;
@Before
public void setUp() throws Exception {
FirefoxOptions options = new FirefoxOptions();
options.setPlatformName("WIN11");
options.setBrowserVersion("latest");
HashMap<String, Object> tbOptions = new HashMap<>();
tbOptions.put("key", "API_KEY");
tbOptions.put("secret", "API_SECRET");
tbOptions.put("name", "My First Test");
options.setCapability("tb:options", tbOptions);
this.driver = new RemoteWebDriver(
new URL("https://hub.testingbot.com/wd/hub"),
options);
setDriver(this.driver);
}
@Test
public void testWithTestingBot() throws Exception {
goTo("https://testingbot.com");
click("Log in");
assertEquals("Online Selenium Testing - Log in to manage your unit tests.", getDriver().getTitle());
write("user12345", into("Email:"));
write("user12345", into("Password:"));
click(Button("Sign in"));
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
Specify Browsers & Devices
To let TestingBot know on which browser/platform you want to run your test on, you need to specify the browsername, version, OS and other optional options in the capabilities field.
Beforedriver = webdriver.Firefox()
from selenium.webdriver.firefox.options import Options
options = Options()
# set capabilities from picker below
driver = webdriver.Remote(
command_executor='https://hub.testingbot.com/wd/hub',
options=options)
More Information
More information regarding Helium is available on the Helium Repository.
Other Python Framework examples
-
PyTest
PyTest makes it easy to run Selenium tests with Python.
-
Behave
Behave is behaviour-driven development, Python style.
-
Lettuce
Lettuce is a Python BDD plugin based on Ruby's Cucumber, offering Gherkin stories.
-
PyUnit
PyUnit is the standard unit testing framework module for Python, described as a Python version of JUnit.
-
Helium
Helium is a tool that makes it easy to test websites and automate browsers.
-
Pylenium
Pylenium is a Python package, its mission: "Bring the best of Selenium, Cypress and Python into one package."
-
SeleniumBase
SeleniumBase is a Python package that simplifies Selenium testing.