Consider this simple protractor test:
<body>
<div ng-app="test2App" ng-controller="test2Ctrl">
<input ng-model="myValue">
</div>
</body>
var test2App = angular.module('test2App', [])
test2App.controller('test2Ctrl', function($scope,$timeout) {
$timeout(function() {
$scope.myValue = true;
},10000);
});
describe('my suite',function() {
it('wait for a model to be defined',function() {
element(by.model('myValue')).evaluate('myValue')
.then(function(v) {
expect(v).toBe(true);
});
});
});
Is there a better way than the protractor sleep() function to wait for "myValue" to be loaded into scope?
thx
Try browser.wait()
https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js#519
browser.wait(function(){
// Wait until condition is true.
return element(by.model('myValue')).evaluate('myValue')
.then(function(v) {
// I'm not sure if it will evaluate to a string, try it.
return v === 'true';
});
}, 10000)
Where 10000 is the timeout in ms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With