Typing into input

This is our next step:

When user types in "valid@ema.il" in the "#email" element

This involves finding the element with the id of email, and then sending keystroke events to it. In spec/cucumber/steps/interactions/input.js, add the following step definition:

import { Given, When, Then } from 'cucumber';import { By } from 'selenium-webdriver';When(/^user types in (?:"|')(.+)(?:"|') in the (?:"|')([\.#\w]+)(?:"|') element$/, async function (text, selector) {  this.element = await this.driver.findElement(By.css(selector));  return this.element.sendKeys(text);});

Here, driver.findElement returns an instance of WebElementPromise. We are using the async/await syntax to avoid callback hell or heavily chained promises. The same 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.