Page tree
Skip to end of metadata
Go to start of metadata

Last updated: May 31, 2020 10:48

In iOS 10 and newer, Safari supports an unlimited number of tabs. However, if you find yourself with too many tabs open and want to start fresh, there’s a shortcut to close all your tabs at once.

by Christopher Alton

Legacy | Manual Process

Step #1. First, launch Safari on your iOS device.

Step #2. Second, tap and hold on the tab button. (For a long touch, hold down the Ctrl key and click & hold on the desired location on the device)


Step #3. Next up, you will get the option to close all the open tabs at once. Tap on Close Tab.


This will clear the tabs for your iOS device.

Automated Process

This can also be done through automation. As a helpful step, here is a JAVA code sample using Appium, that can work for iOS 11 and newer:

Map<String, Object> params = new HashMap<>();

params.clear();
params.put("automation", "os");
driver.executeScript("mobile:browser:open", params);

driver.context("NATIVE_APP");
WebElement browserTab = driver.findElementByXPath("//*[@label=\"Tabs\"]");

TouchAction action = new TouchAction(driver);
action.longPress(browserTab).press(browserTab);
action.perform();
action.longPress(browserTab).release();
action.perform();

params.clear();
params.put("content", "Close All");
params.put("timeout", "30");
driver.executeScript("mobile:text:find", params);

driver.context("NATIVE_APP");
driver.findElementByXPath("//XCUIElementTypeButton[contains(@label,'Close All')]").click();

Thread.sleep(10000);


NOTE:

This automation code sample currently works in the following iOS Versions:

  • iOS 11
  • iOS 12


This automation code sample does not work in the following iOS versions

  • iOS 10 and earlier


This automation code sample does not work in any Android version.