September 2018
Intermediate to advanced
764 pages
20h 6m
English
Before we can run any tests, we must tell Selenium which browser to use. Chrome is, by far, the most popular browser in use today, and so we will start with using ChromeDriver. Let's install it:
$ yarn add chromedriver --dev
Now, inside spec/cucumber/steps/index.js, define Before and After hooks which are run before each scenario:
import { After, Before } from 'cucumber';import webdriver from 'selenium-webdriver';Before(function () { this.driver = new webdriver.Builder() .forBrowser("chrome") .build(); return this.driver;});After(function () { this.driver.quit();});
In the Before hook, we are creating a new instance of the driver. A driver is akin to an user session, and a session can have many windows opened (just like ...
Read now
Unlock full access