I am writing a middleware framework for testing an AngularJS web app and I want to be able to wait for certain conditions to be met before I move on to another action in my tests. I am fairly new to Protractor and from what I have found in their doc and other forums, there are a few different ways to do this using browser.driver.wait or similar techniques that use a Condition or a promise including this answer.
What I am specifically trying to achieve is to follow the Page Object model design in my framework and to allow each page to provide its own function to determines whether that page is visible in the browser or not. In order to do that, I ended up writing page objects as below:
var pages = {
home: {
name: 'home',
url: server + '/#/home',
title: 'Home',
isVisible: until.titleIs(this.title)
},
...
}
There are two issues that I am trying to wrap my head around and fix:
- First and foremost, I get an error saying that
untilis undefined. I have not been able to find the right way to use this object yet and all my searches lead to alternative ways for waiting for an element to be visible or an expected condition to be true. How can I access this object directly? And, is that considered bad/obsolete design? -
Assuming that I find a way to use the
untilobject directly, I can see in Protractor source code that theuntil.titleIs()function returns aCondition, so my next question is how I can use thisConditionobject to get its the boolean result after the waiting is over (or times out)? I will need to do this for some special cases such as below:var condition = until.titleIs('some title'); var result = browser.wait(condition, timeout).then(function(res) { return res; }); if (result) // do something else // do another thing
I will really appreciate your help with this!
Aucun commentaire:
Enregistrer un commentaire