2

我正在尝试为响应式网站编写测试,并且我想编写如下步骤:

Given I am in the desktop view

或者

Given I am in the mobile view

我怎样才能在生菜中做到这一点?

我找到了这个答案,但我不知道在哪里插入这个,或者这是否是最好的做法。任何帮助将非常感激。

4

1 回答 1

1

这就是我最终实现这一目标的方式:

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])
于 2013-10-25T08:15:11.963 回答