Shailendra Sharma Shailendra Sharma - 1 year ago 84
Javascript Question

Calling "click()" on checkboxes fails in protractor

in one of my test case, i have to perform a click on checkbox

i tried : -

var cb = element(by.css('#port'+text)); // failed



is anybody face this kind of issue , is there any other workaround to do this

updated - tried with hard-coded values:


<input type="checkbox" style="min-width:50px;" id="port32201295-a833-45ea-8268-7c4bc0aa9887" ng-checked="port.checked" ng-disabled="port.disabled" ng-click="getSelectedPorts($event,port);$event)">


var cb = element(by.css('#port32201295-a833-45ea-8268-7c4bc0aa9887')); // failed(element is not visible | but element is visible have height & width)
browser.actions().mouseMove(cb).click().perform();// nothing happens

Answer Source

Fixed this issue by removing custom styles form checkbox,in my case the real checkbox is override by checkbox look like div , because of this element is not visible for protractor , this happens only in case of check-boxes because i am also using select2.js for select boxes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download