菜鸟教程小白 发表于 2022-12-12 22:26:31

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


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

<p>我在 Appium 日志中收到以下错误:</p>

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

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

<p>我在尝试单击之前尝试滚动到该元素:</p>

<pre><code>((IJavaScriptExecutor)driver).ExecuteScript(&#34;arguments.scrollIntoView();&#34;, driver.FindElement(By.Id(elementId)));
</code></pre>

<p>并通过 javascript 滚动到它似乎没有任何区别。似乎是某些坐标被弄乱了,但我对 Appium 的工作原理了解得不够多。</p>

<h3>测试</h3>

<p>我创建了一个 jsFiddle <a href="http://jsfiddle.net/fFFPY/5/" rel="noreferrer noopener nofollow">HERE</a> (仅供查看 <a href="http://fiddle.jshell.net/fFFPY/5/show/light/" rel="noreferrer noopener nofollow">here</a> )测试指向。
它有一组列在页面下方的字段。</p>

<p>我正在设置具有以下功能的网络驱动程序:</p>

<pre><code>DesiredCapabilities caps = DesiredCapabilities.IPad();
caps.SetCapability(CapabilityType.Platform, &#34;OS X 10.9&#34;);
caps.SetCapability(CapabilityType.Version, &#34;7&#34;);
caps.SetCapability(&#34;device-orientation&#34;, &#34;portrait&#34;);
caps.SetCapability(&#34;nonSyntheticWebClick&#34;, &#34;false&#34;);
</code></pre>

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

<pre><code>   
    public void TestSequence()
    {
      string sequence = &#34;button4,button3,button2&#34;;
      var fieldIds = sequence.Split(&#39;,&#39;);
      foreach (var fieldId in fieldIds)
      {
            Console.Write(&#34;{0},&#34;, fieldId);
            if (fieldId == &#39;t&#39;)
            {
                driver.FindElement(By.Id(fieldId)).SendKeys(&#34;1&#34;);
            }
            else
            {
                driver.FindElement(By.Id(fieldId)).Click();
            }
      }
    }
</code></pre>

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

<p>为了说明问题,以下组合失败:</p>

<pre><code>text1,button1,text4,button3
text4,button3
button4,text3,button2
button4,button3,button2
</code></pre>

<p>这些都很好:</p>

<pre><code>button1,button4,button1,button4,button1
button1,button2,button3,button4
</code></pre>

<p>感谢任何帮助。</p>

<h3>(日志)</h3>

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

<pre><code>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: {&#34;using&#34;:&#34;id&#34;,&#34;value&#34;:&#34;button4&#34;}
2014-05-29T17:48:32.075Z - info: Executing &#39;find_element&#39; atom in default context
2014-05-29T17:48:32.076Z - info: Sending javascript command
2014-05-29T17:48:32.076Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.084Z - debug: Receiving data from remote debugger
2014-05-29T17:48:32.084Z - debug: got applicationSentData response
2014-05-29T17:48:32.085Z - info: Responding to client with success: {&#34;status&#34;:0,&#34;value&#34;:{&#34;ELEMENT&#34;:&#34;5000&#34;},&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
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: Executing &#39;get_top_left_coordinates&#39; atom in default context
2014-05-29T17:48:32.688Z - info: Sending javascript command
2014-05-29T17:48:32.689Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.712Z - debug: Receiving data from remote debugger
2014-05-29T17:48:32.712Z - debug: got applicationSentData response
2014-05-29T17:48:32.712Z - info: Executing &#39;get_size&#39; atom in default context
2014-05-29T17:48:32.713Z - info: Sending javascript command
2014-05-29T17:48:32.713Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.731Z - debug: Receiving data from remote debugger
2014-05-29T17:48:32.731Z - debug: got applicationSentData response
2014-05-29T17:48:32.732Z - info: Pushing command to appium work queue: &#34;au.getElementsByType(&#39;webview&#39;)&#34;
2014-05-29T17:48:32.732Z - debug: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Socket data received (63 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:[{&#34;ELEMENT&#34;:&#34;1&#34;}]}
2014-05-29T17:48:32.879Z - info: Pushing command to appium work queue: &#34;au.getElement(&#39;1&#39;).rect()&#34;
2014-05-29T17:48:32.879Z - info: Sending javascript command
2014-05-29T17:48:32.879Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:32.879Z - debug: Sending command to instruments: au.getElement(&#39;1&#39;).rect()
info: Sending command to instruments: au.getElement(&#39;1&#39;).rect()
2014-05-29T17:48:32.880Z - debug: Receiving data from remote debugger
2014-05-29T17:48:32.880Z - debug: Receiving data from remote debugger
2014-05-29T17:48:32.881Z - debug: got applicationSentData response
info: Socket data received (108 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:{&#34;origin&#34;:{&#34;x&#34;:0,&#34;y&#34;:-423},&#34;size&#34;:{&#34;width&#34;:768,&#34;height&#34;:1467}}}
2014-05-29T17:48:32.987Z - info: Converted web coords {&#34;x&#34;:351,&#34;y&#34;:734}into real coords {&#34;x&#34;:275.069387755102,&#34;y&#34;:132.2019230769231}
2014-05-29T17:48:32.987Z - info: Pushing command to appium work queue: &#34;au.complexTap({\&#34;x\&#34;:275.069387755102,\&#34;y\&#34;:132.2019230769231,\&#34;tapCount\&#34;:1,\&#34;duration\&#34;:0.3,\&#34;touchCount\&#34;:1})&#34;
2014-05-29T17:48:32.987Z - debug: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:132.2019230769231,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:132.2019230769231,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Socket data received (48 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:&#34;&#34;}
2014-05-29T17:48:34.002Z - info: Responding to client with success: {&#34;status&#34;:0,&#34;value&#34;:&#34;&#34;,&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
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: {&#34;using&#34;:&#34;id&#34;,&#34;value&#34;:&#34;button3&#34;}
2014-05-29T17:48:34.738Z - info: Executing &#39;find_element&#39; atom in default context
2014-05-29T17:48:34.738Z - info: Sending javascript command
2014-05-29T17:48:34.738Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:34.748Z - debug: Receiving data from remote debugger
2014-05-29T17:48:34.749Z - debug: got applicationSentData response
2014-05-29T17:48:34.749Z - info: Responding to client with success: {&#34;status&#34;:0,&#34;value&#34;:{&#34;ELEMENT&#34;:&#34;5001&#34;},&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
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: Executing &#39;get_top_left_coordinates&#39; atom in default context
2014-05-29T17:48:35.353Z - info: Sending javascript command
2014-05-29T17:48:35.353Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.364Z - debug: Receiving data from remote debugger
2014-05-29T17:48:35.364Z - debug: got applicationSentData response
2014-05-29T17:48:35.365Z - info: Executing &#39;get_size&#39; atom in default context
2014-05-29T17:48:35.365Z - info: Sending javascript command
2014-05-29T17:48:35.365Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.377Z - debug: Receiving data from remote debugger
2014-05-29T17:48:35.378Z - debug: got applicationSentData response
2014-05-29T17:48:35.378Z - info: Pushing command to appium work queue: &#34;au.getElementsByType(&#39;webview&#39;)&#34;
2014-05-29T17:48:35.378Z - debug: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Socket data received (63 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:[{&#34;ELEMENT&#34;:&#34;2&#34;}]}
2014-05-29T17:48:35.544Z - info: Pushing command to appium work queue: &#34;au.getElement(&#39;2&#39;).rect()&#34;
2014-05-29T17:48:35.544Z - info: Sending javascript command
2014-05-29T17:48:35.545Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:35.545Z - debug: Sending command to instruments: au.getElement(&#39;2&#39;).rect()
info: Sending command to instruments: au.getElement(&#39;2&#39;).rect()
2014-05-29T17:48:35.547Z - debug: Receiving data from remote debugger
2014-05-29T17:48:35.547Z - debug: got applicationSentData response
info: Socket data received (110 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:{&#34;origin&#34;:{&#34;x&#34;:0,&#34;y&#34;:-137.5},&#34;size&#34;:{&#34;width&#34;:768,&#34;height&#34;:1467}}}
2014-05-29T17:48:35.651Z - info: Converted web coords {&#34;x&#34;:351,&#34;y&#34;:629}into real coords {&#34;x&#34;:275.069387755102,&#34;y&#34;:335.4182692307692}
2014-05-29T17:48:35.651Z - info: Pushing command to appium work queue: &#34;au.complexTap({\&#34;x\&#34;:275.069387755102,\&#34;y\&#34;:335.4182692307692,\&#34;tapCount\&#34;:1,\&#34;duration\&#34;:0.3,\&#34;touchCount\&#34;:1})&#34;
2014-05-29T17:48:35.651Z - debug: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:335.4182692307692,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:335.4182692307692,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Socket data received (48 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:&#34;&#34;}
2014-05-29T17:48:36.634Z - info: Responding to client with success: {&#34;status&#34;:0,&#34;value&#34;:&#34;&#34;,&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
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: {&#34;using&#34;:&#34;id&#34;,&#34;value&#34;:&#34;button2&#34;}
2014-05-29T17:48:37.337Z - info: Executing &#39;find_element&#39; atom in default context
2014-05-29T17:48:37.337Z - info: Sending javascript command
2014-05-29T17:48:37.337Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.355Z - debug: Receiving data from remote debugger
2014-05-29T17:48:37.355Z - debug: Receiving data from remote debugger
2014-05-29T17:48:37.355Z - debug: got applicationSentData response
2014-05-29T17:48:37.356Z - info: Responding to client with success: {&#34;status&#34;:0,&#34;value&#34;:{&#34;ELEMENT&#34;:&#34;5002&#34;},&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
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: Executing &#39;get_top_left_coordinates&#39; atom in default context
2014-05-29T17:48:37.952Z - info: Sending javascript command
2014-05-29T17:48:37.953Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.965Z - debug: Receiving data from remote debugger
2014-05-29T17:48:37.965Z - debug: got applicationSentData response
2014-05-29T17:48:37.966Z - info: Executing &#39;get_size&#39; atom in default context
2014-05-29T17:48:37.966Z - info: Sending javascript command
2014-05-29T17:48:37.967Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:37.977Z - debug: Receiving data from remote debugger
2014-05-29T17:48:37.977Z - debug: got applicationSentData response
2014-05-29T17:48:37.977Z - info: Pushing command to appium work queue: &#34;au.getElementsByType(&#39;webview&#39;)&#34;
2014-05-29T17:48:37.977Z - debug: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Sending command to instruments: au.getElementsByType(&#39;webview&#39;)
info: Socket data received (63 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:[{&#34;ELEMENT&#34;:&#34;3&#34;}]}
2014-05-29T17:48:38.132Z - info: Pushing command to appium work queue: &#34;au.getElement(&#39;3&#39;).rect()&#34;
2014-05-29T17:48:38.132Z - info: Sending javascript command
2014-05-29T17:48:38.132Z - debug: Sending _rpc_forwardSocketData: message to remote debugger
2014-05-29T17:48:38.133Z - debug: Sending command to instruments: au.getElement(&#39;3&#39;).rect()
info: Sending command to instruments: au.getElement(&#39;3&#39;).rect()
2014-05-29T17:48:38.133Z - debug: Receiving data from remote debugger
2014-05-29T17:48:38.134Z - debug: Receiving data from remote debugger
2014-05-29T17:48:38.134Z - debug: got applicationSentData response
info: Socket data received (110 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:0,&#34;value&#34;:{&#34;origin&#34;:{&#34;x&#34;:0,&#34;y&#34;:-137.5},&#34;size&#34;:{&#34;width&#34;:768,&#34;height&#34;:1467}}}
2014-05-29T17:48:38.243Z - info: Converted web coords {&#34;x&#34;:351,&#34;y&#34;:161}into real coords {&#34;x&#34;:275.069387755102,&#34;y&#34;:-31.331730769230774}
2014-05-29T17:48:38.243Z - info: Pushing command to appium work queue: &#34;au.complexTap({\&#34;x\&#34;:275.069387755102,\&#34;y\&#34;:-31.331730769230774,\&#34;tapCount\&#34;:1,\&#34;duration\&#34;:0.3,\&#34;touchCount\&#34;:1})&#34;
2014-05-29T17:48:38.243Z - debug: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:-31.331730769230774,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Sending command to instruments: au.complexTap({&#34;x&#34;:275.069387755102,&#34;y&#34;:-31.331730769230774,&#34;tapCount&#34;:1,&#34;duration&#34;:0.3,&#34;touchCount&#34;:1})
info: Socket data received (99 bytes)
info: Socket data being routed for &#39;cmd&#39; event
info: Got result from instruments: {&#34;status&#34;:17,&#34;value&#34;:&#34;start point is not within the bounds of the screen&#34;}
2014-05-29T17:48:38.902Z - info: Responding to client with error: {&#34;status&#34;:17,&#34;value&#34;:{&#34;message&#34;:&#34;An error occurred while executing user supplied JavaScript.&#34;,&#34;origValue&#34;:&#34;start point is not within the bounds of the screen&#34;},&#34;sessionId&#34;:&#34;fc441e9f-8ade-4799-8f87-1653a50a5a49&#34;}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我无法重现您的错误,请尝试更新到 Appium v​​1.1 或 1.2。 Sauce Labs 目前默认为 v0.18。</p>

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

<p><code>appium 版本:'1.1'</code></p>

<p>另外,我使用 <code>value</code> 而不是 <code>keys</code> 来输入输入字段。不知道这在 C# 中是什么意思</p>

<p>我使用了 javascript,但这是一个有效的 <a href="https://gist.github.com/149fe33b4776ca7fb853" rel="noreferrer noopener nofollow">gist</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Appium 错误 : start point is not within the bounds of the screen,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/23939844/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/23939844/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Appium 错误 : start point is not within the bounds of the screen