Is there a straightforward way to simulate HTTP_REFERER
in a Dusk test? I'm using Laravel\Dusk\Browser
and calling the visit()
method on various pages. This is using the Selenium driver.
Something like setReferer
below:
namespace Example\Tests\Browser\Processes\PublicSite;
class SampleBrowser extends Browser {
use MakesAssertions, ProvidesAdditionalBrowserActions, WaitsForElements;
public function __construct(RemoteWebDriver $driver, $resolver = null)
{
parent::__construct($driver, new ElementResolver($driver,
$resolver->prefix ?? 'body'));
}
}
class SampleTestCase extends BrowserTestCase
{
/**
* Test that the deal builder modal shows up.
*/
public function testRefererRendering()
{
$this->browse(function (SampleBrowser $browser) {
$browser
// this is the bit that I want
->setReferer('https://example.org/')
->visit('/')
->waitForLocation('/?came_via=example.org')
->assertCookieValue('came_via', 'example.org');
});
}
}