【问题标题】:Set browser window size in a step一步设置浏览器窗口大小
【发布时间】:2013-04-30 10:37:18
【问题描述】:

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

Given I am in the desktop view

Given I am in the mobile view

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

我找到了this answer,但我不知道在哪里插入它,或者这是否是最好的做法。任何帮助将不胜感激。

【问题讨论】:

    标签: selenium bdd lettuce


    【解决方案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])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-19
      • 1970-01-01
      • 2016-03-07
      • 2015-11-15
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多