is possible execute jquery commands angular e2e scenario ?
for example, if execute : $('.picker-col-id-id').attr('class'); i'm getting error:
typeerror: property '$' of object [object object] not function
the problem here angularjs scenario test runner runs application in iframe. runner hasn't loaded jquery.
it's best use angular scenario dsl. e2e testing docs:
element(selector, label).{method}(key, value)
executes method passing in key , value on element matching given jquery selector, method can of following jquery methods: attr, prop, css. label used test output.
although not clear docs, can use 'attr' method 1 argument value of attribute.
element('.picker-col-id-id').attr('class'); if need other jquery functionality, focus(), can way:
element('.picker-col-id-id').query(function(elements, done) { elements.focus(); done(); }); or extend angular dsl
angular.scenario.dsl('jqueryfunction', function() { return function(selector, functionname /*, args */) { var args = array.prototype.slice.call(arguments, 2); return this.addfutureaction(functionname, function($window, $document, done) { var $ = $window.$; // jquery inside iframe var elem = $(selector); if (!elem.length) { return done('selector ' + selector + ' did not match elements.'); } done(null, elem[functionname].apply(elem, args)); }); }; }); and use way:
jqueryfunction('.picker-col-id-id', 'focus'); or in general:
jqueryfunction(selector, jqueryfunctionname, arg1, arg2, ...);
Comments
Post a Comment