<commit_before>'use strict';
/* global browser, expect, element, by, EC */
/* eslint no-magic-numbers: 1, new-cap: 0 */  // --> OFF for Given, When, Then

/*
 * Created by marketionist on 13.11.2016
 */
// #############################################################################

// Use the external Chai As Promised to deal with resolving promises in
// expectations
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const fs = require('fs');
const protractor = require('protractor');
const censor = require('./utils/helpers.js').censor;

chai.use(chaiAsPromised);
let expect = chai.expect;
let EC = protractor.ExpectedConditions;
let customTimeout = browser.params.customTimeout || 5000;
let pageObjects = browser.params.pageObjects;

module.exports = function () {
    /**
     * Waits for the element to be present and displayed on the page
     * @param {string} elementSelector
     */
    function waitForDisplayed(elementSelector) {
        browser.wait(EC.presenceOf(elementSelector), customTimeout,
            `${elementSelector} should be visible, but it\'s not`);
    }

    // #### When steps #############################################################

    this.When(/^I go to URL "([^"]*)"$/, function (url, next) {
        browser.get(url);
        next();
    });

    this.When(/^I go to "([^"]*)"."([^"]*)"$/, function (page, elem, next) {
        let url = pageObjects[page][elem];

        browser.get(url);
        next();
    });

    this.When(/^I click "([^"]*)"."([^"]*)"$/, function (page, elem, next) {
        let locator = pageObjects[page][elem];
        let elmnt;

        if (locator[0] + locator[1] === '//') {
            elmnt = element(by.xpath(locator));
        } else {
            elmnt = element(by.css(locator));
        }

        waitForDisplayed(elmnt);
        elmnt.click();
        next();
    });

    // #### Then steps #############################################################<commit_msg>Added new step to work with inputs<commit_after>'use strict';
/* global browser, expect, element, by, EC */
/* eslint no-magic-numbers: 1, new-cap: 0 */  // --> OFF for Given, When, Then

/*
 * Created by marketionist on 13.11.2016
 */
// #############################################################################

// Use the external Chai As Promised to deal with resolving promises in
// expectations
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const fs = require('fs');
const protractor = require('protractor');
const censor = require('./utils/helpers.js').censor;

chai.use(chaiAsPromised);
let expect = chai.expect;
let EC = protractor.ExpectedConditions;
let customTimeout = browser.params.customTimeout || 5000;
let pageObjects = browser.params.pageObjects;

module.exports = function () {
    /**
     * Waits for the element to be present and displayed on the page
     * @param {string} elementSelector
     */
    function waitForDisplayed(elementSelector) {
        browser.wait(EC.presenceOf(elementSelector), customTimeout,
            `${elementSelector} should be visible, but it is not`);
    }

    // #### When steps #############################################################

    this.When(/^I go to URL "([^"]*)"$/, function (url, next) {
        browser.get(url);
        next();
    });

    this.When(/^I go to "([^"]*)"."([^"]*)"$/, function (page, elem, next) {
        let url = pageObjects[page][elem];

        browser.get(url);
        next();
    });

    this.When(/^I click "([^"]*)"."([^"]*)"$/, function (page, elem, next) {
        let locator = pageObjects[page][elem];
        let elmnt;

        if (locator[0] + locator[1] === '//') {
            elmnt = element(by.xpath(locator));
        } else {
            elmnt = element(by.css(locator));
        }

        waitForDisplayed(elmnt);
        browser.wait(EC.elementToBeClickable(elmnt), customTimeout,
            `${elmnt} should be clickable, but it is not`);
        elmnt.click();
        next();
    });

    this.When(/^I type "([^"]*)"."([^"]*)" in the "([^"]*)"."([^"]*)"$/, function (
            page1, element1, page2, element2, next) {
        let inputField = element(by.css(pageObjects[page2][element2]));

        browser.wait(EC.elementToBeClickable(inputField), customTimeout,
            `${inputField} should be clickable, but it is not`);
        browser.actions().mouseMove(inputField).click().perform();
        inputField.sendKeys(pageObjects[page1][element1]);
        next();
    });

    // #### Then steps #############################################################
{'fraction_non_alphanumeric': 0.24550768564624378, 'fraction_numerical': 0.008659883091578264, 'mean_word_length': 3.1176470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '386549', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1322, 'n_words': 323}