Something is wrong with the AcceptanceTester->see()
method for me. It can't see things that are plainly there in the source, as shown by the AcceptanceTester->seeInSource()
method.
Here's my test, which runs in PHPBrowser
within the WP-Browser
implementation of Codeception:
public function testAfricaIsVisible(AcceptanceTester $I) {
$I->amOnPage('/');
$I->seeResponseCodeIs(200);
$I->seeInSource('Africa');
$I->see('Africa');
}
Here's the result I get:
As you can see, ->SeeInSource("Africa")
works, but ->see("Africa")
fails.
I understand that ->SeeInSource()
sometimes "sees" things that ->see()
doesn't, but in this case, the word "Africa" is link text that should be clearly visible with or without strip_tags()
applied.
In this case, when I open up the Html
link the word "Africa" is clearly visible:
Anyone have any idea why Codeception doesn't ->see()
this text?
I figured it out. For anyone with a similar problem, the underlying issue was malformed HTML that was glossed over by Chrome/Firefox but screwed up the site as seen by Phpbrowser
. I bet if I was using the WebDriver
module instead, it would work.
The solution: Use an HTML validation tool and fix the reported syntax errors.
In this case it was a title
tag with a single-quote in it, e.g. title='doesn't'