Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mikebronner's avatar

LogicException: The selected node does not have a form ancestor.

I'm working on fleshing out my functional tests with the integrated PHPUnit functionality added in Laravel 5. I have a form, but its "submit" button is a regular button outside of the form, which onclick event triggers the form to submit. (This is necessary because of layout constraints.)

The error I'm getting is:

LogicException: The selected node does not have a form ancestor.

Here's the relevant unit test:

        $response = $this->actingAs($this->myUser)
            ->visit('testpage')
            ->click('random-link-id')
            ->press('Update Role'); // this is just a regular <button> with an onclick event

Any ideas how to trigger a form submit without pressing a button that has to be within the form tags?

0 likes
3 replies
ifpingram's avatar

I think you will struggle to do this as the InteractsWithPages class in the testing library seems to use the submit button text to identify the form to fill in.

Please or to participate in this conversation.