<commit_before>'use strict';

module.exports = function () {
    this.World = require('../support/world.js').World;

    this.When(/^я выберу в выпадающем списке "([^"]*)" значение "([^"]*)"$/, function (comboboxLabel, value) {
        comboboxLabel = this.helpers.fixQuotes(comboboxLabel);
        value = this.helpers.fixQuotes(value);

        var selector = this.selectors.XPATH.ComboBox.button(comboboxLabel);
        var xpath = this.by.xpath(selector);
        var that = this;

        return this.currentView.findElement(xpath).then(function (element) {
            return element.click().then(function () {
                selector = that.selectors.XPATH.ComboBox.dropDown(value);
                xpath = that.by.xpath(selector);

                return that.driver.findElement(xpath).then(function (dropDownItem) {
                    return dropDownItem.click();
                })
            });
        });
    });

    this.When(/^я выберу в выпадающем списке "([^"]*)" с фильтром "([^"]*)" значение "([^"]*)"$/, function (comboBoxLabel, filter, value) {
        comboBoxLabel = this.helpers.fixQuotes(comboBoxLabel);
        value = this.helpers.fixQuotes(value);

        var selector = this.selectors.XPATH.ComboBox.button(comboBoxLabel);
        var xpath = this.by.xpath(selector);
        var that = this;

        return this.currentView.findElement(xpath).then(function (element) {
            return element.click().then(function () {
                selector = that.selectors.XPATH.ComboBox.filter();
                xpath = that.by.xpath(selector);

                return that.driver.findElement(xpath).then(function (filteredField) {
                    return filteredField.sendKeys(filter).then(function () {
                        selector = that.selectors.XPATH.ComboBox.dropDown(value);
                        xpath = that.by.xpath(selector);

                        return that.driver.findElement(xpath).then(function (dropDownItem) {
                            return dropDownItem.click();
                        });
                    });
                });
            });
        });
    });

    this.When(/^значение в выпадающем списке "([^"]*)" равно "([^"]*)"$/, function (comboBoxLabel, value) {
        comboBoxLabel = this.helpers.fixQuotes(comboBoxLabel);
        value = value.replace(/''/g, '"');

        var selector = this.selectors.XPATH.ComboBox.caption(comboBoxLabel);
        var xpath = this.by.xpath(selector);
        var that = this;
        
        return this.currentView.findElement(xpath).then(function (label) {
            return label.getAttribute('for').then(function (id) {
                return that.currentView.findElement(that.by.id(id)).then(function (control) {
                    selector = that.selectors.XPATH.ComboBox.value();
                    xpath = that.by.xpath(selector);

                    return control.findElement(xpath).then(function (comboBoxValue) {
                        return comboBoxValue.getText().then(function (text) {
                            that.assert.equal(text, value);
                        });
                    });
                });
            });<commit_msg>UI-2213: Выпадающий список "Способ формирования фонда капитального ремонта" не работает #resolved<commit_after>'use strict';

module.exports = function () {
    this.World = require('../support/world.js').World;

    this.When(/^я выберу в выпадающем списке "([^"]*)" значение "([^"]*)"$/, function (comboBoxLabel, value) {
        comboBoxLabel = this.helpers.parseElement(comboBoxLabel);
        comboBoxLabel.name = this.helpers.fixQuotes(comboBoxLabel.name);
        value = this.helpers.fixQuotes(value);

        var selector = this.selectors.XPATH.ComboBox.button(comboBoxLabel.name);
        var xpath = this.by.xpath(selector);
        var that = this;

        return this.currentView.findElements(xpath).then(function (elements) {
            return elements[comboBoxLabel.index].click().then(function () {
                selector = that.selectors.XPATH.ComboBox.dropDown(value);
                xpath = that.by.xpath(selector);

                return that.driver.findElement(xpath).then(function (dropDownItem) {
                    return dropDownItem.click();
                })
            });
        });
    });

    this.When(/^я выберу в выпадающем списке "([^"]*)" с фильтром "([^"]*)" значение "([^"]*)"$/, function (comboBoxLabel, filter, value) {
        comboBoxLabel = this.helpers.parseElement(comboBoxLabel);
        comboBoxLabel.name = this.helpers.fixQuotes(comboBoxLabel.name);
        value = this.helpers.fixQuotes(value);

        var selector = this.selectors.XPATH.ComboBox.button(comboBoxLabel.name);
        var xpath = this.by.xpath(selector);
        var that = this;

        return this.currentView.findElements(xpath).then(function (elements) {
            return elements[comboBoxLabel.index].click().then(function () {
                selector = that.selectors.XPATH.ComboBox.filter();
                xpath = that.by.xpath(selector);

                return that.driver.findElement(xpath).then(function (filteredField) {
                    return filteredField.sendKeys(filter).then(function () {
                        selector = that.selectors.XPATH.ComboBox.dropDown(value);
                        xpath = that.by.xpath(selector);

                        return that.driver.findElement(xpath).then(function (dropDownItem) {
                            return dropDownItem.click();
                        });
                    });
                });
            });
        });
    });

    this.When(/^значение в выпадающем списке "([^"]*)" равно "([^"]*)"$/, function (comboBoxLabel, value) {
        comboBoxLabel = this.helpers.parseElement(comboBoxLabel);
        comboBoxLabel.name = this.helpers.fixQuotes(comboBoxLabel.name);
        value = value.replace(/''/g, '"');

        var selector = this.selectors.XPATH.ComboBox.caption(comboBoxLabel.name);
        var xpath = this.by.xpath(selector);
        var that = this;
        
        return this.currentView.findElements(xpath).then(function (labels) {
            return labels[comboBoxLabel.index].getAttribute('for').then(function (id) {
                return that.currentView.findElement(that.by.id(id)).then(function (control) {
                    selector = that.selectors.XPATH.ComboBox.value();
                    xpath = that.by.xpath(selector);

                    return control.findElement(xpath).then(function (comboBoxValue) {
                        return comboBoxValue.getText().then(function (text) {
                            that.assert.equal(text, value);
                        });
                    });
                });
            });
{'fraction_non_alphanumeric': 0.13578062804068997, 'fraction_numerical': 0.0005897095680377414, 'mean_word_length': 2.029924073246985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6198592', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1884, 'n_words': 280}