Ghost.py icon indicating copy to clipboard operation
Ghost.py copied to clipboard

How to wait (while the content is playing)?

Open hsch0 opened this issue 8 years ago • 1 comments

ok, I made a program which connects to takes www.forecast.io, fills in the city name click on the animation. then I create a png snapshot. But when the animation started I would like to make a couple of snapshots (e.g. each second) for the different forecast images. the python time.sleep() doesn't work, it seems to pause the complete website..

import ghost
import time

g = ghost.Ghost()
with g.start(wait_timeout=20) as session:
    page, extra_resources = session.open("http://forecast.io/#/f/51.5171,-0.1062")
    if page.http_status == 200:
        print("Good!")
        #print session.content
    # Waits for form search field
    session.wait_for_selector('.location_field')
    session.wait_for_selector('.forecast button')

    session.evaluate("document.getElementsByClassName('location_field')[0].value='Berlin';")
    session.click(".forecast button")
    session.click(".label")
    session.capture_to('forecast.png')
    session.click(".c")
    session.click(".refresh")
    session.wait_for_text("Rome")
    session.capture_to('forecast2.png')
    session.click(".load_animation_small")
    session.wait_for_text("Tomorrow", timeout=120)
    session.capture_to('forecast3.png')
    session.click(".level2")
    session.click(".load_animation_small")
    session.wait_for_text("Tomorrow", timeout=120)
    session.capture_to('forecast4.png')
    time.sleep(1)
    session.capture_to('forecast5.png')
    time.sleep(1)
    session.capture_to('forecast6.png')

hsch0 avatar Dec 30 '15 09:12 hsch0

Does session.sleep(1)not do what you want?

naclander avatar Feb 06 '16 20:02 naclander