我有一个简单的场景:
Scenario: No javascript warning
Given I am on homepage
When I don't have javascript enabled
Then I should see a warning
我将如何用 mink 实现 when 部分?有没有比仅仅测试 noscript 元素更优雅的方法?
到目前为止我的解决方案:
/**
* @When /^I don\'t have javascript enabled$/
*/
public function iDonTHaveJavascriptEnabled()
{
$driver = $this->getSession()->getDriver();
if ($driver instanceof BrowserKitDriver or $driver instanceof GoutteDriver) {
return true;
}
throw new UnsupportedDriverActionException(
'Scenario needs to be tested with a javascript disabled driver',
$driver
);
}
/**
* @Then /^I should see a warning$/
*/
public function iShouldSeeAWarning()
{
$this->assertElementOnPage('noscript');
}
谢谢你的帮助!