Open benr77 opened 1 year ago
Yes, I've been burned by this before as well. I agree with your conclusion on how it should work.
Is this just how behat/mink
normally works? I guess you can't really change this behaviour now as it would break a lot of people's existing tests...
Is this just how behat/mink normally works?
Yes
I guess you can't really change this behaviour now as it would break a lot of people's existing tests...
That's my concern. Maybe a new method?
assertSeeInAny()
?
I was also thinking of assertSeeInAny()
but I think the issue is more the underlying use of behat/mink
than the method name. I don't know Mink at all - maybe it also has another method that mirrors our requirement here...
I don't recall mink having such a method but we should be able to add this behaviour manually (find all the elements via the dom crawler, get their text, then assert if the expected text is contained within)
I keep getting annoyed when using
assertSeeIn()
as the CSS selection often does not do what I expect.Say I have a table in my page:
If I want to check that
Bar
is present, I would expect to be able to use:$this->assertSeeIn('td', 'Bar')
.This will work for
Foo
as it's the firsttd
that the crawler will encounter, but to matchBar
I have to use:$this->assertSeeIn('tr td:last-child', 'Bar')
I expect
assertSeeIn
to find a string in ANY element that matches the$selector
.Is this the expected/desired behaviour? If so then something in the docs about it would be good, but personally I don't think it's the right behaviour - I don't want to couple my tests so tightly to the exact HTML - in this case I just want to check the
Bar
is shown somewhere in the table, I don't care about its exact position.Any thoughts?
Cheers