Search code examples
ioswebdriverappiumsaucelabs

Appium Error: start point is not within the bounds of the screen


I'm trying to run automated tests of a web app on iOS using Appium (via SauceLabs) and am getting a problem with a relatively simple test case detailed below.

I get the following error in the Appium Log:

info: [INSTSERVER] Got result from instruments: {"status":17,"value":"start point is not within the bounds of the screen"}
2014-05-29T17:21:01.282Z - info: Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"start point is not within the bounds of the screen"},"sessionId":"47322525-37e0-4f4b-a236-224906d0135c"}

Looking at the screenshots, the element in question does appear to be on the screen.

I've tried scrolling to the element before attempting to click it using:

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView();", driver.FindElement(By.Id(elementId)));

and scrolling to it via javascript doesn't appear to make any difference. It seems to be that some set of coordinates is getting messed up, but I don't know enough about how Appium works to figure it out.

The test

I have created a jsFiddle HERE (view-only here) which the tests point at. It has a set of fields laid out down the page.

I'm setting up the web driver with capabilities like this:

DesiredCapabilities caps = DesiredCapabilities.IPad();
caps.SetCapability(CapabilityType.Platform, "OS X 10.9");
caps.SetCapability(CapabilityType.Version, "7");
caps.SetCapability("device-orientation", "portrait");
caps.SetCapability("nonSyntheticWebClick", "false"); 

