Selenium python,找不到elemen

2024-04-23 15:36:27 发布

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

我刚刚开始了我的第一个使用python的selenium项目。 我的第一个任务是使用“Sign to chrome”按钮登录到chrome,但是我不能点击它:Sign to chrome button

按钮HTML:

<paper-button class="action-button" role="button" tabindex="0" animated="" aria-disabled="false" elevation="0">
                  Sign in to Chrome
                </paper-button>

这是链接:chrome://settings/people

我试过:

driver = webdriver.Chrome()
driver.find_element_by_class_name('action-button').click()
driver.find_element_by_xpath('//paper-button[@class='action-button']').click()
driver.find_element_by_css_selector('paper-button.action-button').click()

什么都没用。你知道吗

错误:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"paper-button:not([raised]).action-button"}

Tags: tobydriverseleniumbuttonactionelementfind
1条回答
网友
1楼 · 发布于 2024-04-23 15:36:27

请尝试使用AutoIt pip,您可以尝试以下代码:

安装Autoit:

pip install -U pyautoit 

使用以下代码:

from selenium import webdriver
import autoit
driver = webdriver.Chrome()
driver.get("chrome://settings/")
autoit.send('{TAB}{TAB}{ENTER}')

让我知道它是否有效。你知道吗

相关问题 更多 >