ios - Appium 错误 : start point is not within the bounds of the screen

标签 ios webdriver appium saucelabs

我正在尝试使用 Appium(通过 SauceLabs)在 iOS 上运行 Web 应用程序的自动化测试,但在下面详述的相对简单的测试用例中遇到了问题。

我在 Appium 日志中收到以下错误:

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"}

查看屏幕截图,有问题的元素确实出现在屏幕上。

在尝试使用以下方法单击它之前,我尝试滚动到该元素:

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

并通过 javascript 滚动到它似乎没有任何区别。似乎是某组坐标被搞乱了,但我对 Appium 的工作原理了解不够,无法弄清楚。

测试

我创建了一个 jsFiddle HERE (view-only here ) 测试指向。 它具有一组布局在页面下方的字段。

我正在设置具有如下功能的网络驱动程序:

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"); 

WebDriver 测试本身(用 C# 编写)如下所示:

    [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();
            }
        }
    }

您可以看到需要单击“序列”字段。只是尝试不同组合的一种方式。

为了说明问题,以下组合失败:

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

而这些很好:

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

非常感谢任何帮助。

(日志)

Appium 日志的(希望)相关部分在这里:

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"}

最佳答案

我无法重现您的错误,请尝试更新到 Appium v​​1.1 或 1.2。 Sauce Labs 现在默认为 v0.18。

您可以通过添加以下功能来更改 Sauce Labs 上的 appium 版本:

appium-version: '1.1'

此外,我使用 value 而不是 keys 来输入输入字段。不确定在 C# 中转换成什么

我使用了 javascript,但这是一个有效的 gist

关于ios - Appium 错误 : start point is not within the bounds of the screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23939844/

相关文章:

objective-c - iOS - 如何使用无序的 CGPoints 绘制特定的 CGPath

ios - 如何快速以全屏模式打开 VLC

ios - Swift 3 协议(protocol)和委托(delegate)方法?

unit-testing - -Djava.net.preferIPv4Stack=true 在 jmeter 中添加这个?

ios - 使用 Appium 检查时出错

ios - 自定义键盘: get notified when text updates

php webdriver - 等待警报而不终止测试用例

android - 无法在 Android 的对话框中定位元素

用 Eclipse 编写的 Java 代码无法使用 TESTNG 运行(尝试使用 Eclipse 和 Appium for Android Emulator 进行自动化测试)

java - visibilityOfElementLocated 与 presenceOfElementLocated 的性能(selenium webdriver - Java)