The next article will describe the integration of Applitools Eyes with a BDD tool, using "Cucumber" as an example.
When using a BDD tool, like cucumber, you have a feature file that contains different scenarios of your product.
In the example below, you can see a demonstration of a Login scenario, that contains valid and invalid login attempts:
Within Cucumber, there is a support directory in a file called env.rb that runs before all the test codes.
This is where we handle setting-up or tearing-down our tests:
In order to add Applitools Eyes for visual testing, we need to pull in the Applitools Eyes "gem", by adding it to our Gemfile, as you can see below:
Following a Bundle install:
After that we are going back to the env.rb file, and add the next strings:
1. The required gem
2. An instance of Applitools Eyes, so we create an eyes object to store and reference the Applitools Eyes instance.
3. Specify your API keys. A use of environment variable to handle this, is recommended as well.
4. Rather than just calling Selenium directly, we are going to store it as local browser variable, so Applitools Eyes can return it as a modified Webdriver object that will allow Applitools to capture screenshots.
5. Set eyes.open and specify the app name ('the-internet'), the test name (since we are running many rent test, we can specify that dynamically - scenario.name) and pass the instance of Selenium Webdriver to Applitools Eyes.
6. After each test run, we need to close the Applitools Eyes session.
At the end, your code editor should looks like this:
Additionally, we need to go back to Step.definitions, and "tell" Applitools Eyes when to visually validate the page: we add the command eyes.check_window, so we can add a string and note what it is that we are checking:
Next, we can run our test, using the command 'bundle exec cucumber'. When the test will be completed, you will be able to review it at the Applitools Eyes Dashboard.