Skip to content

Instantly share code, notes, and snippets.

@raven
Created November 28, 2017 11:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raven/d1baecb09b9f836875d7fdcb04da1893 to your computer and use it in GitHub Desktop.
Save raven/d1baecb09b9f836875d7fdcb04da1893 to your computer and use it in GitHub Desktop.
Launching Mobile Safari for iOS UITests with a specific URL
// Get a hold of Mobile Safari
let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
// Pass in the launch arguments to open specific url immediately
safari.launchArguments = ["-u", "http://google.com"]
safari.launch()
// If using deeplinks, you will need to accept the prompt
safari.buttons.matching(identifier: "Open").firstMatch.tap()
@pattu777
Copy link

The -u argument fails for iOS v12.2 on new iPads. Any workarounds..??

@jonnyijapan
Copy link

@pattu777 There should be a way to have it tap the URL bar, then enter a URL, and a return tap. I do have it in a UI test, I can't get at the code until tomorrow tho :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment