Unable to run appium on Safari browser on Real Devices

Hi All,
I am looking for support to run the appium on safari browser on real iPhone. I have followed the appium documentation but getting error after running the below command -

Option 1: You dont define any parameters and it will set the code signing identity to ‘iPhone Developer’

$ ./reset.sh --ios --real-safari

Appium Document - http://appium.io/slate/en/v1.2.1/?java#setup76

Error Log from Terminal-
Jitendra-Kumars-MacBook-Pro:~ jitendrakumar$ cd /Users/jitendrakumar/Desktop/android
Jitendra-Kumars-MacBook-Pro:android jitendrakumar$ git clone https://github.com/appium/appium.git
Cloning into ‘appium’…
remote: Counting objects: 29622, done.
remote: Compressing objects: 100% (59/59), done.
remote: Total 29622 (delta 27), reused 10 (delta 4)
Receiving objects: 100% (29622/29622), 32.93 MiB | 50.00 KiB/s, done.
Resolving deltas: 100% (18299/18299), done.
Checking connectivity… done.
Jitendra-Kumars-MacBook-Pro:android jitendrakumar$ cd appium
Jitendra-Kumars-MacBook-Pro:appium jitendrakumar$ ./reset.sh --ios --real-safari
---- Resetting / Initializing Appium ----
RESETTING NPM

  • Installing new or updated NPM modules (including devDeps)
    RESETTING GENERAL
  • Setting git revision data
    RESETTING IOS
  • Setting iOS config to Appium’s version
  • Installing ios-sim-locale
  • Cloning/updating udidetect
  • Building udidetect
  • Moving udidetect into build/udidetect
  • Cloning/updating fruitstrap
  • Making fruitstrap
  • Copying fruitstrap to build
  • Cloning/updating SafariLauncher
  • Building SafariLauncher for real devices
    ---- FAILURE: reset.sh exited with status 1 ----
    ---- Retry with --verbose to see errors ----
    Jitendra-Kumars-MacBook-Pro:appium jitendrakumar$

Can you rerun the reset script with the --verbose flag on and post the logs?

I have re run with --verbose and its completed successfully.

Now I am trying to install safari Launcher from Xcode in iPhone and getting below error -

error: could not read CFBundleIdentifier from Info.plist (null)

I have taken the code from below URL -

Hi All,
Please help me resolve this issue. I have installed the safai launcher with valid dev certificate and provisioning profile and also ios-webkit-debug-proxy. running successfully. I have successfully run the command

$ git clone https://github.com/appium/appium.git
$ cd appium

Option 1: You dont define any parameters and it will set the code signing identity to ‘iPhone Developer’

$ ./reset.sh --ios --real-safari

Now I am trying to launch from Code -

DesiredCapabilities capabilities = new DesiredCapabilities();
System.out.println(“Inside Before Test 1”);
capabilities.setCapability(“appium-version”, “1.0”);
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“platformVersion”, “7.1”);
capabilities.setCapability(“deviceName”, “iPhone”);
capabilities.setCapability(“udid”, “4b4f21eb85d965ea925bd05344b5b92dde378f24”);
capabilities.setCapability(“browserName”, “Safari”);
wd = new RemoteWebDriver(new URL(“http://0.0.0.0:4723/wd/hub”),capabilities);

Error Log -
info: Welcome to Appium v1.2.1 (REV 2a4b624a708e580709006b697dc4c9c4e3007863)

info: Appium REST http interface listener started on 0.0.0.0:4723
info: LogLevel: debug

debug: Non-default server args: {“udid”:“4b4f21eb85d965ea925bd05344b5b92dde378f24”,“sessionOverride”:true,“safari”:true,“deviceName”:“iPhone”,“browserName”:“Safari”,“showSimulatorLog”:true,“defaultCommandTimeout”:7200}

info: --> GET /wd/hub/status {}

debug: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}}}

info: <-- GET /wd/hub/status 200 7.711 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}}}

info: --> GET /wd/hub/status {}

debug: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}}}

info: <-- GET /wd/hub/status 200 2.823 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}}}

info: --> POST /wd/hub/session {“desiredCapabilities”:{“platformVersion”:“7.1”,“platformName”:“iOS”,“deviceName”:“iPhone”,“browserName”:“Safari”,“appium-version”:“1.0”,“udid”:“4b4f21eb85d965ea925bd05344b5b92dde378f24”}}

debug: The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version

debug: Configuring Safari session
debug: Using local .zip from command line: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip
debug: Copying local zip to tmp dir

debug: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip copied to /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/appium-app.zip

debug: Unzipping /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/appium-app.zip

debug: Testing zip archive: /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/appium-app.zip

debug: Zip archive tested clean

debug: Unzip successful

debug: Using locally extracted app: /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app

debug: Creating new appium session 523bf749-cc69-4b43-9551-e68924717044

debug: Removing any remaining instruments sockets

debug: Cleaned up instruments socket /tmp/instruments_sock
debug: Setting Xcode folder

debug: Setting Xcode version

debug: Setting iOS SDK Version

info: --> GET /wd/hub/status {}

debug: Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}},“sessionId”:“523bf749-cc69-4b43-9551-e68924717044”}

info: <-- GET /wd/hub/status 200 1.555 ms - 155 {“status”:0,“value”:{“build”:{“version”:“1.2.1”,“revision”:“2a4b624a708e580709006b697dc4c9c4e3007863”}},“sessionId”:“523bf749-cc69-4b43-9551-e68924717044”}

debug: iOS SDK Version set to 7.1

info: Will try to parse the plist file as XML

