python - Instapy 错误与 smart_run 第 117 行导致失败

标签 python selenium selenium-webdriver instapy

我正在玩 instapy,我从快速入门中收到以下错误。这是我的错误,我认为 selenium.common.exceptions.WebDriverException: Message: TypeError: browsingContextFn().currentWindowGlobal is null

""" Quickstart script for InstaPy usage """
# imports
from instapy import InstaPy
from instapy import smart_run

# login credentials
insta_username = ''  # <- enter username here
insta_password = ''  # <- enter password here

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                  password=insta_password,
                  headless_browser=False)

with smart_run(session):
    """ Activity flow """
    # general settings
    session.set_relationship_bounds(enabled=True,
                                    delimit_by_numbers=True,
                                    max_followers=4590,
                                    min_followers=45,
                                    min_following=77)

    session.set_dont_include(["friend1", "friend2", "friend3"])
    session.set_dont_like(["pizza", "#store"])

    # activity
    session.like_by_tags(["natgeo"], amount=10)

任何人都可以指出我正确的方向,我是 python 的新手。这是错误摘要。

Traceback (most recent call last):
  File "/Users/computer/Instagrow/urbley.py", line 16, in <module>
    with smart_run(session):
  File "/usr/local/Cellar/python@3.9/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.9/site-packages/instapy/util.py", line 1920, in smart_run
    session.login()
  File "/usr/local/lib/python3.9/site-packages/instapy/instapy.py", line 425, in login
    if not login_user(
  File "/usr/local/lib/python3.9/site-packages/instapy/login_util.py", line 362, in login_user
    dismiss_get_app_offer(browser, logger)
  File "/usr/local/lib/python3.9/site-packages/instapy/login_util.py", line 466, in dismiss_get_app_offer
    offer_loaded = explicit_wait(
  File "/usr/local/lib/python3.9/site-packages/instapy/util.py", line 1784, in explicit_wait
    result = wait.until(condition)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/support/wait.py", line 71, in until
    value = method(self._driver)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/support/expected_conditions.py", line 128, in __call__
    return _element_if_visible(_find_element(driver, self.locator))
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/support/expected_conditions.py", line 415, in _find_element
    raise e
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/support/expected_conditions.py", line 411, in _find_element
    return driver.find_element(*by)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: TypeError: browsingContextFn().currentWindowGlobal is null

最佳答案

转到“.../instapy/util.py”的第 1953 行并将“PFL”更改为“VOEL”。在 Windows 10、python 3.6 上为我工作。

编辑:

换行

显式等待(浏览器,“PFL”,[],记录器,10)

显式等待(浏览器,“VOEL”,[],记录器,10)

关于python - Instapy 错误与 smart_run 第 117 行导致失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65621719/

相关文章:

python - 发送 key 不起作用 selenium webdriver python

java - Selenium 中自动建议下拉菜单的点击值

java - webdrivermanager 是否支持 RemoteWebDriver (Selenium Grid)?

java - Selenium WebDriver 鼠标操作 moveToElement 不会在 Firefox Linux 上引发 mouseout 事件

python - 值错误 : You are trying to load a weight file containing 6 layers into a model with 0

python - 在 jupyter notebook 中水平打印 Quantile 函数的输出

python - 如何在不完全破坏性能的情况下修改 Numba 中的列表?

python - Django TestCase 在测试完成运行后不会销毁测试数据

python - 如何使用selenium python单击 headless (headless)按钮并且按钮内部有div标签?

java - 使用@FindBy时如何实现 'wait'函数?