python - Python Selenium ng-click 动作
问题描述
我一直在 Stackoverflow 或 Google 上寻找解决方案,但不幸的是我找不到任何解决方案。我正在尝试在网站上进行 webscrape,但我无法使用 Python + Selenium + Chrome webdriver 点击按钮。
网站上的 HTML 代码:
<button type="button" ng-click="launch()" title="HTTP/HTTPS: WebSQL">
<div class="flex-column-centered">
<f-icon class="bookmark-icon-large fa-globe" ng-class="TYPE_MAP[bookmark.apptype].icon"></f-icon>
<span class="ng-binding">WebSQL</span>
</div> </button>
我知道那是 AngularJS,我尝试了 CSS 选择器和 Xpath,但这些似乎都不适用于我的情况。任何帮助,将不胜感激!
解决方案
你能试试这个 xpath 吗:
//span[text()='WebSQL']/../..
我建议你有这样的明确等待:
WebDriverWait(driver , 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='WebSQL']/../.."))).click()
进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
推荐阅读
- sql - PostgreSQL - 基于列数的表联合
- python - 如何将对象数据类型从列中分离为多列?
- http - 正确的 HTTP 响应标头
- flutter - 颤振中的“颜色”.dartundefined_named_parameter
- python-3.x - Cloud Composer grpcio Python 包
- php - HTTP Guzzle 未返回所有数据
- python - 在 Scrapy 中调用多个部分链接的请求
- gstreamer - gstreamer,如何忽略 h264 rtsp 流上的错误并继续录制
- c# - 具有多个等待的 WhenAll vs New 对象
- javascript - 开玩笑 - 一些测试在第一次运行时失败,但在第二次和第三次运行时通过