Query:
How can I successfully click on each link within a ul > li a
in one single test?
Issue: Although the test is currently passing, it is not effectively clicking on the links. This can be verified by the absence of redirection or the expected 2000ms delay.
Test Scenario:
it("should navigate to all footer links correctly", function() {
browser.driver.sleep(2000);
browser.ignoreSynchronization = true;
//creates an array containing the text of all menu items
var titles = element.all(by.css('.leftMenu.first .submenu li a'))
.map(function(elm) {
return elm.getText().then(function(text){
return text;
});
});
//iterates through the links using the titles array
for (var i = 0; i < titles.length; i++) {
// creates a link by selecting the element that contains the text from the titles array
var link = element(by.cssContainingText('.submenu li a', titles[i]));
//click functionality
link.click().then(function() {
browser.driver.sleep(2000);
//current expectation may seem arbitrary but should pass
expect(browser.driver.getTitle()).toBe('welcome to: ' + title[i]);
});
}
});
UPDATE: Solution found here: ANSWER