Skip to main content

Runners

Types of runners

There are two types of runners:

ClassicRunner

ClassicRunner is used when the screenshot is taken by the SDK itself.

ClassicRunner classicRunner = new ClassicRunner();

VisualGridRunner

VisualGridRunner is used when the screenshot is taken by the Ultrafast grid.

VisualGridRunner visualGridRunner = new VisualGridRunner(new RunnerOptions().TestConcurrency(5));
  • ConcurrentSessions represents the number of visual tests that are allowed to run at the same time. Default: 1.

Purpose of runners

There are two purposes for using runners:

Use the Ultrafast grid

This is done simply by specifying the VisualGridRunner. Browsers are specified by using the Configuration API. For example:

Eyes eyes = new Eyes(new VisualGridRunner());
Configuration configuration = eyes.GetConfiguration();
configuration
.AddBrowser(1400, 700, BrowserType.CHROME)
.AddBrowser(1200, 900, BrowserType.FIREFOX)
.AddBrowser(1200, 900, BrowserType.SAFARI)
.AddBrowser(1200, 900, BrowserType.EDGE_CHROMIUM)
.AddBrowser(1200, 900, BrowserType.IE_11)
;
eyes.SetConfiguration(configuration);
}

Manage tests across multiple Eyes instances

If you decide to create more than one instance of Eyes in your tests (for example, if you run new Eyes() in BeforeEach test hooks), the runner provides a method called GetAllTestResults for collecting test results across all eyes instances.

Example

[Test]
public async Task TestWithGetAllTestResults()
{
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchAsync();
var context = await browser.NewContextAsync();

IPage page = await context.NewPageAsync();
await page.GotoAsync("https://applitools.com");

VisualGridRunner runner = new VisualGridRunner(10);
Eyes eyes = new Eyes(runner);
eyes.Open(page, "applitools.com website", "My first Playwright test!");
eyes.Check("home page", Target.Window().Fully());
eyes.CloseAsync();

TestResultsSummary testResultSummary = runner.GetAllTestResults();
foreach (TestResultContainer testResultContainer in testResultSummary.GetAllResults())
{
TestResults testResults = testResultContainer.TestResults;
TestContext.WriteLine(FormatTestResults(testResults));
}
}

This code example runs two visual tests in parallel on two websites, using a specific configuration for each URL.

To achieve this, multiple Eyes instances are used, but in order to wait for all test results, the code calls testResultContainer.GetTestResults. It then iterates through the results and prints out a formatted summary.