lundi 13 février 2017

Assert that there are certain number of elements on the page

I was writing a test with Laravel Dusk to make sure that there are, let's say, 10 articles on the index page.

Here is some HTML code:

<h1>A list of articles</h1>
<ul>
    @foreach($articles as $article)
        <li class="article-item"> </li>
    @endforeach
</ul>

I was thinking that in my test file I could firstly select all li.article-item then assert that there are 10 such elements.

The code might be

$this->browse(function ($browser) {
    $browser->visit('/articles')
        ->assertSee('A list of articles');

    $elements = $browser->findElements('.article-item');

    $this->assertCount(10, $elements);

});

But in fact, it looks like Laravel Dusk doesn't support choosing multiple elements at once. So in this case how may I structure my test? Any chance that within Dusk I use WebDriver API to select those elements?

Thank you!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lJKNCw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire