Following example from here, trying to implement some Selenium testing.
Test class code:
class StackoverflowTest extends \PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp(): void
{
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowserUrl('https://stackoverflow.com/');
$this->setBrowser('chrome');
parent::setUp();
}
public function onNotSuccessfulTest(Throwable $e): void
{
$filedata = $this->currentScreenshot();
$file = __DIR__ . '/' . time() . '.png';
file_put_contents($file, $filedata);
parent::onNotSuccessfulTest($e);
}
/**
* @test
*/
public function visit_home_page_case_success()
{
$this->url('/');
dump($this->title());
dd($this->byTag('body')->text()); //line 35
}
}
Console output:
...
"Stack Overflow - Where Developers Learn, Share, & Build Careers"
...
There was 1 error:
1) ...\StackoverflowTest::visit_home_page_case_success
InvalidArgumentException: Element not found.
...
.../StackoverflowTest.php:35
...
Screenshot:
What's wrong and how can I to interact with the page elements?
Repeated here.
