0

I have a simple scenario:

Scenario: No javascript warning
    Given I am on homepage
    When I don't have javascript enabled
    Then I should see a warning

How would I implement the when part with mink? Is there a more elegant way than just testing for a noscript element?

My solution so far:

/**
 * @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');
}

Thanks for your help!

ottsch
  • 431
  • 1
  • 6
  • 14

1 Answers1

-1
<noscript>You're only spoiling things for yourself!</noscript>
Dale
  • 10,384
  • 21
  • 34
  • Thanks, how to implement it for a visitor is clear but I'd like to test against it... – ottsch Nov 19 '12 at 08:56
  • I see.. could you have some ajax form submit if it is enabled? updating a session value to true for example? I am not familiar with behat or mink myself. – Dale Nov 19 '12 at 08:57
  • Yes... The question is more how to make mink behave as if it had no JavaScript enabled... – ottsch Nov 19 '12 at 09:06