unable to click on popup ok button in protractor
<p>I don`t why this  protractor code work for popups.
My protractor version : 4.0.3  chrome version: chromedriver_2.22.exe</p>

<p>below is the Error message that i am getting</p>

<p>Failed: no alert open
      (Session info: chrome=52.0.2743.116)
      (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)
  Stack:
    NoSuchAlertError: no alert open
      (Session info: chrome=52.0.2743.116)
      (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)</p>

<p>HTML Script for the popup</p>

<pre><code>&lt;div class="modal-content" modal-transclude=""&gt;&lt;div class="popupAlert popupAlert-full marginNone ng-scope"&gt;
    &lt;div class="popup-header"&gt;
        &lt;h2 class="modal-title ng-binding" id="myModalLabel"&gt;You are leaving this page &lt;/h2&gt;
    &lt;/div&gt;
    &lt;div class="popup-body"&gt;
        &lt;div class="row Margin0"&gt;
            &lt;p class="text ng-binding"&gt;By continuing all the SLI data will be lost.&lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="popup-footer"&gt;
        &lt;div class="row Margin0"&gt;
            &lt;a data-ng-click="cancel()" class="pull-right buttonLink2"&gt;Cancel
            &lt;button type="button" class="pull-right swc_button" focus-element="autofocus" data-dismiss="modal" ng-click="ok()"&gt;Ok&lt;/button&gt;
        &lt;/a&gt;&lt;/div&gt;&lt;a data-ng-click="cancel()" class="pull-right buttonLink2"&gt;
    &lt;/a&gt;&lt;/div&gt;&lt;a data-ng-click="cancel()" class="pull-right buttonLink2"&gt;
&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
</code></pre>

<h1>Protractor code</h1>

<p>var popupAlert = browser.switchTo().alert();</p>

<pre><code>    var alertText = popupAlert.getText();
    console.log(" Alert text :" +alertText);
   popupAlert.accept();
</code></pre>

<p>//expect(popupAlert.accept).toBeDefined();</p>