Selenium CSharp overview
This SDK allows you to work with Applitools Eyes using Selenium CSharp.
For information about installing and configuring this SDK, see Testing web apps in C# using Selenium WebDriver on the Applitools Tutorial site.
To get started with this SDK, you need to set the following:
- Applitools API key
- Eyes server URL - Required only if the Eyes server is not deployed on the Eyes public server.
Entering the Applitools API key
To authenticate via the Applitools server and run tests, you need to set the environment variable
APPLITOOLS_API_KEY to the API key provided from Applitools Eyes. For details how to retrieve your API key, see the Applitools documentation.
Entering the API Key on Linux or a Mac
Entering the API Key on Windows
Eyes server URL
If the Eyes server is not deployed in
https://eyes.applitools.com, you need to set the Server URL in the environment variable
APPLITOOLS_SERVER_URL before running tests.
The server URL of your Applitools Eyes dashboard is in the format
Entering the server URL on Linux or a Mac
Entering the server URL on Windows
Recommended practice for using the SDK
A test in Applitools Eyes always starts with a
eyes.open call and ends with
eyes.close. The steps in the test are calls to
A test is structured as following:
This SDK uses the following Runner classes:
- ClassicRunner - Used when running multiple Eyes sessions.
- VisualGridRunner - Used to manage sessions when working with the Ultrafast Grid.
An object of this class is used to manage multiple Eyes sessions when working without the Ultrafast Grid.
For a details of arguments, see ClassicRunner class.
To define the class:
EyesRunner runner = new ClassicRunner();
This command returns an object with the Eyes test results from a given test or test file. This command should be called after all Eyes tests have been completed.
TestResultsSummary allTestResults = runner.GetAllTestResults();
An object of this class is used to manage multiple Eyes sessions when working with the Ultrafast Grid.
For details of arguments, see VisualGridRunner class.
To define the class:
EyesRunner runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(5));
This command returns an object with the results from a test or test file. This command should be called after all Eyes tests have been completed.
TestResultsSummary allTestResults = runner.getAllTestResults();
Eyes Class enables visual testing with Applitools Eyes.
To define the class:
Eyes eyes = new Eyes(runner);
This method creates an Eyes test. This will start a session with the Applitools server.
eyes.Open(driver, "app name", "test name", new RectangleSize(width, height));
- driver – Your web driver
- "app name" – The application name, this may be any string. You can set the application name for all tests using
Configuration.setAppName, in which case you do not need to set the app name.
- "test name" – The name of the test. This name must be unique within the scope of the application name. It may be any string.
- new RectangleSize(width, height)) (Optional) - Defines the viewport size of the browser that will be set before the start of the test. If this parameter is not provided, the viewport size will be based on the current browser window size.
This command generate a screenshot of the current page and adds it to the Eyes test.
For details of
eyes.check arguments, see CheckSettings class.
This command closes the Eyes test and checks that all screenshots are valid. It is important to call this command at the end of each test, symmetrically to
eyes.close receives no arguments.
Log files are automatically saved in the temp directory of the machine the tests ran on.
By default, the log directory is
<os temp directory>/applitools-logs
You can locate it as follows:
When running the tests remotely, you can specify the path to the logs using the environment variable
APPLITOOLS_LOG_DIR=<full path to log_dir>
Other Significant classes
When working with this SDK, you should be familiar with the following classes:
BatchInfo class - Call the
Configuration.setBatchmethod with an object of this class to configure the batch for one or more test.
Configuration class - Used to create a configuration object that is used to configure an Eyes object by passing it to the