Search code examples
phplaraveltestinglaravel-dusk

Laravel Dusk Draw on Canvas Element


I am trying to make a Laravel Dusk test to sign a canvas elememt (jSignature plugin)

But can seem to get it working. this is my current code:

    $this->browse(function (Browser $browser) {
        $browser->visit('/form')

            # Sign
            ->click('#input-13')
            ->pause(3000)
            ->mouseover('.jSignature')
            ->click('.jSignature')
            ->moveByOffset(100,100)
    });

Any ideas how?


Solution

  • Managed to solve it! that's how I did it (the signature opens in a bootstrap modal window):

                ->click('#input-13')
                ->pause(3000)
                ->mouseover('.jSignature')
                ->click('.jSignature')
                ->dragRight('.jSignature',100)
                ->dragLeft('.jSignature',200)
                ->pause(3000);
    

    The pausing is there to allow bootstrap's transitions to end.