Skip to content

Instantly share code, notes, and snippets.

@barmmie
Last active May 1, 2019 15:39
Show Gist options
  • Select an option

  • Save barmmie/5b57095aa793cf7f390a48dffdc6f8ec to your computer and use it in GitHub Desktop.

Select an option

Save barmmie/5b57095aa793cf7f390a48dffdc6f8ec to your computer and use it in GitHub Desktop.
//Add this to Your serviceprovider.php

Browser::macro('fillHidden', function ($name , $value) {
    $this->script("document.getElementsByName('$name')[0].value = '$value'");
    return $this;
});
//It can then be used in your tests like this:

/** @test */
public function fill_hidden_fields()
{
    $this->browse(function (Browser $browser) {
        $browser->visit('https://website.com/form')
                ->type('input.name', $name)
                ->type('input.address', $address)
                ->fillHidden('checkin_date', $date)
                ->click('#Submit')
                ->waitForText('Orders');
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment