0
使我有一個簡單的場景:測試的警告,如果JavaScript的不貝哈特/水貂
Scenario: No javascript warning
Given I am on homepage
When I don't have javascript enabled
Then I should see a warning
我將如何實現與貂當一部分?有沒有比測試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');
}
感謝您的幫助!
謝謝,如何實現它的訪問者是明確的,但我想測試它... – ottsch
我明白了..你可以有一些Ajax表單提交,如果它啓用?例如更新會話值爲true?我不熟悉behat或mink自己。 – Dale
是的......問題在於如何讓水貂表現得像沒有啓用JavaScript一樣...... – ottsch