如何单击waitr中对话框内的按钮

时间:2014-08-06 13:24:59

标签: ruby watir watir-webdriver

我想在单击页面中的按钮后打开的对话框中访问不同的元素。例如,我想检查单选按钮,输入文本,单击按钮,然后关闭对话框窗口。

以下是html代码:

div class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; height: 804.267px;"><iframe width="760px" height="800" frameborder="0" src="/apex/PreInstall_Notes?ContractID=800f00000006SVS&LangCode=USE&Order=False&AccountId=001f000000dea7Z">#document<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> … </head><body><form id="j_id0:j_id31" enctype="application/x-www-form-urlencoded" action="https://c.cs16.visual.force.com/apex/PreInstall_Notes" method="post" name="j_id0:j_id31"><input type="hidden" value="j_id0:j_id31" name="j_id0:j_id31"></input><script> … </script><div class="apexp"><div class="individualPalette"><div class="accountBlock"><div id="j_id0:j_id31:thePageBlock" class="bPageBlock brandSecondaryBrd apexDefaultPageBlock secondaryPalette"><div class="pbHeader"> … </div><div class="pbBody"><span id="j_id0:j_id31:thePageBlock:j_id33"></span><div class="tableHead"> … </div><br></br><span id="j_id0:j_id31:thePageBlock:j_id60"><table class="tableCommon"><tbody><tr> … </tr><tr><td class="lblQuestions"> … </td><td> … </td></tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr id="groupDetailSection" style="display: none;"> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr> … </tr><tr id="AEProvidedFloorPlan_ERB" style="display: none;"> … </tr><tr> … </tr></tbody></table></span></div><div class="pbBottomButtons"> … </div><div class="pbFooter secondaryPalette"> … </div></div></div></div></div><div id="j_id0:j_id31:j_id327"></div></form><span id="ajax-view-state-page-container" style="display: none"> … </span><script type="text/javascript"> … </script><div id="datePicker" class="datePicker"> … </div></body></html></iframe></div></div><div class="ui-widget-overlay" style="width: 1349px; height: 4172px; z-index: 1001;"></div></body></html>

下面是我要在该对话框窗口内单击的按钮的html代码。只想知道如何切换到对话框窗口并对其执行。

td id="j_id0:j_id31:thePageBlock:j_id32" class="pbButton "><input id="j_id0:j_id31:thePageBlock:j_id32:btnSave" class="btn" type="submit" value="Save" name="j_id0:j_id31:thePageBlock:j_id32:btnSave"></input><input id="j_id0:j_id31:thePageBlock:j_id32:btnCancel" class="btn" type="submit" onclick="closePopupWindow();" value="Cancel" name="j_id0:j_id31:thePageBlock:j_id32:btnCancel"></input

1 个答案:

答案 0 :(得分:0)

鉴于HTML,我猜想&#34;对话框窗口&#34;实际上只是主浏览器中的div标签。 div还包括一个iframe,当使用其中的元素时需要明确说明。

尝试:

browser.iframe(:src => /PreInstall_Notes/).button(:id => /btnSave/).click