Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Error: stale element reference #6

@gordonje

Description

@gordonje

This tool is exactly what we need. Thanks so much for sharing your awesome work!

On my first run, here was my initial call:

python scraper.py gordon.je@gmail.com ******** missouri --country US

My console has the following output:

Logging into Facebook
Login succeeded
Finding and fixing top navs
Finding ad class
Processing 30 ads on page 1
Ad 1
Ad 2
Ad 3
Ad 4
Ad 5
...
Ad 28
Ad 29
Ad 30
Processing 900 ads on page 2
Ad 31
Ad 32
Ad 33
...
Ad 64
Ad 65
Ad 66

Then I got the following error:

Traceback (most recent call last):
  File "scraper.py", line 321, in <module>
    headless=not args.headed, wait=args.wait)
  File "scraper.py", line 195, in main
    process_ad_divs(new_ad_divs, len(processed_ad_divs), driver, dirname, ad_limit, wait=wait))
  File "scraper.py", line 74, in process_ad_divs
    screenshot(ad_div, ad_count, dirname, driver)
  File "scraper.py", line 92, in screenshot
    ad_top = ad_div.location['y']
  File "/Users/gordo/.virtualenvs/fb-ad-archive-scraper-r0xfSlVs/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 534, in location
    old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value']
  File "/Users/gordo/.virtualenvs/fb-ad-archive-scraper-r0xfSlVs/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "/Users/gordo/.virtualenvs/fb-ad-archive-scraper-r0xfSlVs/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 314, in execute
    self.error_handler.check_response(response)
  File "/Users/gordo/.virtualenvs/fb-ad-archive-scraper-r0xfSlVs/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: headless chrome=69.0.3497.81)
  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.6 x86_64)

Running Python 3.6.3 on macOS 10.13.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions