问题
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