这是我第一次尝试使用 watir-webdriver 进行自动化。当我通过每个测试用例时,我学到了新东西并面临新的挑战。我非常感谢这里的所有问题和答案,因为它对我有很大的帮助。谢谢
我面临着一个新的挑战,它与弹出窗口有关,即使在 stackoverflow 上经历了很多弹出问题之后,我也不太清楚如何解决这个问题。
我还没有编写 watir 代码....只是想弄清楚如何去做。所以请指点一下。
所以我正在尝试创建一个用户配置文件 - 用所有相关信息填写表单并点击创建配置文件按钮。(所有这些都已编码并且工作正常)。单击“创建配置文件”按钮后,会弹出一个弹出窗口,上面有很多表格形式的图像,并带有文本“请点击苹果的图像”。文本是随机生成的——所以我可能会被要求点击飞机而不是苹果。然后我需要点击那个特定的图像。
如何让 watir-webdriver 为我执行此操作?我如何告诉 watir-webdriver 使用弹出窗口,阅读顶部的文本,将其与图像匹配并单击图像?
谢谢。
这是我得到的错误。还包括 watir 代码和 HTML
错误:
ArgumentError: invalid window selector: {:id=>"humanVerificationContainer"}
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir- webdriver/window.rb:15:in `initialize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir- webdriver/has_window.rb:35:in `new'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir- webdriver/has_window.rb:35:in `window'
===============================================================================
$b.window(:id => "humanVerificationContainer").use do
$b.link(:id => "humanVerificationQuestion").click
<div id="humanVerificationContainer" style="position: fixed; z-index: 9999; top: 50px; left: 750.5px; display: block;"><a class="close"></a><div id="humanVerificationQuestion" class="modal">
<h2>Click the picture of an aircraft carrier</h2>
<table>
<tbody><tr>
<td>
<div answer="0" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat -300px 0px; height:100px; width:100px"> </div>
</td>
<td>
<div answer="1" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat 0px -100px; height:100px; width:100px"> </div>
</td>
<td>
<div answer="2" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat 0px -200px; height:100px; width:100px"> </div>
</td>
<td>
<div answer="3" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat -200px -100px; height:100px; width:100px"> </div>
</td>
</tr><tr>
<td>
<div answer="4" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat -300px -400px; height:100px; width:100px"> </div>
</td>
<td>
<div answer="5" class="humanImage" style="float:left; background:url('/images/security_image_tile.png') no-repeat -600px -200px; height:100px; width:100px"> </div>
</td>
<td>