module-webdriver icon indicating copy to clipboard operation
module-webdriver copied to clipboard

i-click fails with html entity present...

Open cjaoude opened this issue 9 years ago • 1 comments

Seems like this is an aggressive regex type deal, but having an html entity inlined inside a button causes an acceptance test fail. Doesn't seem to matter what the entity is. It seems a blank space is needed to cause the entity to be ignored.

// $i->click('sign-in');

// this fails...
<button type="submit">
    <span class="fa fa-user"></span>&nbsp;sign-in
</button>

// this fails, variations...
    &nbsp;<span class="fa fa-user"></span>sign-in
    <span class="fa fa-user">&nbsp;</span>sign-in

//...and this doesn't...        
    <span class="fa fa-user"></span>sign-in
    <span class="fa fa-user"></span>&nbsp; sign-in
    &nbsp; <span class="fa fa-user"></span>sign-in

No biggie, but was a bit of a surprise trying to figure out why the test failed.

cjaoude avatar Mar 07 '16 19:03 cjaoude

I would suggest to try strict locators instead, see: http://phptest.club/t/regarding-filling-fields-and-clicking-buttons/569/2?u=javi_gomez

$I->click(['xpath' => "//button[contains(text(), 'sign-in')]"]);

Alternatively you can improve the markup of the application so you can easily locate the element. See best practice described at: https://docs.joomla.org/Testing_Joomla_Extensions_with_Codeception#Write_complex_locator_VS._modifying_the_output_of_the_tested_website

From my personal view I don't think that ->click codeception function heuristics are weak, I think that is just can't do it perfectly. Anyway all these heuristics affects performance. I think is much more better to write good locators to having performant and effective tests.

javigomez avatar Mar 16 '16 15:03 javigomez