iOS Pasteboard

Go back to tutorial

iOS Pasteboard

Related image

We will be learning about iOS Pasteboard with different types of functions involved. Also, there is a possibility in Appium to set the content of the iOS Simulator pasteboard and read the content from there, if needed. Therefore, each Simulator maintains its own pasteboard. Such that, this feature is only available since Xcode SDK 8.1. But, unfortunately, real devices don’t provide such features.

iOS Pasteboard – mobile: setPasteboard

This command sets the content of Simulator’s pasteboard to the particular string provided as an argument. Also, it is possible to customize the encoding of the given string.

Supported arguments

  • content: The content of the pasteboard. The previous content is going to be overridden. The parameter is mandatory
  • encoding: Encoding of the given content. UTF-8 by default.

Usage examples

// Java

JavascriptExecutor js = (JavascriptExecutor) driver;

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

args.put(“content”, new String(Files.readAllBytes(new File(“/etc/passwd”).toPath()), Charset.forName(“latin-1”)));

js.executeScript(“mobile: setPasteboard”, args);

mobile: getPasteboard

This command is used to get the current content of Simulator’s pasteboard as a string. Also, it is possible to customize the encoding of the received string.

Supported arguments

  • encoding: Encoding of the received pasteboard content. UTF-8 by default.

Usage examples

# Python

content = driver.execute_script(‘mobile: getPasteboard’, {‘encoding’: ‘shift-jis’});


Enrich your profile and become Job Ready. Practice and Prepare for Mobile Testing (Appium) Exam Now!

Get expert advice and hundreds of Free Test – Try Mobile Testing (Appium) Practice Questions Now!

Go back to tutorial

Mobile App Management
iOS Predicate

Get industry recognized certification – Contact us