【发布时间】:2019-10-17 04:33:33
【问题描述】:
我有一个网页,上面有一个下载文件的按钮。单击按钮后,会出现一个模式对话框弹出窗口,其中没有“确定”或“取消”按钮,它只是显示“生成调试信息文件”的信息对话框。请稍等。'。在我的 ui 测试中,我需要检查该对话框是否存在。此模式对话框的 html 代码如下所示。我应该如何检查对话框的存在?
我尝试过使用 Alert 类并使用 Alert(driver).switch_to.alert() 和 Alert(driver).dismiss() 和 accept()
我也试过了
WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "id_value")))
编辑:编辑以添加实际代码。
该元素的html代码有以下参数:
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable" style="position: fixed; height: auto; width: 400px; top: 143px; left: 555.5px; display: block;" tabindex="-1" role="dialog" aria-describedby="dialog" aria-labelledby="ui-id-1">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-id-1" class="ui-dialog-title">Download debug info</span>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close">
<span class="ui-button-icon-primary ui-icon ui-icon-closethick">
</span>
<span class="ui-button-text">close</span>
</button>
</div>
<div id="dialog" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; max-height: none; height: 177px;">
<br>Generating the debuginfo file. Please wait.</div>
<div class="ui-resizable-handle ui-resizable-n" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-s" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-w" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-sw" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-ne" style="z-index: 90;">
</div>
<div class="ui-resizable-handle ui-resizable-nw" style="z-index: 90;">
</div>
【问题讨论】:
-
用实际的 HTML 更新问题,而不是手工制作的 HTML。
-
添加了实际代码。
-
我可以看到文本下载调试信息和生成调试信息文件。请稍候。但我在您提供的 HTML 中没有看到 your download will begin... 文字。你可以交叉检查一次吗?
-
对不起,我的错。当我第一次发布问题时,我实际上并没有查看代码。再次更新我的问题。
标签: python selenium xpath css-selectors webdriverwait