You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
I have a similar problem to this: #55 - though the difference is the expectations working fine, no errors, no exceptions, but it does not switch back to the previous window. I am at my wits end. I tried first with tabs, it did not work, so I switched to windows since them being tabs and not windows is not part of any of our test cases.
it('checks tabs',async()=>{consturl1='/login';consturl2=config.chatLaunchUrl;letwindowHandles={oldTab: '',newTab: ''};awaitbrowser.get(url1);awaitbrowser.getWindowHandle().then(handle=>{windowHandles.oldTab=handle;});// opening new window sending CTRL+Nawaitbrowser.actions().sendKeys(protractor.Key.chord(protractor.Key.CONTROL,"n")).perform();awaitbrowser.getAllWindowHandles().then(handles=>{expect(handles[0]).toEqual(windowHandles.oldTab);windowHandles.newTab=handles[1];returnbrowser.driver.switchTo().window(windowHandles.newTab);}).then(()=>{// this worksreturnbrowser.get(url2);}).then(()=>{returnbrowser.driver.switchTo().window(windowHandles.oldTab).then(()=>browser.driver.executeScript('window.focus();'));}).then(()=>{lethandle=browser.driver.getWindowHandle();expect(handle).toEqual(windowHandles.oldTab);}).then(()=>browser.sleep(6000));});
I have added a sleep to make sure you can see it did not switch. (At least UI is not moved to forward, doesn't get the focus).
Works with FireFox but not with Chrome.
Expectations are all verified in both browsers, though Chrome does not switch, while FireFox does.
I tried out the window.focus() script trick, but it did not switch. On FireFox you don't even need that trick to make it work.