菜鸟教程小白 发表于 2022-12-12 13:18:57

ios - 使用命令行的 UIAutomation 不起作用


                                            <p><p><strong>这是我在终端中执行的代码:</strong></p>

<pre><code>instruments -w &#39;afb79e6f07256ff94c8d5a11e4db6c26950e2b2d&#39; \
    -t &#39;/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate&#39; \
    &#39;TestAutomation.app&#39; \
    -e UIASCRIPT &#39;/Users/roykronenfeld/Desktop/Automation.js&#39; \
    -e UIARESULTSPATH &#39;/Users/roykronenfeld/Desktop/&#39;
</code></pre>

<p><strong>我得到的错误:</strong></p>

<pre><code>Instruments Usage Error : Specified target process is invalid:
/var/mobile/Applications/51EA888D-9D16-4F7B-919F-68F9C56F0585/TestAutomation.app
</code></pre>

<p>这显然表明应用程序的路径不正确。但是,如果我使用以下代码从 Xcode 中提取该应用程序路径,我不确定它为什么不正确:</p>

<pre><code>NSString *Directory = [ resourcePath];
</code></pre>

<p>有什么想法吗?</p>

<p><em>p.s:该应用已安装在设备上。</em></p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><strong>这是它的工作方式:</strong></p>

<pre><code>instruments -w &#39;fa10dec83c62a571a9691b5d9ef24cc68de73bf0&#39; \
    -t &#39;/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate&#39; \
   TestAutomation \
    -e UIASCRIPT &#39;/Users/roykronenfeld/Desktop/Automation.js&#39; \
    -e UIARESULTSPATH &#39;/Users/roykronenfeld/Desktop‘
</code></pre>

<p>请注意应用名称末尾没有 '' 和 .app 的情况,因为通过命令行在设备上进行自动化操作时,您需要提供的只是应用名称。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 使用命令行的 UIAutomation 不起作用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/27544621/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/27544621/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 使用命令行的 UIAutomation 不起作用