bellini's avatar

Dusk test in Laravel Nova

Hey I am trying to create a test of when I click on the first resource row shown on the current page. For example If I wanted to navigate to the row with id of 1 I would do:

        $this->browse(function (Browser $browser) {
            $browser->click('@1-view-button');
        });

But I need to target the first row for the current logged in user on the current resource which can be 1 or any other id. Any idea how I can accomplish that?

0 likes
1 reply
forrestedw's avatar
Level 3

I don't know the complete answer to this, but when I was Dusk testing and needed to get and iframe with a name that had consistent beginning but variable end to it - __privateStripeFrame followed by a random integer of length 4 - I used this:

->waitFor('iframe[name^=__privateStripeFrame]')

Note the ^ after name.

I'm guessing that because ^ matched the beginning of a sting in regex then maybe you could use $ to match the end of string, so yours would be something like:

$browser->click('button[dusk$=view-button]');
1 like

Please or to participate in this conversation.