New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to launch Safari on real device (iOS) #1083
Comments
Additional details: Pavithras-MacBook-Pro:~ pavithrank$ /bin/bash -c 'which node' |
Do we need to get the webviewapp(from github repository) to be installed in the device to launch safari on the real device ? |
Tried launching via SafariLauncher but still same issue. Through xcode I installed the Safarilauncher on the device and safari came up after few seconds delay. Kindly help out, I am stuck up !! |
@PavithraNavaneeth, you have two options:
For both solutions you will have to run the ios-webkit-debug-proxyand build the app using a profile that allows it to be installed on your device. In NO case can you set the app to safari or set the bundle id to com.apple.mobilesafari for a real device. This will not work! |
Sergio, Thanks for your reply !! Note: I have installed safarilauncher in my device via xcode. Also I have run the ios-webkit-debug-proxy.. |
When you build the app through Xcode it will stored on your machine in the ~/Library/Developer/Xcode/DerivedData/ folder. Find your .app file (in the iphoneos folder). Set this file including path as your "app" value. |
Now, I could launch the safarilauncher in the device by providing the app details with path. However after starting the app it is just hanging and not proceeding further at all (I almost waited for more than 3 mts but nothing happened). Here is my code: Note: I couldnt see even my System.println (pausing) in the eclipse console. Also, in appiium console, there were no further logs generated once the safarilauncher was started. Appium logs: info: Appium REST http interface listener started on 127.0.0.1:4723 debug: Appium request initiated at /wd/hub/session debug: Request received with params: {"desiredCapabilities":{"app":"/Users/pavithrank/Library/Developer/Xcode/DerivedData/SafariLauncher-cfrvqexlzffqbndvbwbhmlyvlqah/Build/Products/Debug-iphoneos/SafariLauncher.app","device":"iPad Device","version":"6.1"}} info: Using local app from desiredCaps: /Users/pavithrank/Library/Developer/Xcode/DerivedData/SafariLauncher-cfrvqexlzffqbndvbwbhmlyvlqah/Build/Products/Debug-iphoneos/SafariLauncher.app info: Creating new appium session d60b3df5-c612-462d-a743-f1e3fd121bca info: Cleaned up instruments socket /tmp/instruments_sock debug: No device id or app, not installing to real device. info: Not setting device type since we're connected to a device debug: Creating instruments info: instruments is: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock info: Attempting to run app on real device with UDID UDIDValue info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Appium.app/Contents/Resources/node_modules/appium/app/uiauto/Automation.tracetemplate -w UDIDValue info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/lib/libgenkit.dylib"} info: [INST] 2013-09-03 04:49:24 +0000 Default: Instruments shell user: pavithrank info: [INST] 2013-09-03 04:49:37 +0000 Default: Found node using info: [INSTSERVER] Instruments is ready to receive commands info: Instruments launched. Starting poll loop for new commands. info: Pushing command to appium work queue: "au.bundleId()" debug: Sending command to instruments: au.bundleId() info: [INSTSERVER] Socket data received (15 bytes) info: [INSTSERVER] Socket data being routed for 'cmd' event info: [INST] 2013-09-03 04:49:43 +0000 Default: Got new command 0 from instruments: au.bundleId() |
Try and launch it manually. Does it open safari after e.g 30 seconds? |
Yes it is launching after a delay. Actually even via appium it is launching the safari after some delay but, after that it is stuck. Looks like after launching safari it is not responding back to appium and hence it hangs. Sometimes, when I try to manually launch the safari launcher app (in between during this hung) - it responds back and proceeds further - but not all the time. So, how should I get rid of this - not responding issue? Thanks On 03-Sep-2013, at 12:45 PM, Sergio Neves Barros notifications@github.com wrote:
|
Check in the safariLauncher app if the timeout in the app is set to 20 seconds. If it is change it to 30. I have seen a few threads were this was the problem. Appium needs to be given enough time to determine the app has launched successfully. Once you have safari open and appium ready your switch to window should take over (and make sure you have the ios webkit debug proxy running in the background). Sergio |
In SafariLauncher - I could see the default value startDelay_ = 20; which I changed it to 30; now. Hope this is fine ? info: [INST] 2013-09-03 09:09:27 +0000 Fail: Could not start script, target application is not frontmost. info: [INSTSERVER] Instruments exited with code 0 |
Out of bloom, just one time it proceeded fully. Is it expected to work inconsistent? (or) is there any permanent way out for this.. |
As we are not polling when appium is "ready" but merely guessing, the time-out depends on the speed/power of the machine and device it's running and testing against. So where 20 seconds might work for one machine/device combination another might need 40. A more reliable solution will have to be put in place anyways (e.g. a way for appium to detect that it's safari that has been launched and not throw any errrors at that point.). |
I am confused... actually when the safarilauncher is launching via appium (it approximately takes around 15 to 20 seconds) to launch the browser and to navigate to default url:www.apple.com. And default delay is provided as 30 seconds in safarilauncher - presferences code. With this, I hope it should work - kindly clarify. In my case, after launching the app (within 15 to 20 secs) - it is just hanging. It looks like: Instrument is not responding back - could you please clarify this by checking the below console logs:So, what could be reason for the instrument to get stuck? info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/lib/libgenkit.dylib"} info: [INST] 2013-09-03 04:49:24 +0000 Default: Instruments shell user: pavithrank info: [INST] 2013-09-03 04:49:37 +0000 Default: Found node using which node: /usr/local/bin/node info: [INSTSERVER] Instruments is ready to receive commands info: Instruments launched. Starting poll loop for new commands. info: Pushing command to appium work queue: "au.bundleId()" debug: Sending command to instruments: au.bundleId() info: [INSTSERVER] Socket data received (15 bytes) info: [INSTSERVER] Socket data being routed for 'cmd' event info: [INST] 2013-09-03 04:49:43 +0000 Default: Got new command 0 from instruments: au.bundleId() |
I increased the time to 45 seconds now and built the app. Now, I am consistently getting the below error:"Could not start script, target application is not frontmost." But I could see the safarillauncher.app is launched and ready.. info: Instruments exited with code 1 and trace dir undefined error: Instruments socket client never checked in; timing out info: [INST] 2013-09-04 07:01:39 +0000 Fail: Could not start script, target application is not frontmost. error: Instruments did not launch successfully, failing session |
I think you're better off waiting until this functionality is supported by Appium and using the web view app until then. It's much easier to setup and to run. This functionality is definitely one of the things I would like to pick up in the near future if I can. For now it simply seems to be to unreliable (which is to be expected considering the hard coded wait and how it's trying to "fool" appium, rather then using it properly). |
@snevesbarros, what is necessary to make Appium aware of what's going on here? On Sep 4, 2013, at 1:03 AM, Sergio Neves Barros notifications@github.com wrote:
|
I looked into it a while ago. I think what happens when the app navigates I was looking at how to determine that it was the safari launcher:
If we can stop it at that point the remote debugger can take over. The next thing was to see if we could close our reset the browser (or maybe Sergio
|
What if we detected that (a) the user's app is 'safari' and (b) the user has a UDID therefore wanting to run the test on a real device. In this case we could launch the safari launcher app automatically and know to wait. In other words, we could bundle the safari launcher as part of appium itself and use it as a special case when the user requests 'safari' as the app for a real device. Jonathan On Sep 5, 2013, at 12:08 AM, Sergio Neves Barros notifications@github.com wrote:
|
What about build profile? The user would have to deploy the safari launcher From your description I assume you would want to use the bundled app in Or is it possible to use the bundle id? Sergio
|
It is possible to use the bundle ID alone. So assuming they've got it on their device…. Or we could just have the code for the launcher app in appium itself and build it using xcodebuild and deploy it to the device using your fruitstrap methods On Sep 6, 2013, at 2:22 AM, Sergio Neves Barros notifications@github.com wrote:
|
Kindly let me know when this can be expected to get resolved. Sorry, till then we are stuck up and cannot proceed further. |
@PavithraNavaneeth as mentioned above you can use the web view app (in the sample code) to do your testing until this has been resolved. This is what we are currently using for our browser based tests and it works for viewing and interacting with web pages. Once the solution is in place your tests will require minor tweaks to get them working with Safari. NOTE: The only downside to the web view is it struggles to render e.g. the HTML5 canvas (which works well with Safari), but other than that its fine. |
With webapp view what I noticed manually (also) is I am not able to navigate to any url by typing in the url value in the address bar field. Tap on Go button- doesnt do anything. May be we can change the default url to our app url in webviewapp. But in between the tests we have scenarios to type in the address bar and navigate - which might not work if 'tap on go' doesnt work. |
You dont need the native elements (e.g the go button) to navigate to a page. Simply grab the windhandles switch to the web view and the use the webdriver goto method go navigate to whatever page you want. |
Any idea I am not able to checkout the webviewapp from https://github.com/appium/appium/tree/master/sample-code/apps/WebViewApp Tried git clone https://github.com/appium/appium/tree/master/sample-code/apps/WebViewApp |
Checked out and tested with WebViewApp on ipad. But it is not rendering the UI as expected as in Safari. We have different UI for iphone and ipad and with WebViewApp on ipad - it is showing the iphone UI even with zoomed view (since the webview app is of specific size). Hence it doesn't solve the purpose for us. As of now, I can live with testing only on iphone and ipad Simulators. But kindly resolve the issue with SafariLauncher so that real device testing can be proceeded. |
Our team was quite proactive and innovative and altered the app in a couple of hours. It simply needs a view for ipad which any ios developer can do (and in our case a QA did it). A little pro-activeness goes a long way :) |
Thanks for the suggestion and motivation Sergio :-) Modified the code and got the webviewapp for ipad view and it is running fine for our web app. |
👍 |
Now got issue with iphone. I built the app on iphone - it is launching the webview app. But when driver is trying to get the windowhandles the app is getting killed. Also appium server is also stopped. Here is my code and appium console logs: console logs: info: Creating new appium session 3faf1a30-9134-4500-bb5d-8f002095e2dd debug: Appium request initiated at /wd/hub/session debug: Request received with params: {"desiredCapabilities":{"app":"/Users/pavithrank/Library/Developer/Xcode/DerivedData/WebViewApp-cdpzaddiuzidvvfcbqcaitpceyxv/Build/Products/Debug-iphoneos/WebViewApp.app","device":"iphone device","version":"6.1"}} info: Cleaned up instruments socket /tmp/instruments_sock debug: No device id or app, not installing to real device. info: Not setting device type since we're connected to a device debug: Creating instruments info: instruments is: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Appium.app/Contents/Resources/node_modules/appium/app/uiauto/Automation.tracetemplate -w c320087b32c72ec753434668a811c7046e7be152 /Users/pavithrank/Library/Developer/Xcode/DerivedData/WebViewApp-cdpzaddiuzidvvfcbqcaitpceyxv/Build/Products/Debug-iphoneos/WebViewApp.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/app/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/ info: [INST] 2013-09-12 11:38:58 +0000 Default: Instruments shell user: pavithrank info: [INST] 2013-09-12 11:39:11 +0000 Default: Found node in Appium.app info: [INSTSERVER] Instruments is ready to receive commands debug: Sending command to instruments: au.bundleId() info: Instruments launched. Starting poll loop for new commands. info: [INSTSERVER] Sending command to instruments: au.bundleId() info: [INST] 2013-09-12 11:39:15 +0000 Default: Got new command 0 from instruments: au.bundleId() info: [INST] 2013-09-12 11:39:15 +0000 Default: Result is not protocol compliant, wrapping info: [INSTSERVER] Socket data received (68 bytes) debug: Sending command to instruments: au.setScreenOrientation('PORTRAIT') info: [INSTSERVER] Socket data being routed for 'cmd' event info: [INST] 2013-09-12 11:39:16 +0000 Default: Got new command 1 from instruments: au.setScreenOrientation('PORTRAIT') info: [INSTSERVER] Socket data received (56 bytes) debug: Sending command to instruments: setBootstrapConfig: useLocationServices=true info: [INSTSERVER] Socket data being routed for 'cmd' event info: [INST] 2013-09-12 11:39:16 +0000 Debug: target.setDeviceOrientation("1") info: [INST] 2013-09-12 11:39:17 +0000 Default: Got bootstrap config: useLocationServices=true info: [INST] 2013-09-12 11:39:17 +0000 Default: Set bootstrap config key 'useLocationServices' to true info: [INSTSERVER] Socket data received (56 bytes) info: [INSTSERVER] Socket data being routed for 'cmd' event debug: Appium request initiated at /wd/hub/session/3faf1a30-9134-4500-bb5d-8f002095e2dd POST /wd/hub/session 303 35310ms - 9 debug: Appium request initiated at /wd/hub/session/3faf1a30-9134-4500-bb5d-8f002095e2dd/window_handles error: uncaughtException date=Thu Sep 12 2013 17:08:08 GMT+0530 (IST), pid=95745, uid=502, gid=20, cwd=/Applications/Appium.app/Contents/Resources/node_modules/appium, execPath=/Applications/Appium.app/Contents/Resources/node/bin/node, version=v0.10.15, argv=[/Applications/Appium.app/Contents/Resources/node/bin/node, /Applications/Appium.app/Contents/Resources/node_modules/appium/server.js, --port, 4723, --app, /Users/pavithrank/Library/Developer/Xcode/DerivedData/WebViewApp-cdpzaddiuzidvvfcbqcaitpceyxv/Build/Products/Debug-iphoneos/WebViewApp.app, --udid, c320087b32c72ec753434668a811c7046e7be152, --no-session-override, --keep-artifacts], rss=38674432, heapTotal=31139328, heapUsed=15515376, loadavg=[1.21923828125, 1.3662109375, 1.5498046875], uptime=535738, trace=[column=11, file=net.js, function=errnoException, line=901, method=null, native=false, column=19, file=[as oncomplete] (net.js, function=Object.afterConnect, line=892, method=afterConnect, native=false], stack=[Error: connect ECONNREFUSED, at errnoException (net.js:901:11), at Object.afterConnect as oncomplete] |
Not really sure what the error is related to. Do make sure that the ios-webkit-debug-proxy is running (for the right device) in the background. Verify that your app works manually and is able to navigate to a page etc... |
I am getting the exception exactly when it driver is trying to get the window handles (not while launching the app). Through automation I am able to launch the app in the iphone device (it confirms that I am using the right udid of the device in the background). |
w.r.t iphone device - webinspector in safari settings was not enabled on the phone. Hence it was failing with above error. Now my test runs successfully on iphone device as well with webviewapp. Thanks !! |
we should definitely add this to README/docs/troubleshooting. it's important for both simulator and real device, webview/hybrid/safari support On Sep 17, 2013, at 3:05 PM, PavithraNavaneeth notifications@github.com wrote:
|
Just an update to this actual issue: When I gave sleep for 30 Secs to my selenium code (after launching the driver) + along with increasing the safari launcher delay to 30 sec- it resolved the issue of throwing the error: Could not start script, target application is not frontmost. Now, I have the question of how to close the safari launcher app? From one of the google discussion, Sergio suggested to use https://github.com/appium/appium/blob/master/sample-code/examples/java/testng/src/main/java/com/example/LocalWebDriver.java But when I directly just used mobile: closeapp it didn't work. It is not closing the safari app which is not allowing my next test to launch the safari (unless i restart my device). |
#1244 this fix removes the need for the delay. |
I think the issue here is resolved, also no updates in 2 months. |
Hi I am facing the same issue like safariLauncher is launched successfully but later on it hangs I mean driver.get(myURL) is not opening in the safari. DesiredCapabilities d = new DesiredCapabilities(); d.setCapability("platformName", "iOS");
Please find the logs info: Welcome to Appium v1.2.0 (REV fd2c284) #import "/Users/a041720/Desktop/shaik/appium/node_modules/appium-uiauto/uiauto/bootstrap.js"; bootstrap({ debug: [INST] Instruments Trace Complete (Duration : 14.199546s; Output : /tmp/appium-instruments/instrumentscli0.trace) debug: [INSTSERVER] Instruments exited with code 0 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am trying to test my web on Safari iOS. I am stuckup and not able to proceed: kindly help out!!
I followed the instructions from: https://github.com/appium/appium/blob/master/docs/hybrid.md
My device is connected to MAC.
I started the appium server (0.8.5) (GUI) providing properly UDID with force ipad and use Mobile Safari checked. I didnt provide the bundle id (hope it is not required to start safari on ios)
Here is my test:
Here is my test: Could you please help out resolving this issue..
private static WebDriver driver;
@BeforeTest
public void setUp() throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
First of all when it is instantiating the remotewebdriver, it is launching the ipad simulator (does it launch even when we want to run on device only) opens the safari browser and then throws the below errror in appium console:
info: Welcome to Appium v0.8.5 (REV 3a6720d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: socket.io started
debug: Appium request initiated at /wd/hub/session
info: Trying to use mobile safari, version 6.1
debug: Request received with params: {"desiredCapabilities":{"app":"safari","device":"iPad Device","version":"6.1"}}
info: Looking for built in app MobileSafari
info: Got app, trying to copy to tmp dir
info: Copied MobileSafari to /tmp/Appium-MobileSafari.app
info: Using mobile safari app at /tmp/Appium-MobileSafari.app
info: Cleaning mobile safari data files
info: Determining current user
info: User is pavithrank
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Caches/Snapshots/com.apple.mobilesafari
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Caches/com.apple.mobilesafari/Cache.db*
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Caches/com.apple.WebAppCache/.db
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Safari/.plist
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/WebKit/LocalStorage/.
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Library/WebKit/GeolocationSites.plist
info: Deleting /Users/pavithrank/Library/Application\ Support/iPhone\ Simulator/6.1/Library/Cookies/*.binarycookies
info: Creating new appium session 46bf8f15-a289-4cf7-b7e6-01a95bf67934
info: Cleaned up instruments socket /tmp/instruments_sock
debug: No device id or app, not installing to real device.
info: Not setting device type since we're connected to a device
debug: Creating instruments
info: instruments is: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Attempting to run app on real device with UDID "Actual UDID Value"
info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Appium.app/Contents/Resources/node_modules/appium/app/uiauto/Automation.tracetemplate -w "Actual UDID Value" /tmp/Appium-MobileSafari.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/app/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/lib/libgenkit.dylib"}
info: [INST STDERR] 2013-09-02 15:17:19.705 instruments[29904:1703] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Failed to start trace.
error: Instruments did not launch successfully, failing session
info: [INSTSERVER] Instruments exited with code 253
error: Failed to start an Appium session, err was: Instruments did not launch successfully--please check your app paths or bundle IDs and try again
info: Responding to client with error: {"status":6,"value":{"message":"A session is either terminated or not started","origValue":"Instruments did not launch successfully--please check your app paths or bundle IDs and try again"},"sessionId":"46bf8f15-a289-4cf7-b7e6-01a95bf67934"}
POST /wd/hub/session 500 58075ms - 270
info: Clearing out appium devices
The text was updated successfully, but these errors were encountered: