如何在不必在每个功能中调用窗口的情况下始终最大化窗口?

时间:2015-12-07 17:38:16

标签: php selenium phpunit behat mink

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

1 个答案:

答案 0 :(得分:3)

您可以使用背景或功能挂钩。两者的工作方式与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)
{
}

在文档中阅读更多内容: