title: How to get a return value from a js executing using browser.executeScript in protractor?
body: <p>I am trying to get a value back from execute script function and match it with the expect method.
  as isSelected doesn't work on many checkboxes that are used in app, I have to go this way.
  Here is my code, and I really appreciate your help.</p>
  
  <p>I have tried using isSelected with these kind of checkboxes but that doesnt work.
  Below code gives me the following error.
  Failed: Cannot read property 'getText' of null</p>
  
  <pre><code>exports.verifyRegularCheckboxChecked = function () {
    browser.driver.executeScript(function() {
      var special_list = $('div &gt; div');
      var returnValue = 'itIsTrue';
      var label, label_children;
      special_list.filter(function(index, elem) {
        label = elem.children;
        label_children = $(label).children();
        label_children.filter(function(nestedIndex, nestedElem) {
          if(nestedElem.tagName === 'INPUT') {
            if(nestedElem.checked) {
              return returnValue;
              }
            }
          });
        });
      }).then(function (returnValue) {
      expect(returnValue.getText()).toBe('itIsTrue');
    });
  };
  </code></pre>
  
  <p>The HTML code:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;div class="checkbox"&gt; 
      &lt;label&gt; 
         &lt;input class="ark-checkbox ng-untouched ng-valid ng-dirty ng-valid-parse" 
               ng-model="block.properties.milestoneIsVariable.value" type="checkbox"&gt; 
         &lt;span aria-label="ark-checkbox"&gt; ::before &lt;/span&gt; use variable 
       &lt;/label&gt; 
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>