我正在尝试为响应式网站编写测试,我想写一个这样的步骤:
Given I am in the desktop view
或
Given I am in the mobile view
我怎样才能在生菜中做到这一点?
我找到了this answer,但我无法弄清楚在哪里插上这个,或者这是最好的事情。任何帮助将不胜感激。
答案 0 :(得分: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])