Navigating to a page

Now that everything is set up, let's implement our first step, which is When user navigates to /. Navigation can be done using the .get method on our driver object:

import { Given, When, Then } from 'cucumber';When(/^user navigates to ([\w-_\/?=:#]+)$/, function (location) {  return this.driver.get(`http://${process.env.SERVER_HOST_TEST}:${process.env.SERVER_PORT_TEST}${location}`);});

This step takes the server host and port from the environment variables. this.driver.get returns a promise which is returned. Cucumber will wait for this promise to be resolved or rejected before moving on to the next step.

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.