0

I am getting Error in Communicating with Remote browser. It may have died when closing an existing browser created by protractor and switching to newly created window and then finding element by Link Text. Below is the code snippet. Kindly help in resolving the issue.

browser.driver.getAllWindowHandles().then(function(handles){
    browser.driver.switchTo().window(handles[0]);
    browser.driver.close();
    browser.driver.switchTo().window(handles[1]);
});
element(by.linkText('connect')).isPresent(); // While Executing This code it throws the above error and Fails...
  • I have not tried it, but I think maybe after you close window[0] you have only one window left? So window[1] doesnt exist? Maybe you don't need to switch of locate your window another way than by index ? – Chai Jul 05 '17 at 12:55
  • Thank you for your Answer. Even i thought the same way.But Even After i Close, I still see both the window handle Available when i print in console. Also After closing window[0], If i try to switchTo Window[0]; I am getting No Such Window Exception... I see a similar Example working, But there they close the newly opened window.. https://stackoverflow.com/questions/29502255/is-there-a-way-to-close-a-tab-in-webdriver-or-protractor – Mithun048 Jul 06 '17 at 11:11
  • Was just now looking into it. I suspect the issue is that the line with isPresent() is executed without waiting for the rest. Maybe try like so: browser.driver.getAllWindowHandles().then(function(handles){ browser.driver.switchTo().window(handles[0]); browser.driver.close(); browser.driver.switchTo().window(handles[1]); }).then(function () { element(by.linkText('connect')).isPresent(); }) – Chai Jul 10 '17 at 11:02

0 Answers0