Browser.wait () until .getAttribute () returns true

I am still studying Protractor, so I'm not sure if this is a simple answer that I am not getting, but I'm just trying to make the browser wait while the attribute that I am retrieving is right.

I am testing the pizza option for this site .

Full code:

browser.get('https://material.angularjs.org/latest/#/demo/material.components.select');

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');

This gives me an error:

The element does not click at the point (436, 693). Another item will get a click:<md-backdrop class="md-select-backdrop md-click-catcher md-default-theme"></md-backdrop>

One more note: if I put browser.sleep(1000);after topping.click()and before browser.wait(), then the test will pass. Therefore, I know that the rest of the test is not unsuccessful. For some reason, the call to wait does not work.

, - , , , , topping, ComboBox . - "", .

+4
3

return :

browser.wait(function() {
    return topping.getAttribute('aria-expanded').then(function(value) {
        return value == 'true';
    });
}, 5000);

, then.


:

var EC = protractor.ExpectedConditions;

var toppingOptions = element.all(by.repeater("topping in toppings"));
browser.wait(EC.visibilityOf(toppingOptions.first()), 5000);

toppingOptions.get(5).click();
+6

, - :

var toppingElem = by.id('#topping'); // or how ever you can designate this element

browser.wait(function() {
  return ptor.isElementPresent(toppingElem);
}, 5000);
0

, . , Selenium , ( ). , , , , , . , .

, thread.sleep .

: " "

0

All Articles