const {client} = require('nightwatch-cucumber');
const {defineSupportCode} = require('cucumber');

defineSupportCode(({When}) => {
    When(/^I follow "([^"]*)"$/, (linkText) => {
        return client
            .useXpath()
            .click('//a[contains(., "' + linkText + '")]');
    });

    When(/^I visit "([^"]*)"$/, (url) => {
        return client
            .url(client.launch_url + url)
            .waitForElementVisible('body');
    });

    When(/^I click on "([^"]*)"$/, (css) => {
        return client
            .useCss()
            .waitForElementVisible(css)
            .click(css);
    });

    When(/^I click on list item "([^"]*)"$/, (text) => {
        let selector = '//li[contains(., "' + text + '")]';
        return client
            .useXpath()
            .waitForElementVisible(selector)
            .click(selector);
    });

    When(/^I press "([^"]*)"$/, (key) => {
        return client.keys([client.Keys[key]]);
    });
});

@@ -957,13 +957,305 @@
 %0A    %7D);
+%0A%0A    When(/%5EI scroll to %22(%5B%5E%22%5D*)%22$/, (element) =%3E %7B%0A        return client.getLocationInView(element, () =%3E %7B%0A            // Scroll a little extra to trigger lazy actions such as infinite%0A            // scroll.%0A            return client.execute('window.scrollBy(0, 100)');%0A        %7D);%0A    %7D);
 %0A%7D);%0A

Add scroll to navigation step