使用Watir / Selenium,我希望点击“取消”'对话框右上角的按钮,如下所示: dijitDialog 'Cancel'
以下是DOM:
<div class="dijitDialog" role="dialog" aria-labelledby="dijit_Dialog_4_title" id="dijit_Dialog_4" widgetid="dijit_Dialog_4" style="width: 300px; position: absolute; opacity: 1; left: 533px; top: 297px; z-index: 100000;">
<div data-dojo-attach-point="titleBar" class="dijitDialogTitleBar">
<span data-dojo-attach-point="titleNode" class="dijitDialogTitle" id="dijit_Dialog_4_title" role="heading" level="1">Info</span>
- <span data-dojo-attach-point="closeButtonNode"
class="dijitDialogCloseIcon" data-dojo-attach-event="ondijitclick:
onCancel" title="Cancel" role="button" tabindex="-1">
<span data-dojo-attach-point="closeText" class="closeText" title="Cancel">x</span>
</span>
</div>
<div data-dojo-attach-point="containerNode" class="dijitDialogPaneContent"><img src="information.gif" style="vertical-align:bottom"> Approved 1 record(s)</div>
</div>
我认为需要使用类似browser.element(name: "nameOfButton").click
的内容,但我不确定。
任何建议?
答案 0 :(得分:0)
我会尝试:
browser.span(class: 'dijitDialogCloseIcon').click
或
browser.span(data_dojo_attach_point: 'closeButtonNode').click
请注意,根据页面上存在多少个关闭/取消链接,您可能需要将定位器范围限定在对话框(而不是整个浏览器)和/或包含:visible
定位器。