【问题标题】:How do I always maximize the window without having to call it in each function?如何始终最大化窗口而不必在每个函数中调用它?
【发布时间】:2016-03-12 10:06:34
【问题描述】:

JUnit 中,我会在@Before 方法中完成此操作,但在Mink 中我看不到。有谁知道如何为所有测试执行此操作,而不必在每个函数中执行$this->getSession()->maximize()?谢谢

【问题讨论】:

    标签: php selenium phpunit behat mink


    【解决方案1】:

    您可以使用背景或功能挂钩。两者的工作方式都类似于 xUnit 框架中使用的 setUp 方法。

    背景更明确:

    Feature: your feature
    
    Background:
        Given the window is maximized
    
    Scenario: Log in
        Given I press the login button
        Then I should see "logged in"
    

    使用钩子,您可以执行 FeatureContext 方法。也许这样更合适:

    /** @BeforeFeature */
    public static function setupFeature(FeatureEvent $event)
    {
    }
    

    在文档中阅读更多信息:

    【讨论】:

    • 感谢朋友,非常感谢。也感谢您对文档的推荐。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 2011-08-24
    • 2011-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多