Chrome, Android.
After a test, in which our app causes a browser to open, (the system default browser has been set to chrome) the number of tabs in that browser eventually grows. How do we close them? A few people have shown how we can happily close all tabs that we open during a test, that’s fine, but driver.close() can only close a handle it knows about or opened already.
- It’s impractical to close all browser tabs in test teardown, because sometimes a test will loose connection to the webdriver due to timeout so the driver.close() call is really not going to do anything useful as it does not have all open tabs handles
- Resetting the app data/ gets painful because then we need to go through whatever random chrome terms and conditions pop-ups go with that version of chrome. Is this what mostly people do do?
- https://stackoverflow.com/questions/28715942/how-do-i-switch-to-the-active-tab-in-selenium Does not behave as one expects because driver.window_handles , only returns a single handle, it does not return any other tabs that were opened the day before.
Is targeting the browser as a native app and clicking X on all the tabs to the left of the topmost one a working solution? Anyone had luck using send-keys and CTRL+TAB perhaps? Although knt knowing how many times to tab is a mystery still, so if that works, do let us know a strategy that covers using CTRL + TAB.