Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stof opened this issue Nov 4, 2015 · 2 comments

Comments

@stof
Copy link

stof commented Nov 4, 2015

$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)

@weaverryan
Copy link
Member

@stof Ah, I haven't used the assertSession - I thought (by its name) it was purely an asserter, but this actually finds and asserts, which indeed is very very handy. I'm going to look into adding a quick chapter about this somewhere (or maybe updating an existing chapter).

I also hadn't seen the https://github.com/Behat/MinkExtension/blob/master/src/Behat/MinkExtension/Listener/FailureShowListener.php - that's also interesting.

Thanks!

@weaverryan
Copy link
Member

Code changes merged and deployed in at #23. Only todo is to record a small addition to the mink-inside-feature-context chapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants