giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
601 stars 270 forks source link

InvalidArgumentException: Element not found #439

Closed lihusha closed 4 years ago

lihusha commented 4 years ago

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.

thewunder commented 4 years ago

Unfortunately phpunit-selenium does not support W3C mode yet, you can force it to use the non-w3c mode by:


$this->setDesiredCapabilities(['chromeOptions' => ['w3c' => false]]); 
hexmode commented 4 years ago

dupe of #436