Search code examples
javascriptprotractorend-to-end

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));
cb.click() // failed 

and

browser.actions().mouseMove(cb).click().perform();

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

updated - tried with hard-coded values:

Template

   <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); 
submenu.network.minimizeMaximizePops($event)">

JS

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

Solution

  • 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.