title: Cannot switch to POPUP window in Protractor
body: <p>when i click on the Link , a Popup opens up. However couldn't able to work on the fields of popup as protractor can't locate the elements and then it gets timedout.</p>
  
  <p>Following is the code
  browser.ignoreSynchronization = true;</p>
  
  <pre><code>    performancePage.go();
      logger.info('Info', 'Navigating to performance Page');
      helper.isElementVisible(performancePage.performanceTab);
      performancePage.performanceTab.click();
      element(by.id("ButtonAddProduct")).click();
      browser.driver.sleep(4000)
     var  handlePromise = browser.getAllWindowHandles();
      var handles = handlePromise.then(function (handles) {
          console.log(handles)
          popUpHandle = handles[1];
          var handle = browser.switchTo().window(popUpHandle);
          handle = browser.getWindowHandle();
          expect(handle).toEqual(popUpHandle);
          browser.driver.executeScript('window.focus();');
      });
      //helper.isElementVisible(performancePage.addProduct);
      //performancePage.addProduct.click();
      helper.isElementVisible(element(by.id("form1")));[![enter image description here][1]][1]
  </code></pre>
  
  <p>Also in console.log, its only showing 1 window handle and not of the Popup handle</p>
  
  <p>here is the HTML:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head id="Head1"&gt;
  &lt;body&gt;
  &lt;form id="form1" onsubmit="javascript:return WebForm_OnSubmit();" action="AddProduct.aspx" method="post"&gt;
  &lt;div class="aspNetHidden"&gt;
  &lt;script type="text/javascript"&gt; //&lt;![CDATA[ var theForm = document.forms['form1']; if (!theForm) {     theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) {     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {         theForm.__EVENTTARGET.value = eventTarget;         theForm.__EVENTARGUMENT.value = eventArgument;         theForm.submit();     } } //]]&gt; &lt;/script&gt;
  &lt;script type="text/javascript" src="/WebResource.axd?d=NLOzwancrFW_OxVrAGBXy-kmkOGHUYmO808scG3GJ5f98I_P9beUOmU4HNGkqJQWHiSPU9aY7onPaiTvMCtL3eBXmC_rcSTJAFJAPa_OIJw1&amp;t=635586505120000000"/&gt;
  &lt;script type="text/javascript" src="/ScriptResource.axd?d=K0uQ-qcyckZQ0YCESuG4YfaXFE8emO5C9Ce1KC27_VB1FRGUsYkGZcC6OJnVnIEp6qunwr4jFBAKcuX_FFlQhtiSBdTz0RYmzsqtrKC3ePqj2CqtZGDAEZ4f0TCoYf0CGDgUxlJb7An1eoe5Vvcd-YsPSDf93ysj0hatMJcw5Bk1&amp;t=5303ace5"/&gt;
  &lt;script type="text/javascript" src="/ScriptResource.axd?d=ICFVFfrCSHOWqdP0dm99rLOsC2_-ZnYiCw1CqjXgfBZ92x5ruBu78fP6ZyV7fADUc626lvSvIubJzd5ej_JSkHNQHZSSai511-4rfVoNIRmTJczCHqrBjZa3yIX-22uMxb3rGnoSAGlTcOHE53z7TSmGu1MNobwW3y3pLnoN-H72LyOhX5OECQ17aAmZHECd0&amp;t=7b689585"/&gt;
  &lt;script type="text/javascript"&gt; //&lt;![CDATA[ if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.'); //]]&gt; &lt;/script&gt;
  &lt;script type="text/javascript" src="/ScriptResource.axd?d=OL2ISgjqQODB5nkx4b5_GOgoAHxOq6FEk9tXBRu0WSmyCZCd3ccx73Jhlea-pmk11_GS4uVKb8o448Z76ihbV5xUGrVOtwriFbjM0joyKwz96l4gVfykwP91DaSn6g66OedAzY_pkY4s5--Zg_vgtAu4W2Kz6hrDw12cq5mZa1pji5zdqGZ-ZKisFszMRWz10&amp;t=7b689585"/&gt;
  &lt;script type="text/javascript"&gt; //&lt;![CDATA[ function WebForm_OnSubmit() { if (typeof(ValidatorOnSubmit) == "function" &amp;&amp; ValidatorOnSubmit() == false) return false; return true; } //]]&gt; &lt;/script&gt;
  &lt;div class="aspNetHidden"&gt;
  &lt;div style="margin: 4px"&gt;
  &lt;script type="text/javascript"&gt; //&lt;![CDATA[ Sys.WebForms.PageRequestManager._initialize('Scriptmanager1', 'form1', [], [], [], 90, ''); //]]&gt; &lt;/script&gt;
  &lt;table&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;td&gt;
  &lt;input id="TextBoxProductName" type="text" name="TextBoxProductName"/&gt;
  &lt;span id="RequiredFieldValidator1" style="visibility:hidden;"&gt;
  &lt;br/&gt;
  Please enter a product name.
  &lt;/span&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;b&gt;
  Product Short Name
  &lt;img id="Img4" src="../Images/Asterisk.gif"/&gt;
  &lt;/b&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input id="TextBoxShortName" type="text" name="TextBoxShortName"/&gt;
  &lt;span id="RequiredFieldValidator2" style="visibility:hidden;"&gt;
  &lt;br/&gt;
  Please enter a product short name.
  &lt;/span&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>