browser
browser copied to clipboard
Unexpected behaviour for assertSeeIn()
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:
<tr>
<td>Foo</td>
<td>Bar</td>
</tr>
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 first td
that the crawler will encounter, but to match Bar
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