单击该元素,我没有收到任何错误,但弹出窗口(Facebook中的“添加特色照片”弹出窗口)仍然存在.它没有关闭.
这是HTML代码:
<div class="_5lnf uiOverlayFooter _5a8u">
<table class="uiGrid _51mz uiOverlayFooterGrid" cellspacing="0" cellpadding="0">
<tbody>
<tr class="_51mx">
<td class="_51m- prs uiOverlayFooterMessage">
<td class="_51m- uiOverlayFooterButtons _51mw">
<a class="_42ft _4jy0 layerCancel uiOverlayButton _4jy3 _517h _51sy" href="#" role="button">Cancel</a>
<button class="_42ft _4jy0 layerConfirm uiOverlayButton _4jy3 _4jy1 selected _51sy" type="submit" value="1">Save</button>
</td>
</tr>
</tbody>
</table>
</div>
这是我的代码:
driver.find_element_by_xpath(".//button[@class='_42ft _4jy0 layerConfirm uiOverlayButton _4jy3 _4jy1 selected _51sy']")
如何单击“保存”按钮以关闭弹出窗口?非常感谢你 :)
解决方法:
您可以滚动到该按钮,然后再单击它
from selenium.webdriver.common.action_chains import ActionChains
button = driver.find_element_by_xpath(".//button[@class='_42ft _4jy0 layerConfirm uiOverlayButton _4jy3 _4jy1 selected _51sy']")
ActionChains(driver).move_to_element(button).perform()
button.click()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。