I am new to Protractor. I think I have this down when dealing with an Angular page, but can\'t figure it out for a non-Angular page. Any help would be appreciated.
In protractor there are two types terms for on the page. isPresent
ask if the element is exists on the page. isDisplayed
asks if the element is visible. If you are waiting for a page to load you need to wait for isDisplayed
, but that will error if it is not present, so wait for isPresent
first. I use a function to wait for an element.
function waitForElement(el, waitTimeoutMilliseconds){
return browser.wait(function() { return el.isPresent(); }, waitTimeoutMilliseconds)
.then(function(){
return browser.wait(function() { return el.isDisplayed(); }, waitTimeoutMilliseconds);
});
}
Then just call that function in your test.
describe('Search', function() {
it('should click Search button and wait for results', function() {
var el = element(by.id('search'));
waitForElement(el, 5000);
el.click();
});
});