Error while selecting radio button option using protractor and cucumberjs

540 views
Skip to first unread message

kary...@gmail.com

unread,
Feb 16, 2016, 4:33:50 AM2/16/16
to AngularJS
Hello,

I am new to the world of automating tests on angular pages.
The framework I am using is protractor, but I am clubbing it with cucumberjs.

I am trying to click on a radio button. This is how the element looks like in the DOM :-

<div>
<input class="ng-pristine ng-untouched ng-valid" type="radio" ng-click="setTestOrValid(p)" value="Valid" ng-model="p.testOrValidDisplay" name="341">
Valid
<input class="ng-pristine ng-untouched ng-valid" type="radio" ng-click="setTestOrValid(p)" value="Invalid" ng-model="p.testOrValidDisplay" name="342">
Invalid (Test/Junk)
</div>


Following is the function which I have written to be able to click on it :-

    sut.browser.findElements(sut.by.css('[ng-click="setTestOrValid(p)"]')).then(function(elements){
     
for (i=0; i < elements.length; i++){
        elements
[i].getAttribute('value').then(function(value){
         
if (value == 'Invalid') {
            elements
[i].click();
         
}
       
})
     
}
   
})


The code above throws an error :-

 TypeError: Cannot read property 'click' of undefined


Would you please help me with this?
Reply all
Reply to author
Forward
0 new messages