Reputation: 473
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'm testing the pizza option for this site.
Complete 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 the error:
Element is not clickable at point (436, 693). Other element would receive the 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 passes. So I know the rest of the test isn't what's failing. For some reason the call to wait isn't working.
I'm thinking it might have something to do with the fact that the option I'm trying to click is not technically visible when topping
is clicked because it's in a ComboBox with a scroll element. If anyone knows a good way to simulate scrolling to the "onion" element it would be much appreciated as well.
Upvotes: 4
Views: 5829
Reputation: 473873
You are missing the return
from the wait condition function:
browser.wait(function() {
return topping.getAttribute('aria-expanded').then(function(value) {
return value == 'true';
});
}, 5000);
Note that I've also simplified the comparison logic inside the then
callback.
Or, you can also wait for the option element to become visible:
var EC = protractor.ExpectedConditions;
var toppingOptions = element.all(by.repeater("topping in toppings"));
browser.wait(EC.visibilityOf(toppingOptions.first()), 5000);
toppingOptions.get(5).click();
Upvotes: 6
Reputation: 2291
I came across a similar issue in one of my test where the Selenium was clicking at the wrong coordinates. Actually, Selenium was able to find the element when the element moved not very swiftly from top to center(a pop up was loaded in that fashion). Then while clicking on the element, it's position changed and click went on wrong location and hence the error. It seems to a limitation of selenium as discussed here.
If you have the same issue, better use thread.sleep with small interval.
You may also like to visit the page: Debugging "Element is not clickable at point" error
Upvotes: 0
Reputation: 4705
I think you want something like this:
var toppingElem = by.id('#topping'); // or how ever you can designate this element
browser.wait(function() {
return ptor.isElementPresent(toppingElem);
}, 5000);
Upvotes: 0