Question

Im trying to write tests for a responsive website, and I want to write a step like so:

Given I am in the desktop view

or

Given I am in the mobile view

How can I accomplish this in lettuce?

I've found this answer, but I cant figure out where to plug this, or if this is the best thing to do. Any help would be much appreciated.

Was it helpful?

Solution

This is how I finally accomplished this:

SCREEN_SIZES = {
    "desktop": (1020, 768),
    "tablet": (768, 1024),
    "mobile": (320, 460)
}

@step(ur'I am in the "(?P<breakpoint>(desktop|tablet|mobile))" view')
def set_viewport(step, breakpoint):
    """ Changes the resolution of the window """
    # Set the window size
    world.browser.driver.set_window_size(*SCREEN_SIZES[breakpoint])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top