Skip to content

Your Mink example could use the WebAssert instead of assertNotNull after using find() #22

@stof

Description

@stof
$searchBox = $this->assertSession()->elementExists('css', 'input[name="searchTerm"]');

$searchBox->setValue(...)

WebAssert::elementExists accepts the same arguments than Element::find (plus an optional third one if you want to search in specific element rather than the whole page), but it throws an ExpectationException when there is no node instead of returning null.

There is a nice side-effect compared to using a PHPUnit assertion on the element: as the exception thrown is a MinkException, this will play well with the MinkExtension feature allowing to open the failing page on failure (to debug what failed by seeing the actual content)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions