How to make a redirection in Behat?

How to make a redirection in Behat?

per Julen Pardo,
Number of replies: 2

Hi all,

I'm trying, with Behat, to go to a page giving the full path.

For that, I'm creating a custom step definition, for the following step:

And I go to "/local/plugin/index.php"

In the PHP file where I'm defining the steps, I've tried the following:

/**
* @Given /^I go to "([^"]*)"$/
*/
public function iGoTo($path) {
$fullurl = new \moodle_url($path);

redirect($fullurl);
}

But, Behat marks the step as failed:

Unsupported redirect detected, script execution terminated
In step `And I go to "/local/plugin/index.php"'
From scenario `scenario'.


Is there any way to set directly an url with Behat?


Thanks in advance,

Julen

Average of ratings: -
In reply to Julen Pardo

Re: How to make a redirection in Behat?

per Davo Smith,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers

Why not have a look at the code for the existing behat functions 'I am on homepage' and 'I am on site homepage' (lib/tests/behat/behat_general.php).

That should give you the answer to your question.

Average of ratings:Useful (2)
In reply to Davo Smith

Re: How to make a redirection in Behat?

per Julen Pardo,

Hi Davo,

Thanks for your quick response.

That works for me, many thanks. I've been almost all the day using grep to find the way, and I feel quite silly right now.


Many thanks!

Julen