iOS safari automation on real device

Hi,
I’m trying to automate safari browser and i’m able to do it with simulator. However on real device it’s not working. I have used appium server 1.3.5, 1.4.8, 1.4.13 and 1.5.0-beta8. I have gone through the issues on this forum as well as on git issue log. Didn’t helped much.
Execution steps:

  1. launch ios-webkit-debug-proxy from terminal(installed via brew)
  2. Start server with appium --safari
  3. Run script from intelliJ as testNG test.
  4. Safari launcher gets installed.
  5. Safari browser gets launched and apple.com opens.
  6. Fails in getting webview.
    serverlog
    @Priyank_Shah @Hassan_Radi @amitjaincoer191

let me know if some body got it working on real device.

Hi

Have you started .ios-webkit-debug-proxy-launcher.js
I think this is the issue here

Updated the steps.
I have started ios-webkit-debug-proxy from terminal which is installed using brew.
PS. i’m able to inspect after starting the ios-webkit-debug-proxy at http://localhost:9222/devtools/devtools.html?ws=localhost:9222/devtools/page/1

Do i need to start it only from js file???

Start ios-Webkit with your device UDID and default port 27753

For example:

ios_webkit_debug_proxy -c UDID_of_device:27753

Hope it help

@pr4bh4sh

Perform below steps:

  1. Launch ios_webkit_debug_proxy:
    ios_webkit_debug_proxy -c <UDID>:27753 -d
  2. Launch appium
  3. Switch to web view before using driver.get(“URL”);

Thanks,
Priyank Shah

1 Like

@Priyank_Shah Thank you so much, finally it’s done.

@pr4bh4sh @Priyank_Shah @Mani_Maran_Chandraba I am getting the following error in appium Console while try to run the safari browser inn real devices. I can launch successfully in Simulators:

error: Failed to start an Appium session, err was: Error: ENOENT, stat ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip’

info: *************************************
info: *************************************
info: [debug] Configuring Safari session
info: [debug] Using local .zip from command line: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip
info: [debug] Copying local zip to tmp dir
info: [debug] Got configuration error, not starting session
info: [debug] Cleaning up appium session
info: [debug] Error: ENOENT, stat ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip’
at Error (native)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: ENOENT, stat ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip’)”,“errno”:-2,“code”:“ENOENT”,“path”:"/Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip",“origValue”:“ENOENT, stat ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/build/SafariLauncher/SafariLauncher.zip’”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 2.984 ms - 498

I guess, you are using appium GUI, i really no idea whether safari launcher app is builded locally while installing Appium GUI. Can u please tried to do same things using appium’s non-GUI (from source or via nam version).

Thanks,
Priyank Shah

@Priyank_Shah I have done the following:

  1. Started os_webkit_debug_proxy -c af5020497b55d10f41a88c488051a85927765a08:27753

Output: Connected :27753 to iPod 5 (af5020497b55d10f41a88c488051a85927765a08)

  1. Started appium – safari

Output: info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {“safari”:true}
info: Console LogLevel: debug

  1. I have ran my code:

Getting Error Output:

rror: Failed to start an Appium session, err was: App zip unzipped OK, but we couldn’t find a .app bundle in it. Make sure your archive contains the .app package and nothing else
info: [debug] undefined
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created.”,“origValue”:“App zip unzipped OK, but we couldn’t find a .app bundle in it. Make sure your archive contains the .app package and nothing else”},“sessionId”:null}

Have anything I missed?

Thanks,
Sanoj

can you try with version 1.5.0

npm install -g [email protected]

@Priyank_Shah i got another issue, Same code not working with 8.1.3 which works with 7.1
It’s giving me same previous error. Any thoughts???

may i know which error?

Thanks,
Priyank Shah

Error gist here.

Java stack trace here

Things going on device(iPhone 5 iOS 8.1.3)

  1. Safari Launcher gets installed.
  2. Safari launcher get launched
  3. Safari browser get launched and apple.com get opened.

Java code gist here

P.S. Thanks for the prompt reply.

@pr4bh4sh, the same code i ran on real device (8.4 and 9.2), in both case i was able to launch safari and run your code. Just check that you launch ios_debug_proxy with appropriate UDID along with appium server.

Thanks,
Priyank Shah

Thanks Priyank for the help, I have created a thread here
If you have something to add let me know.