javascript - How can I access the 'until' object directly in Protractor? -
i writing middleware framework testing angularjs web app , want able wait conditions met before move on action in tests. new protractor , have found in doc , other forums, there few different ways using browser.driver.wait or similar techniques use condition or promise including answer.
what trying achieve follow page object model design in framework , allow each page provide own function determines whether page visible in browser or not. in order that, ended writing page objects below:
var pages = { home: { name: 'home', url: server + '/#/home', title: 'home', isvisible: until.titleis(this.title) }, ... } there 2 issues trying wrap head around , fix:
- first , foremost, error saying
untilundefined. have not been able find right way use object yet , searches lead alternative ways waiting element visible or expected condition true. how can access object directly? and, considered bad/obsolete design? assuming find way use
untilobject directly, can see in protractor source codeuntil.titleis()function returnscondition, next question how can useconditionobject boolean result after waiting on (or times out)? need special cases such below:var condition = until.titleis('some title'); var result = browser.wait(condition, timeout).then(function(res) { return res; }); if (result) // else // thing
i appreciate this!
until protractor.expectedconditions object. define globally, put following onprepare() function in config:
onprepare: function () { global.until = protractor.expectedconditions; }, as second question, make isvisible function, return promise:
isvisible: function () { return browser.wait(until.titleis(this.title), 5000).then(function () { return true; }, function () { return false; }); }, then, can expect in test:
expect(mypageobject.isvisible()).tobe(true);
Comments
Post a Comment