2013-04-30 126 views
2

我試着去寫一個負責任的網站測試,我想寫像這樣一個步驟:集瀏覽器窗口大小

Given I am in the desktop view 

Given I am in the mobile view 

我怎樣才能做到這一點在生菜?

我找到了this answer,但我不知道該插入哪裏,或者如果這是最好的做法。任何幫助將非常感激。

回答

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])