javascript - How do I tell Selenium that an Angular controller has "loaded" -


i've got ui tests attempting test click on element makes else appear. there's existing check tests looks see if dom ready, there's small amount of time between firing , app.controller() calls completing test jump in , wrongly determine click handler has not been added.

i can use angular.element('[ng-controller=mycontroller]').scope() determine if scope defined, there still small window test run before click handler bound (a very, small window).

<div ng-controller="mycontroller"> <div ng-click="dowork()"></div> </div>

can see way tell click handler has been added?

ps: there's event fires within controller when controller has loaded:$scope.$on('$viewcontentloaded', function(){ }); doesn't me unless subscribe in controller , flag variable somewhere can check via selenium.

pps: lot of these have classes change when scope changes , can used trigger test, many not.

there specialized tool testing angularjs application - protractor. wrapper around webdriverjs - selenium javascript webdriver.

the main benefit of using protractor knows when angular settled down , ready. makes tests flow in natural way without having use explicit waits:

you no longer need add waits , sleeps test. protractor can automatically execute next step in test moment webpage finishes pending tasks, don’t have worry waiting test , webpage sync.

it provides several unique angularjs-specific locators, by.model, by.binding etc. and, in general, provides convenient , well-designed api end-to-end testing.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -