Execute Tests in a Grid

Learn to use BELLATRIX to execute tests in a grid.

Example

@ExecutionBrowser(browser = Browser.CHROME, browserVersion = 89, platform = Platform.WINDOWS, lifecycle = Lifecycle.REUSE_IF_STARTED)
public class SeleniumGridTests extends WebTest {
    @Test
    public void promotionsPageOpened_When_PromotionsButtonClicked() {
        app().navigate().to("http://demos.bellatrix.solutions/");

        var promotionsLink = app().create().byLinkText(Anchor.class, "Promotions");

        promotionsLink.click();
    }
}

Explanations

@ExecutionBrowser(browser = Browser.CHROME, browserVersion = 89, platform = Platform.WINDOWS, lifecycle = Lifecycle.REUSE_IF_STARTED)

To use BELLATRIX tests with in a grid, you should use the ExecutionBrowser annotation to set the additional parameters for browser version and platform type. You can set other parameters for browser width and hight, lifecycle and etc. just like in every other test class.

Configuration

There’s an option about execution type in the testFrameworkSettings.<env>.json file under the webSettings section.

"webSettings": {
    "executionType": "grid"
}

You can set the grid URL and set some additional arguments under the gridSettings array, setting providerName to the match the name you set in executionType. To set additional arguments for providers such as SauceLabs, BrowserStack or CrossBrowserTesting, you can use the arguments array parameter.

"gridSettings": [
    {
        "providerName" : "grid",
        "url" : "http://127.0.0.1:4444/wd/hub",
        "arguments" : [
            {
                "name" : "bellatrix_run"
            }
        ]
    }
]

Playwright

Playwright supports only Chrome for Selenium Grid execution. Also, in the ExecutionBrowser, you cannot add PlatformType.