I'm still learning Protractor so I'm not sure if this is a simple answer that I'm not getting but I'm just trying to have the browser wait until the attribute I'm retrieving is true.
I was trying something like this:
browser.wait(function() {
topping.getAttribute('aria-expanded').then(function(value) {
if(value == 'true') {
return true;
};
});
}, 5000);
Since .getAttribute() only returns as a string or null I tried to use an if statement to return an actual true value. This doesn't appear to work. Am I misunderstanding the .then() function or maybe misunderstanding browser.wait()?
Complete code:
browser.get('http://ift.tt/1GgQA5W');
var topping = element(by.model('topping'));
topping.click();
browser.wait(function() {
return topping.getAttribute('aria-expanded').then(function(value) {
return value == 'true';
});
}, 5000);
var toppingOptions = element.all(by.css('[role="option"]'));
toppingOptions.get(5).click();
expect(topping.getText()).toBe('Onion');
One more note, if I put browser.sleep(1000); after topping.click() and before browser.wait() then the test passes. So I know the rest of the test isn't what's failing. For some reason the call to wait isn't working.
Aucun commentaire:
Enregistrer un commentaire