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

Safari mobile browser not loading default page / initialURL correctly #6440

Closed
amaricleroberts opened this Issue Apr 27, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@amaricleroberts

amaricleroberts commented Apr 27, 2016

The problem

I am trying to simulate deep linking in an Appium app. To do this, I first open up an iOSDriver that navigates to the desired URL. Then I quit this AppiumDriver without closing the simulator, and open another iOSDriver with the app.

However, the Driver won't load because the initial welcome URL doesn't apply. The simulator opens up Safari and puts the welcome text into the search bar, but it doesn't apply it / hit Enter. The simulator just spins and the Driver can't be created unless I manually hit Enter.

See below.
screen shot 2016-04-27 at 3 59 18 pm

Environment

  • Appium 1.4.16
  • MacBook Pro, running Yosemite 10.10.5
  • Node v1.5.0
  • iOS app being tested
  • iPhone 6, OS 9.2 simulator

Link to Appium logs

Appium log once it eventually times out:
https://gist.github.com/amaricleroberts/3cf32c46d727d0f4dda2692150eefe53

I think the important bit is this, where it appears to try to hit 'Go' in Safari but can't.

info: [debug] Pushing command to appium work queue: "au.getElementByName('Go')"
info: [debug] Sending command to instruments: au.getElementByName('Go')
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: Got new command 7 from instruments: au.getElementByName('Go')
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: evaluating au.getElementByName('Go')
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: evaluation finished
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: Lookup returned [object UIAButton] with the name "Go" (id: 2).
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: responding with:
info: [debug] [INST] 2016-04-27 21:04:28 +0000 Debug: Running system command #8: /usr/local/Cellar/node/5.1.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"2"}}...
info: [debug] Socket data received (38 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"2"}}
info: [debug] Pushing command to appium work queue: "au.tapById('2')"
info: [debug] Sending command to instruments: au.tapById('2')
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: Got new command 8 from instruments: au.tapById('2')
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: evaluating au.tapById('2')
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: UIAButton.tap()
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: UIAButton.scrollToVisible()
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: UIAButton - scrollToVisible cannot be used because this element has no scrollable ancestor.
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: UIAButton - scrollToVisible cannot be used because this element has no scrollable ancestor.
info: [debug] [INST] 2016-04-27 21:04:29 +0000 Debug: UIAButton could not be tapped because the element is not visible
info: [debug] Socket data received (57 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":13,"value":"elementId 2 could not be tapped"}
info: [debug] Navigating to most recently opened webview

Code

DesiredCapabilities desCap = new DesiredCapabilities();

        final URL connectionUrl;
        try {
            connectionUrl = new URL(connectionUrlString);
        } catch (MalformedURLException MUE) {
            throw new RuntimeException("COULD NOT PARSE APPIUM CONNECTION URL");
        }

        desCap.setCapability("platform", platform);
        desCap.setCapability("deviceName", deviceName);
        desCap.setCapability("platformVersion", platformVersion);
        desCap.setCapability("noReset", true);

        switch (platform) {
            case PLATFORM_ANDROID:
                desCap.setCapability("avd", System.getProperty("avd", deviceName));
                desCap.setCapability("androidDeviceReadyTimeout", 180);

                appiumDriver = new AndroidDriver(connectionUrl, desCap);

                break;
            case PLATFORM_IOS:
                desCap.setCapability("autoAcceptAlerts", true);
                desCap.setCapability("sendKeyStrategy", "setValue");

                desCap.setBrowserName("Safari");
                desCap.setCapability("safariInitialUrl", initialUrl);

                int tries = 3;

                while (tries > 0) {
                    try {
                        appiumDriver = new IOSDriver(connectionUrl, desCap);

                        tries = 0;
                    } catch (SessionNotCreatedException e) {
                        System.out.println("Problem encountered while trying to launch appium driver, trying again in 5 seconds...");
                        try {
                            Thread.sleep(5000L);
                            System.out.println("Done sleeping");
                        } catch (InterruptedException ex) {
                           System.out.println(ex);
                        }
                    }

                    tries--;
                }

                break;
            default:
                throw new RuntimeException("UNKNOWN PLATFORM");
        }

appiumDriver.manage().timeouts().implicitlyWait(TIMEOUT_SECONDS, TimeUnit.SECONDS);

appiumDriver.get(initialUrl);

@triager triager added the NeedsTriage label Apr 27, 2016

@imurchie

This comment has been minimized.

Show comment
Hide comment
@imurchie

imurchie Apr 28, 2016

Member

Do you not have the keyboard on? That seems to be why it cannot find the Go button. I will look into catching that error and firing the event some other way.

Member

imurchie commented Apr 28, 2016

Do you not have the keyboard on? That seems to be why it cannot find the Go button. I will look into catching that error and firing the event some other way.

@imurchie

This comment has been minimized.

Show comment
Hide comment
@imurchie

imurchie Apr 28, 2016

Member

It doesn't look like there is anything that can be done. Toggle your keyboard on and it should work.

Member

imurchie commented Apr 28, 2016

It doesn't look like there is anything that can be done. Toggle your keyboard on and it should work.

@scottdixon scottdixon added iOS and removed NeedsTriage labels Apr 28, 2016

@scottdixon

This comment has been minimized.

Show comment
Hide comment
@scottdixon

scottdixon Apr 28, 2016

Contributor

@amaricleroberts please also try Appium 1.5

Contributor

scottdixon commented Apr 28, 2016

@amaricleroberts please also try Appium 1.5

@amaricleroberts

This comment has been minimized.

Show comment
Hide comment
@amaricleroberts

amaricleroberts Apr 29, 2016

Toggling the Software keyboard On on my simulator fixed it. I will upgrade to Appium 1.5 and try that as well.

amaricleroberts commented Apr 29, 2016

Toggling the Software keyboard On on my simulator fixed it. I will upgrade to Appium 1.5 and try that as well.

@qual

This comment has been minimized.

Show comment
Hide comment
@qual

qual Oct 5, 2016

I just struggled with this issue for 2 days until I ended up on this page. When I toggle the software keyword, everything worked well.

I am using Appium 1.5.3 on Mac OS X EL Capitan. So it seems that issue exists in Appium 1.5.3 as well.
Please check if the issue is fixed and provide update. If not fixed, please add it to the list of known issues.

qual commented Oct 5, 2016

I just struggled with this issue for 2 days until I ended up on this page. When I toggle the software keyword, everything worked well.

I am using Appium 1.5.3 on Mac OS X EL Capitan. So it seems that issue exists in Appium 1.5.3 as well.
Please check if the issue is fixed and provide update. If not fixed, please add it to the list of known issues.

@imurchie imurchie referenced this issue Oct 5, 2016

Merged

Add troubleshooting note about Safari keyboard #6947

4 of 9 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment