首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么instapy找不到元素xpath

为什么instapy找不到元素xpath
EN

Stack Overflow用户
提问于 2020-11-27 04:21:20
回答 1查看 189关注 0票数 0

我为一个测试机器人执行了这段代码,我得到了这个错误,我不知道我必须做什么?

代码语言:javascript
复制
from instapy import InstaPy

session = InstaPy(username="<your_username>", password="<your_password>")
session.login()
session.like_by_tags(["bmw", "mercedes"], amount=5)
session.set_dont_like(["naked", "nsfw"])
session.set_do_follow(True, percentage=50)
session.set_do_comment(True, percentage=50)
session.set_comments(["Nice!", "Sweet!", "Beautiful :heart_eyes:"])
session.end()

错误:

代码语言:javascript
复制
File "c:/Users/omid/Desktop/New folder/instaPy.py", line 4, in <module>
    session.login()
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\instapy\instapy.py", line 366, in login
    if not login_user(self.browser,
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\instapy\login_util.py", line 203, in login_user
    login_elem = browser.find_element_by_xpath(
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\omid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in 
check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//article//a[text()='Log in']"}
  (Session info: chrome=87.0.4280.66)
  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.18363 x86_64)
EN

回答 1

Stack Overflow用户

发布于 2020-11-27 05:53:11

您的主要问题是您正在使用的二进制文件版本之间的incompatibility,如下所示:

您正在使用chromedriver=2.44

  • Release
  • 的笔记中明确提到了以下内容:

支持Chrome v69-71

您正在使用chrome=87.0.4280.66

  • Release
  • 的笔记中明确提到了以下内容:

支持Chrome版本87

因此,ChromeDriver v2.44和Chrome浏览器v85.0之间存在明显的不匹配

解决方案

确保:

  • Selenium升级到最新发布的level.
  • Chrome更新到最新的ChromeChrome87.0版本。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65028764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档