0

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
JeffC
  • 22,180
  • 5
  • 32
  • 55
Shailendra Sharma
  • 6,976
  • 2
  • 28
  • 48

2 Answers2

0

Alternatively you can use to click a check box by using element(locator).click()

function setCheckBoxTo(locator, value){
    var checkbox = element(locator);
    checkbox.isChecked().then(function(selected){
        if(selected !== value){
            checkbox.click();
        }
    }
}

Reference here author

Pritish Vaidya
  • 21,561
  • 3
  • 58
  • 76
0

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.

Shailendra Sharma
  • 6,976
  • 2
  • 28
  • 48