菜鸟教程小白 发表于 2022-12-13 14:13:08

ios - 如何将 ruby​​ 中的随机字符串传递给 iOS 应用程序?


                                            <p><p>我正在使用 Frank 来自动化 iPhone,到目前为止效果很好。我正在尝试为用户名创建一个随机字符串,并将随机字符串连接到步骤定义中的电子邮件。我需要将它传递给 iOS 应用程序中的文本字段元素。这是我目前所拥有的:</p>

<pre><code>def generate_random_string(length=6)
    string = &#34;&#34;
    chars = (&#34;a&#34;..&#34;z&#34;).to_a
    length.times do
    string &lt;&lt; chars
end
string
end

Given /^I generate a username$/ do
   globalVariableName = Rand.rand(10)  + &#34;@test.email.com&#34;
end
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这既是一个 cucumber 问题,也是一个弗兰克问题。听起来你在问hw</p>

<p>首先,您需要将生成的用户名保存在可用于其他步骤的位置。您可以通过将其分配给成员变量来做到这一点。</p>

<pre><code>Given /^I generate a username$/ do
@username = Rand.rand(10)+ &#34;@test.email.com&#34;
end
</code></pre>

<p>现在您可以在另一个步骤中引用该变量。这是一个步骤,它将在 UI 中找到带有所需占位符的文本字段,点击它,然后在该字段中键入先前分配的用户名。</p>

<pre><code>When /^I enter my username into the username field$/ do
text_field_selector = &#34;view:&#39;UITextField&#39; placeholder:&#39;username&#39;&#34;
touch( text_field_selector )
type_into_keyboard( @username )
end
</code></pre>

<p>显然,您可能希望根据指定要输入的字段的最佳方法来更改该选择器。 </p>

<p>请注意,我正在使用 <code>type_into_keyboard</code> 辅助方法,该方法仅在最新版本的 Frank 中可用。如果需要,请升级。</p>

<p>希望对您有所帮助。坦率的邮件列表也是获得支持的好地方 - <a href="https://groups.google.com/group/frank-discuss" rel="noreferrer noopener nofollow">https://groups.google.com/group/frank-discuss</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何将 ruby​​ 中的随机字符串传递给 iOS 应用程序?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/11007258/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/11007258/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何将 ruby​​ 中的随机字符串传递给 iOS 应用程序?