小编Sai*_*ita的帖子

如何修复:无法定位元素:方法- XPath

这是我试图自动执行一些点击的网站:

在此输入图像描述

我尝试使用Xpath和单击按钮FullXpath,但仍然没有运气。

这是简单的代码:

w = webdriver.Chrome(executable_path='chromedriver.exe',
                     chrome_options=options)

w.get("https://quillbot.com/")
time.sleep(5)
pasteXpath = "//button[contains(@class,'outlinedPrimary') and .//span[contains(text(),'Paste Text')]]"
element = w.find_element_by_xpath(pasteXpath).click()
Run Code Online (Sandbox Code Playgroud)

但它失败并在控制台中显示以下消息:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="inOutContainer"]/div[2]/div[2]/div/div[1]/div/div/div[1]/div/div/div[2]/div/div/button/span[1]/div"}
Run Code Online (Sandbox Code Playgroud)

请告诉我如何使用 selenium 自动执行此点击。

python selenium xpath

1
推荐指数
1
解决办法
6791
查看次数

标签 统计

python ×1

selenium ×1

xpath ×1