2

I'm trying to click on an element in a headless browser using the ghost library of python like so:

ghost = Ghost()
USERAGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"

with ghost.start():
    session = Session(ghost, download_images=True, display=True, user_agent=USERAGENT)
    session.load_cookies("cookies.txt", keep_old=False)
    page, rs = session.open("{url-here}", timeout=120)
    session.wait_for_page_loaded(timeout=None)
    assert page.http_status == 200

    while session.exists("#selector"):
        page, rs = ghost.click("#selector")
        session.wait_for_page_loaded(timeout=None)

This returns the error message:

AttributeError: 'Ghost' object has no attribute 'click'

I've also tried:

page, rs = ghost.evaluate("document.getElementByClassName('#selector').click();", expect_loading=True)

Which gives the same error message. What have I done wrong with my use of Ghost?

goose
  • 2,502
  • 6
  • 42
  • 69

0 Answers0