I am writing my automated test scripts using selenium-webdriver, phantomJS and mocha.
My script file is javascript file by nature.
I want to wait till an element() becomes completely visible. After it becomes visible, the element will be clicked.
Let me explain in details:
There are some menus and submenus. The menu is collapsible in nature. When I click on a menu, then its corresponding submenus are displayed.
My following script first iterates(And clicks) through the menu and then iterates and (should be) clicking the submenu.
for(var iMajor = 2; iMajor <= majorLinkLast ; iMajor++)
{
(function(iMajor){
majorMenuXPath = "//ul[contains(@id, 'side-menu')]/li["+iMajor+"]/a";
if(iMajor != 2)
{
driver.findElement(By.xpath(majorMenuXPath)).click().then((function(iMajor){
for(var iMinor = 1; iMinor <= minorSize[iMajor] ; iMinor++)
{
(function(iMajor, iMinor){
minorMenuXPath = "//ul[contains(@id, 'side-menu')]/li["+iMajor+"]/ul/li["+iMinor+"]/a";
driver.findElement(By.xpath(minorMenuXPath)).then(function(eleMinor){
driver.wait(function(){
return eleMinor.isDisplayed();
}, 20000).then(function(){
eleMinor.isDisplayed().then(function(stat){
console.log(stat);
});
});
});
})(iMajor,iMinor)
}
})(iMajor));
}
})(iMajor)
}
But I am getting message like this:
Track Revenue
Track Revenue
Track Revenue
Track Revenue
Track Revenue
Track Revenue
Campaigns
1) View page by clicking menu
2 passing (1m)
1 failing
1) TrackRevenue Click Menu Test View page by clicking menu:
Error: timeout of 50000ms exceeded. Ensure the done() callback is being cal
led in this test.
Why am I getting such output?
The title should have been different.
Please help.