jeudi 3 mars 2016

How to get AngularJS model updated by clicking checkbox from outside javascript?

  • I have AngularJS application I need to test
  • I can't modify it.
  • I write my test in Selenide/Java, using JavascriptExecutor for JS execution
  • I need to click checkbox from javascript (it's necessary) in my test

The checkbox:

<input class="ng-pristine ng-valid" type="checkbox" ng-model="row.selected">

Question:

How I fire an event which updates row.selected variable in Angular's model?

Note: The AngularJS application works perfectly when clicked by human hand on a mouse. There isn't probably nothing wrong with it.

What I have tried:

jsExecutor.executeScript(""
    + "angular.element(arguments[0]).trigger('click'); "
    + "return 'doesnt matter what';",proxy);

  • proxy is WebElement
  • this approach works when clicking on the links in other test cases

Result: The checkbox has been un/checked after the javascript run but model's row.selected variable hasn't.




Aucun commentaire:

Enregistrer un commentaire