The last step is to do the following:
Then the "#register-button" element should have a "disabled" attribute
As before, we need to find the element, but this time read its disabled attribute and assert that it is set to "true".
The HTML content attribute will always be a string, even when you'd expect a boolean or number.
In spec/cucumber/steps/assertions/index.js, add the following:
import assert from 'assert';
import { Given, When, Then } from 'cucumber';
import { By } from 'selenium-webdriver';
When(/^the (?:"|')([\.#\w-]+)(?:"|') element should have a (?:"|')([\w_-]+)(?:"|') attribute$/, async function (selector, attributeName) {
const element = await this.driver.findElement(By.css(selector));
const attributeValue = await element.getAttribute(attributeName);
assert.equal(attributeValue, 'true');
});
Here, we use the getAttribute method from the WebElement instance to get the value of the disabled attribute. Again, this is an asynchronous operation, so we are using async/await syntax to keep things neat.
If you have time, it's always a good idea to read the official documentation. The API of all classes and methods from selenium-webdriver can be found at https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/.