0
votes

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!

1

1 Answers

-1
votes
<noscript>You're only spoiling things for yourself!</noscript>