mercredi 3 février 2016

Laravel phpunit emulate keyboard key press

I am writing tests for the search functionality in my laravel app. I want to mock the user behaviour so in my tests I have sth like public function testSearchCanBeDone() { $this->visit('/') ->type('name', 'query') ->press('Search') //In my case press enter key ->seePageIs('/search?query=name') ->see('Results'); } }

My problem is at the ->press('Find') now that I don't have a search button. In my case after typing inside the search field one presses the enter key. How do I go about it. This is the code for my search form

<form method="GET" action="/search" role="search">

                    <div class="input-field">
                        <input name = "query" id="search" type="search" class="search" required>
                        <label for="search">
                            <i class="material-icons teal-text text-lighten-2">search</i>
                        </label>
                        <i class="material-icons">close</i>
                    </div>
                </form>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire