Closed sswaroopgupta closed 5 years ago
Note: This is because the order in which we connect to the next tab after closing the current tab is random for now and shouldn't be related to headless/headful mode.
Fix should be to connect to the previously opened tab, when the current tab is closed.
Test case notes Close tab should retain order when application opens content in a separate tab. Not specified explicitly by the taiko script
const { openBrowser, goto, link, text, contains, click,
openTab,closeTab } = require('taiko');
(async () => {
try {
await openBrowser({headless:false});
await goto("google.com",{timeout:20000});
await openTab("https://www.thoughtworks.com/contact-us",{timeout:20000});
await click(link("privacy policy",below(text(contains("I agree to share my information")))))
await closeTab()
await closeTab()
} catch (e) {
console.error(e);
} finally {
closeBrowser();
}
})();
Here the website opens the
privacy policy
in a separate tab. The script does not specify it explicitly.
commit - 499249fb2a904ee4dc4eb83976d6d1905a3edd07 Mac it is working as expected. Windows it is having an issue
[PASS] Browser opened
[PASS] Navigated to url "http://google.com"
[PASS] Opened tab with url "https://www.thoughtworks.com/contact-us"
[PASS] Clicked link with text privacy policy and Below Element with text "[object Object]"
[PASS] Closed tab with url "https://www.thoughtworks.com/privacy-policy"
[PASS] Closed tab with url "chrome://welcome-win10/"
[PASS] Browser closed
I can see this issue happen intermittently with https://github.com/getgauge/taiko/blob/5155b890d9e19d0573727cccf2830ecc45efcd36/examples/04-windows-tabs.js
I suspect that when launching chromium in headless mode, closing a tab does not always bring the previous tab back as active.
Seems to work fine after the fix for #589.
The below code has been testes with both headless and headful mode
const { openBrowser, goto, link, text, contains, click,
openTab,closeTab } = require('taiko');
(async () => {
try {
await openBrowser({headless:false});
await goto("google.com",{timeout:20000});
await openTab("https://www.thoughtworks.com/contact-us",{timeout:20000});
await click(link("privacy policy",below(text(contains("I agree to share my information")))))
await closeTab()
await closeTab()
} catch (e) {
console.error(e);
} finally {
closeBrowser();
}
})();
Observation:
Commit version: 7493c6afa8565c8482f8f01ada43c32dd1185627
Expected behavior The behavior of closeTab without parameters should be consistent in headless and non-headless modes.
Actual behavior The tabs getting closed are different in both these cases
Steps to replicate
(async () => { try { await openBrowser({headless:false}); await goto("makemytrip.com/") await openTab("gauge.org/index.html") await closeTab() await closeTab() } catch (e) { console.error(e); } finally { closeBrowser(); } })();
[PASS] Browser opened [PASS] Navigated to url "http://makemytrip.com/" [PASS] Opened tab with url "http://gauge.org/index.html" [PASS] Closed tab with url "https://gauge.org/index.html" [PASS] Closed tab with url "https://www.makemytrip.com/" [PASS] Browser closed
const { openBrowser, goto, inputField, into, write, toRightOf, comboBox, click, openTab,closeTab } = require('taiko');
(async () => { try { await openBrowser(); await goto("makemytrip.com/") await openTab("gauge.org/index.html") await closeTab() await closeTab() } catch (e) { console.error(e); } finally { closeBrowser(); } })();
[PASS] Browser opened [PASS] Navigated to url "http://makemytrip.com/" [PASS] Opened tab with url "http://gauge.org/index.html" [PASS] Closed tab with url "https://gauge.org/index.html" [PASS] Closed tab with url "about:blank" [PASS] Browser closed
commit - 55e833232dc9d7c27b45db9801ca959639e62553