The WebDriver test itself (written in C#) looks like:

    [Test]
    public void TestSequence()
    {
        string sequence = "button4,button3,button2";
        var fieldIds = sequence.Split(',');
        foreach (var fieldId in fieldIds)
        {
            Console.Write("{0},", fieldId);
            if (fieldId[0] == 't')
            {
                driver.FindElement(By.Id(fieldId)).SendKeys("1");
            }
            else
            {
                driver.FindElement(By.Id(fieldId)).Click();
            }
        }
    }

You can see that it takes a 'sequence' of fields to be clicked. Just a way of trying out different combinations.

To illustrate the issue, the following combinations fail:

text1,button1,text4,button3
text4,button3
button4,text3,button2
button4,button3,button2

whereas these are fine:

button1,button4,button1,button4,button1
button1,button2,button3,button4

Any help gratefully appreciated.

(The log)

The (hopefully) relevant part of the Appium Log is here:

2014-05-29T17:48:32.074Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element
2014-05-29T17:48:32.074Z - debug: Request received with params: {"using":"id","value":"button4"}
2014-05-29T17:48:32.075Z - info: [REMOTE] Executing 'find_element' atom in default context
2014-05-29T17:48:32.076Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:32.076Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.084Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:32.084Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:32.085Z - info: Responding to client with success: {"status":0,"value":{"ELEMENT":"5000"},"sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}
POST /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element 200 11ms - 112b
2014-05-29T17:48:32.687Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element/5000/click
2014-05-29T17:48:32.687Z - debug: Request received with params: {}
2014-05-29T17:48:32.688Z - info: [REMOTE] Executing 'get_top_left_coordinates' atom in default context
2014-05-29T17:48:32.688Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:32.689Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.712Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:32.712Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:32.712Z - info: [REMOTE] Executing 'get_size' atom in default context
2014-05-29T17:48:32.713Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:32.713Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.731Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:32.731Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:32.732Z - info: Pushing command to appium work queue: "au.getElementsByType('webview')"
2014-05-29T17:48:32.732Z - debug: Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Socket data received (63 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"1"}]}
2014-05-29T17:48:32.879Z - info: Pushing command to appium work queue: "au.getElement('1').rect()"
2014-05-29T17:48:32.879Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:32.879Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.879Z - debug: Sending command to instruments: au.getElement('1').rect()
info: [INSTSERVER] Sending command to instruments: au.getElement('1').rect()
2014-05-29T17:48:32.880Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:32.880Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:32.881Z - debug: [REMOTE] got applicationSentData response
info: [INSTSERVER] Socket data received (108 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"origin":{"x":0,"y":-423},"size":{"width":768,"height":1467}}}
2014-05-29T17:48:32.987Z - info: Converted web coords {"x":351,"y":734}into real coords {"x":275.069387755102,"y":132.2019230769231}
2014-05-29T17:48:32.987Z - info: Pushing command to appium work queue: "au.complexTap({\"x\":275.069387755102,\"y\":132.2019230769231,\"tapCount\":1,\"duration\":0.3,\"touchCount\":1})"
2014-05-29T17:48:32.987Z - debug: Sending command to instruments: au.complexTap({"x":275.069387755102,"y":132.2019230769231,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Sending command to instruments: au.complexTap({"x":275.069387755102,"y":132.2019230769231,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Socket data received (48 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}
2014-05-29T17:48:34.002Z - info: Responding to client with success: {"status":0,"value":"","sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}
POST /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element/5000/click 200 1317ms - 87b
2014-05-29T17:48:34.737Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element
2014-05-29T17:48:34.737Z - debug: Request received with params: {"using":"id","value":"button3"}
2014-05-29T17:48:34.738Z - info: [REMOTE] Executing 'find_element' atom in default context
2014-05-29T17:48:34.738Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:34.738Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:34.748Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:34.749Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:34.749Z - info: Responding to client with success: {"status":0,"value":{"ELEMENT":"5001"},"sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}
POST /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element 200 14ms - 112b
2014-05-29T17:48:35.352Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element/5001/click
2014-05-29T17:48:35.352Z - debug: Request received with params: {}
2014-05-29T17:48:35.352Z - info: [REMOTE] Executing 'get_top_left_coordinates' atom in default context
2014-05-29T17:48:35.353Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:35.353Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.364Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:35.364Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:35.365Z - info: [REMOTE] Executing 'get_size' atom in default context
2014-05-29T17:48:35.365Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:35.365Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.377Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:35.378Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:35.378Z - info: Pushing command to appium work queue: "au.getElementsByType('webview')"
2014-05-29T17:48:35.378Z - debug: Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Socket data received (63 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"2"}]}
2014-05-29T17:48:35.544Z - info: Pushing command to appium work queue: "au.getElement('2').rect()"
2014-05-29T17:48:35.544Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:35.545Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.545Z - debug: Sending command to instruments: au.getElement('2').rect()
info: [INSTSERVER] Sending command to instruments: au.getElement('2').rect()
2014-05-29T17:48:35.547Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:35.547Z - debug: [REMOTE] got applicationSentData response
info: [INSTSERVER] Socket data received (110 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"origin":{"x":0,"y":-137.5},"size":{"width":768,"height":1467}}}
2014-05-29T17:48:35.651Z - info: Converted web coords {"x":351,"y":629}into real coords {"x":275.069387755102,"y":335.4182692307692}
2014-05-29T17:48:35.651Z - info: Pushing command to appium work queue: "au.complexTap({\"x\":275.069387755102,\"y\":335.4182692307692,\"tapCount\":1,\"duration\":0.3,\"touchCount\":1})"
2014-05-29T17:48:35.651Z - debug: Sending command to instruments: au.complexTap({"x":275.069387755102,"y":335.4182692307692,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Sending command to instruments: au.complexTap({"x":275.069387755102,"y":335.4182692307692,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Socket data received (48 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":""}
2014-05-29T17:48:36.634Z - info: Responding to client with success: {"status":0,"value":"","sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}
POST /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element/5001/click 200 1282ms - 87b
2014-05-29T17:48:37.337Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element
2014-05-29T17:48:37.337Z - debug: Request received with params: {"using":"id","value":"button2"}
2014-05-29T17:48:37.337Z - info: [REMOTE] Executing 'find_element' atom in default context
2014-05-29T17:48:37.337Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:37.337Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.355Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:37.355Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:37.355Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:37.356Z - info: Responding to client with success: {"status":0,"value":{"ELEMENT":"5002"},"sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}
POST /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element 200 20ms - 112b
2014-05-29T17:48:37.952Z - debug: Appium request initiated at /wd/hub/session/fc441e9f-8ade-4799-8f87-1653a50a5a49/element/5002/click
2014-05-29T17:48:37.952Z - debug: Request received with params: {}
2014-05-29T17:48:37.952Z - info: [REMOTE] Executing 'get_top_left_coordinates' atom in default context
2014-05-29T17:48:37.952Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:37.953Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.965Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:37.965Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:37.966Z - info: [REMOTE] Executing 'get_size' atom in default context
2014-05-29T17:48:37.966Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:37.967Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.977Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:37.977Z - debug: [REMOTE] got applicationSentData response
2014-05-29T17:48:37.977Z - info: Pushing command to appium work queue: "au.getElementsByType('webview')"
2014-05-29T17:48:37.977Z - debug: Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Sending command to instruments: au.getElementsByType('webview')
info: [INSTSERVER] Socket data received (63 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":[{"ELEMENT":"3"}]}
2014-05-29T17:48:38.132Z - info: Pushing command to appium work queue: "au.getElement('3').rect()"
2014-05-29T17:48:38.132Z - info: [REMOTE] Sending javascript command
2014-05-29T17:48:38.132Z - debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:38.133Z - debug: Sending command to instruments: au.getElement('3').rect()
info: [INSTSERVER] Sending command to instruments: au.getElement('3').rect()
2014-05-29T17:48:38.133Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:38.134Z - debug: [REMOTE] Receiving data from remote debugger
2014-05-29T17:48:38.134Z - debug: [REMOTE] got applicationSentData response
info: [INSTSERVER] Socket data received (110 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"origin":{"x":0,"y":-137.5},"size":{"width":768,"height":1467}}}
2014-05-29T17:48:38.243Z - info: Converted web coords {"x":351,"y":161}into real coords {"x":275.069387755102,"y":-31.331730769230774}
2014-05-29T17:48:38.243Z - info: Pushing command to appium work queue: "au.complexTap({\"x\":275.069387755102,\"y\":-31.331730769230774,\"tapCount\":1,\"duration\":0.3,\"touchCount\":1})"
2014-05-29T17:48:38.243Z - debug: Sending command to instruments: au.complexTap({"x":275.069387755102,"y":-31.331730769230774,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Sending command to instruments: au.complexTap({"x":275.069387755102,"y":-31.331730769230774,"tapCount":1,"duration":0.3,"touchCount":1})
info: [INSTSERVER] Socket data received (99 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":17,"value":"start point is not within the bounds of the screen"}
2014-05-29T17:48:38.902Z - info: Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"start point is not within the bounds of the screen"},"sessionId":"fc441e9f-8ade-4799-8f87-1653a50a5a49"}

Solution

  • I can't recreate your error, try updating to Appium v1.1 or 1.2. Sauce Labs defaults to v0.18 right now.

    You can change the appium version on Sauce Labs by adding the following capability:

    appium-version: '1.1'

    Also, I used value instead of keys to type into the input field. Not sure what that translates to in C#

    I used javascript, but here's a working gist