lundi 7 novembre 2016

Protractor - Giving "could not find testability for element" error when accessing element

I'm running into issue with Protractor when accessing variable that stores return value of "elements.all". I'm fairly new to Protractor, so I wasn't sure how to select elements by custom attribute. Luckily, I received a suggestion, when I posted a question in another post. I was suggested to try out - "element.all(by.css('[mycustom-id]'));". But I'm not sure if that statement works or not since I'm getting "Could not find testability for element" error. It is also possible that I'm incorrectly iterating the object. I appreciate if anyone of you can point out my mistake. Thanks.

Spec.JS

var settings = require(__dirname + '/setting.json');
describe('Protractor Demo App', function() { 
    var target = element.all(by.css('[mycustom-id]')); 

    beforeEach(function() {
       browser.get(settings.url);
    });     

    it('Test mouseover', function() {       

       // This does not work
       target.each(function(item){
          //Do some stuff here
       });     

       // This does not work either
       target.count().then(function(x){
         console.log("Total--" + x);
       });
    });

});

index.html

<div>
    <a mycustom-id="123" href=''>HELLO1</a>
    <a mycustom-id="211" href=''>HELLO2</a>
</div>

Aucun commentaire:

Enregistrer un commentaire