1

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:

enter image description here

What's wrong and how can I to interact with the page elements?

Repeated here.

1 Answer 1

2

Answered here:

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]]); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.