debug: Detecting automation tracetemplate
debug: Not auto-detecting udid, running on sim
error: Could not parse plist file (as binary) at /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/en.lproj/Localizable.strings
parseFileSync() is deprecated. Use parseStringSync() instead.
error: Could not parse plist file (as XML) at /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/en.lproj/Localizable.strings
debug: Not setting locale because we’re using a real device
debug: Creating instruments
debug: Preparing uiauto bootstrap
debug: Dynamic bootstrap dir: /Users/jitendrakumar/Library/Application Support/appium/bootstrap
debug: Dynamic env: {“nodePath”:"/Applications/Appium.app/Contents/Resources/node/bin/node",“commandProxyClientPath”:"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js",“instrumentsSock”:"/tmp/instruments_sock",“interKeyDelay”:null}
debug: Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!

#import “/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js”;

bootstrap({
nodePath: “/Applications/Appium.app/Contents/Resources/node/bin/node”,
commandProxyClientPath: “/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js”,
instrumentsSock: “/tmp/instruments_sock”,
interKeyDelay: null,
});
debug: Dynamic bootstrap path: /Users/jitendrakumar/Library/Application Support/appium/bootstrap/bootstrap-3fd3829137e4c5d0.js
debug: Reusing dynamic bootstrap: /Users/jitendrakumar/Library/Application Support/appium/bootstrap/bootstrap-3fd3829137e4c5d0.js
debug: Fixing device was changed from:" iPhone - Simulator - iOS 7.1 " to:“iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1”
debug: Not setting iOS and app preferences since we’re on a real device
debug: Starting iOS device log capture via idevicesyslog

warn: Could not parse app Localizable.strings

debug: Not setting device type since we’re connected to a device

debug: Getting bundle ID from app

debug: Parsed app Info.plist (as binary)
debug: Checking app install status using: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id 4b4f21eb85d965ea925bd05344b5b92dde378f24 --bundle com.bytearc.SafariLauncher

debug: Installing app using cmd: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id 4b4f21eb85d965ea925bd05344b5b92dde378f24 --bundle “/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app”

debug: Cleaning up appium session

error: Failed to start an Appium session, err was: Error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]
debug: Error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:142:10
at ChildProcess.exithandler (child_process.js:652:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)

info: <-- POST /wd/hub/session 500 4732.035 ms - 618

debug: Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ])”,“origValue”:“Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]”},“sessionId”:null}

info: --> GET /wd/hub/status {}

What happens when you try running the install command itself? You may need to change the path to SafariLauncher to the build directory for Appium.

/Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id 4b4f21eb85d965ea925bd05344b5b92dde378f24 --bundle “/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app”

I ran the above commenced from terminal and its getting failed -

Error Log -

Jitendra-Kumars-MacBook-Pro:appium jitendrakumar$ /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id 4b4f21eb85d965ea925bd05344b5b92dde378f24 --bundle “/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app”
[…] Waiting for iOS device to be connected
found device id
[ 0%] Found device (4b4f21eb85d965ea925bd05344b5b92dde378f24), beginning install
[ 5%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app to device
[ 6%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/_CodeSignature to device
[ 7%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/_CodeSignature/CodeResources to device
[ 8%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/AUTHORS to device
[ 9%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/[email protected] to device
[ 11%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Default.png to device
[ 12%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/[email protected] to device
[ 14%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/embedded.mobileprovision to device
[ 16%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/en.lproj to device
[ 17%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/en.lproj/InfoPlist.strings to device
[ 18%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Info.plist to device
[ 19%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/LICENSE to device
[ 20%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/PkgInfo to device
[ 21%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/README.md to device
[ 23%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/ResourceRules.plist to device
[ 24%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/SafariLauncher to device
[ 45%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Settings.bundle to device
[ 46%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Settings.bundle/en.lproj to device
[ 47%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Settings.bundle/en.lproj/Root.strings to device
[ 48%] Copying /var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/11485-5451-3y6j4g/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app/Settings.bundle/Root.plist to device
[ 52%] CreatingStagingDirectory
[ 57%] ExtractingPackage
[ 60%] InspectingPackage
[ 60%] TakingInstallLock
[ 65%] PreflightingApplication
[ 65%] InstallingEmbeddedProfile
[ 70%] VerifyingApplication
AMDeviceInstallApplication failed: -402620395
Jitendra-Kumars-MacBook-Pro:appium jitendrakumar$

Can some body help me to resolve this issue.

can i get any help to fix this issue

Still i am getting same error -

error: Failed to start an Appium session, err was: Error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/114811-7646-1wkwam7/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]

info: <-- POST /wd/hub/session 500 15567.040 ms - 622

debug: Error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/114811-7646-1wkwam7/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:142:10
at ChildProcess.exithandler (child_process.js:652:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
debug: Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/114811-7646-1wkwam7/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ])”,“origValue”:“Unable to install [/var/folders/kq/grpr3fjj1wnch6t8zyd6rg5m0000gp/T/114811-7646-1wkwam7/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [4b4f21eb85d965ea925bd05344b5b92dde378f24]. Error [Error: Command failed: ]”},“sessionId”:null}

You can use WebView app instead of safari browser. Because safari browser is frequently getting failed due to instrumentation crashed…

  1. download webview application

  2. launch the application

  3. using getcontexthandles method to get the handles and switch to webview.

sample code —switch to webview and native application

// java
// assuming we have a set of capabilities
driver = new AppiumDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Set contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1
}
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1

//do some web testing
String myText = driver.findElement(By.cssSelector(".green_button")).click();

driver.context(“NATIVE_APP”);

// do more native testing if we want

driver.quit();
Test Automation

try to install / launch SafariLauncher from xcode to your device. Is the application signed? is your device in developer mode?

Hi @siva_sankar_s,
Could you please give some more information on the webview application?
Sure it is available for iOS?

Thanks,
Shiran