【发布时间】:2020-05-02 02:27:45
【问题描述】:
<div id="RadWindowWrapper_alert1579252675818" class="RadWindow RadWindow_Metro rwNormalWindow rwTransparentWindow" unselectable="on" style="width: 398px; height: 148px; position: absolute; transform: none; backface-visibility: visible; touch-action: none; visibility: visible; left: 84px; top: 113px; z-index: 3012;"><table cellspacing="0" cellpadding="0" class="rwTable" style="height: 148px;"><tbody><tr class="rwTitleRow"><td class="rwCorner rwTopLeft"> </td><td class="rwTitlebar" style="cursor: move;"><div class="rwTopResize"><!-- / --></div><table align="left" cellspacing="0" cellpadding="0" class="rwTitlebarControls"><tbody><tr><td style="width: 16px;"><a class="rwIcon"></a></td><td><em unselectable="on" style="width: 318px;">Automax Message</em></td><td nowrap="" style="white-space: nowrap;"><ul class="rwControlButtons" style="width: 32px;"><li><a href="javascript:void(0);" class="rwCloseButton" title="Close"><span>Close</span></a></li></ul></td></tr></tbody></table></td><td class="rwCorner rwTopRight"> </td></tr><tr class="rwContentRow"><td class="rwCorner rwBodyLeft"> </td><td class="rwWindowContent" valign="top"><iframe name="alert1579252675818" src="javascript:'<html></html>';" frameborder="0" style="width: 100%; height: 100%; border: 0px; display: none;"></iframe><div id="alert1579252675818_content" style="">
<div class="rwDialogPopup radalert" style="background-image: url("../Images/InteractionImages/AutomaxSuccess.png");">
<div class="rwDialogText" id="alert1579252675818_message">
Location added successfully<br><br>
</div>
<div>
<a onclick="$find('alert1579252675818').close(true);" class="rwPopupButton" href="javascript:void(0);" tabindex="-1">
<span class="rwOuterSpan">
<span class="rwInnerSpan">Ok</span>
</span>
</a>
</div>
</div>
</div></td><td class="rwCorner rwBodyRight"> </td></tr><tr class="rwStatusbarRow" style="display: none;"><td class="rwCorner rwBodyLeft"> </td><td class="rwStatusbar"><table align="left" cellspacing="0" cellpadding="0" style="width: 100%;"><tbody><tr><td style="width: 100%;"><input id="alert1579252675818_status" readonly="" unselectable="on" tabindex="-1"><label for="alert1579252675818_status" style="display: none;">status label</label></td></tr></tbody></table></td><td class="rwCorner rwBodyRight"> </td></tr><tr class="rwFooterRow"><td class="rwCorner rwFooterLeft"> </td><td class="rwFooterCenter"> </td><td class="rwCorner rwFooterRight"> </td></tr></tbody></table></div>
- “确定”按钮消息的详细 HTML 标记。
- name="alert1579246138835" 在刷新页面时发生变化。
- 用于弹出/警报的 HTML 在页面上存在/可见
【问题讨论】:
-
不要查看整个
driver,寻找以rwDialogText为父元素的span元素 -
您是否尝试过直接引用“确定”按钮?检查 Chrome 上的元素,复制 xPath?
-
@DeaneKane 也试过了
-
你可以试试 xpath "//span[.='Ok']"
-
@Jayaram Ganeshan 请不要忘记标记解决您问题的答案。见:stackoverflow.com/help/someone-answers
标签: java selenium xpath css-selectors webdriverwait