Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidArgumentException: Element not found #439

Closed
lihusha opened this issue Nov 30, 2019 · 2 comments
Closed

InvalidArgumentException: Element not found #439

lihusha opened this issue Nov 30, 2019 · 2 comments

Comments

@lihusha
Copy link

lihusha commented Nov 30, 2019

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
Copy link
Collaborator

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
Copy link

hexmode commented Jan 9, 2020

dupe of #436

@pajon pajon closed this as completed May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants