Click is skipping a child element on a dropdown menu

你离开我真会死。 提交于 2019-12-25 07:46:42

问题


Only the first child is ok, second is never clicked, the 3rd option is clicked but changed into the first option too quick that it doesn´t have time to get the URL. Tried to increase pauses and waiting times but it didn´t work.

module.exports =  {
'Language Selection': function(browser) {
    const homePage = browser.page.language();
    var j = 0;
    for (var i in homePage.elements) {
        homePage
            .navigate()
            .waitForElementVisible('#azercell_language_selector', 2000)
            .click('#azercell_language_selector');
        //browser
           // .keys(['uE015','uE006']);

                //function(){
            //.pause(1000);
                homePage
                    .waitForElementVisible(homePage.elements[i].selector, 5000,
                        function () {
                            browser.pause(1000);
                            browser.moveToElement(homePage.elements[i].selector, 1,1,
                       function(){
                            browser.pause(5000)
                       })
                        .click(homePage.elements[i].selector,
                        function () {
                        browser
                            .pause(1000)
                            .windowHandles(function (result) {
                                url = homePage.getUrl(j + 1);
                                var home = result.value[0];

                                var handle = result.value[1];
                                browser
                                    .switchWindow(handle)
                                    .pause(5000)
                                    .verify.urlContains(url)
                                    .switchWindow(home);
                                j += 1;
                         //  })
                            })
                    });
          })
    }
}

}; Page Object:

module.exports = {
    url: function() {
        return 'http://oyun.azercell.com/?lang=az';
    },
    commands: [{
        getUrl: function(n) {
            if (n === 1) {
                return 'oyun.azercell.com/?lang=az';
            }
            if (n === 2) {
                return 'oyun.azercell.com/?lang=ru';
            }
            if (n === 3) {
                return 'oyun.azercell.com/?lang=en';
            }

        }

    }],
    elements: {

        AZ: {
            selector: '#azercell_language_selector>option:nth-child(1)'
        },
        RU: {
            selector:'#azercell_language_selector>option:nth-child(2)'
        },
        EN: {
            selector: '#azercell_language_selector>option:nth-child(3)'
        }

    }
};

来源:https://stackoverflow.com/questions/37523672/click-is-skipping-a-child-element-on-a-dropdown-menu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!