Python单击操作

2024-06-09 13:57:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在Stackoverflow或Google上搜索解决方案,但不幸的是,我找不到任何解决方案。 我试图在一个网站上做webscrape,但我不能用Python+Selenium+ChromeWebDriver点击按钮

网站上的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,但在我的情况下,这些似乎都不起作用。 任何帮助都将不胜感激


Tags: div网站seleniumgooglebutton解决方案ngstackoverflow
1条回答
网友
1楼 · 发布于 2024-06-09 13:57:48

你能试试这个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

相关问题 更多 >