4

i'm setting up an phpunit test to walk trough a checkout. Now im struggling with the stripe iFrame. How can i access it?

I've created a DuskServiceProvider and registered it in AppServiceProvider.

public function boot()
{
    Browser::macro('reloadPage', function ($element = null) {
        $this->script('location.reload()');
        return $this;
    });
    Browser::macro('switchFrame', function ($frame) {
        $this->driver->switchTo()->defaultContent()->switchTo()->frame($frame);
        return $this;
    });
    Browser::macro('switchToParentFrame', function () {
        $this->driver->switchTo()->defaultContent()->switchTo()->defaultContent();
        return $this;
    });
}

this is the method where the error comes from. The "waitFor" waits for the Frame.

public function paymentNewCostumer()
{
    $this->browse(function (Browser $browser) {
        $browser
            ->assertSee('WÄHLE DEINE ZAHLUNGSART')
            ->waitFor('iframe[name=__privateStripeFrame5]')

        $browser->switchFrame('__privateStripeFrame5');

        //do some stuff in frame..
    });
}

after that i should be able inserting some credit card information in those field but got the following error..

Tests\Browser\Packages\Checkout\CheckoutDesktopNewCostumerTest::testNewCostumerDesktop Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/5180c633d44eca82adb0c51f7ace803e/log with params: {"type":"browser"}

Operation timed out after 30000 milliseconds with 0 bytes received

/home/vagrant/faaren/backend/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:297 /home/vagrant/faaren/backend/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:565 /home/vagrant/faaren/backend/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php:40 /home/vagrant/faaren/backend/vendor/facebook/webdriver/lib/WebDriverOptions.php:156 /home/vagrant/faaren/backend/vendor/laravel/dusk/src/Browser.php:306 /home/vagrant/faaren/backend/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:154 /home/vagrant/faaren/backend/vendor/laravel/framework/src/Illuminate/Support/Collection.php:475 /home/vagrant/faaren/backend/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:155 /home/vagrant/faaren/backend/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:77 /home/vagrant/faaren/backend/tests/Browser/Packages/Checkout/CheckoutDesktopNewCostumerTest.php:99 /home/vagrant/faaren/backend/tests/Browser/Packages/Checkout/CheckoutDesktopNewCostumerTest.php:55 /home/vagrant/faaren/backend/tests/Browser/Packages/Checkout/CheckoutDesktopNewCostumerTest.php:30

Evan M
  • 2,573
  • 1
  • 31
  • 36
Veldhaenchen
  • 41
  • 1
  • 2

1 Answers1

2

Finally I found a solution that worked.

My setup is the following:

  • Using Laravel Forge
  • Server provider is digitalocean (Ubuntu)

Login to your server using a SSH keypair. I'm using the forge username (with sudo access).

1. Run the following commands (taken from here)

# makes sure all your repos are up to date
sudo apt-get update
# chrome dependencies I think
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
# chromium is what I had success with on Codeship, so seemed a good option
sudo apt-get install chromium-browser
# XVFB for headless applications
sudo apt-get -y install xvfb gtk2-engines-pixbuf
# fonts for the browser
sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
# support for screenshot capturing
sudo apt-get -y install imagemagick x11-apps

# Once all this has run through, you need to fire up xvfb on your homestead box. If you’re planning to # do this on a regular basis, you’ll want to get this setup on boot, but for the sake of testing things out:
Xvfb -ac :0 -screen 0 1280x1024x16 &

2. Afterwards run the following command

Taken from here

chmod -R 0755 vendor/laravel/dusk/bin/

If 2 + 3 dosen't work...

Make sure you've executed the artisan command: php artisan dusk:install

Unicco
  • 2,466
  • 1
  • 26
  • 30