python - 一个接一个地触发点击功能(在模态中)
问题描述
我正在尝试以下内容;它因错误“ Message: element not intractable
”而失败。大概是因为 Python 正试图同时解雇它们。
第一个有效。但是,第二个失败了。我只是尝试sleep
在两者之间使用implicity_wait
。场景是一个接一个的模态对话框。单击第一个“按钮”,第二个模式显示(基本上是确认屏幕)>不会单击该按钮。
self.driver.find_element_by_css_selector("#publishButton").click()
self.driver.implicitly_wait(4)
self.driver.find_element_by_css_selector(".btn-primary").click()
这是标记;我试图访问的第二个按钮。
<button class="btn btn-mini btn-primary" ng-click="save();">Save As Pending</button>
解决方案
尝试 WebDriverWait 和第二个按钮的可见性。
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.btn.btn-mini.btn-primary"))).click()
您需要具有以下导入。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
推荐阅读
- django - Post() 得到了一个意外的关键字参数“用户”
- python - Linux 中脚本文件的非可读/可编辑文件格式
- python - 在 Tensorflow 2.0 中使用我的自定义嵌入层时出错
- java - Junit 测试 5(例外)
- c++ - 与在 C++ 中使用 push_back 相比,声明具有大小的向量是否提供任何改进
- java - 如何使用 MongoDB Java 更新文档并设置字段的值?
- rust - 如何处理 Rust 中的循环闭包调用?
- django - 有什么办法可以强制 django 在退出前运行一些整理代码?
- sql-server - 如何在同一行中创建两个不同的值
- angular - 我正在将 Angular 版本从 7 更新到 8。但出现对等依赖错误