0

My application was laravel framework 5.8 and i am currently upgrading it to 6.0.

My Laravel Dusk browser tests include logging into Stripe, creating a user and a subscription before testing the application functionality.

I am using Google Chrome Version 80.0.3987.132 (Official Build) (64-bit)

I have set the Dusk chrome driver to the same using the usual command...

php artisan dusk:chrome-driver 80

My phpunit tests are now all running fine. My dusk tests start to run but when they get to the stripe login stage they return the error

InvalidArgumentException: In W3C compliance mode frame must be either instance of WebDriverElement, integer or null

The section of the Dusk test it is throwing this error at is:

$this->browse(function (Browser $browser) use ($recr1, $screenshotEnabled) {
    $browser->waitFor('iframe[name=__privateStripeFrame5]');
    $browser->driver->switchTo()->frame('__privateStripeFrame5');

I realise it probably isn't best practise to ignore/paper over the issue but to keep the upgrade to laravel 6.0 moving i have tried setting w3c compliance to false following the suggestions in:

How to turn off w3c in chromedriver to address the error unknown command: Cannot call non W3C standard command while in W3C

and

https://github.com/laravel/dusk/issues/624

by modifying DuskTestCase.php but to no avail.

protected function driver()
{
    $options = (new ChromeOptions)->addArguments([
        '--disable-gpu',
        '--headless',
        '--no-sandbox',
        '--window-size=1920,1080',

    ]);
        return RemoteWebDriver::create(
        'http://localhost:9515', DesiredCapabilities::chrome()
        ->setCapability(ChromeOptions::CAPABILITY, $options)
        ->setCapability('alwaysMatch', ['goog:chromeOptions' => ['w3c' => false]])
        , 60*1000, 60*1000
    );
}

}

I think the correct action is actually to address the issue head on and modify the way i reference the stripe frame i.e.

            $browser->waitFor('iframe[name=__privateStripeFrame5]');
        $browser->driver->switchTo()->frame('__privateStripeFrame5');

but im not sure how to do this.

I think i might need toswitch back to the default frame but have yet to get that working...

https://laracasts.com/discuss/channels/laravel/dusk-click-element-in-iframe?page=1

$this->driver->switchTo()->defaultContent()->switchTo()->defaultContent();

Any thoughts/recommendations greatly appreciated guys.

Greenie
  • 63
  • 1
  • 10

1 Answers1

0

Seems I have sorted the problem.

The switchTo wasn't working...

            $browser->waitFor('iframe[name=__privateStripeFrame5]');
    $browser->driver->switchTo()->frame('__privateStripeFrame5');

so instead i used withinFrame...

    $browser
    ->waitFor('iframe[name=__privateStripeFrame5]')
    ->withinFrame('iframe[name=__privateStripeFrame5]', function($browser){
...
        });

Thanks to tgugnani in his post...

https://www.5balloons.info/working-with-iframe-in-laravel-dusk/

Greenie
  • 63
  • 1
  • 10