Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type value is wrong in iframe inputs #558

Closed
dellow opened this issue Oct 2, 2018 · 4 comments
Closed

Type value is wrong in iframe inputs #558

dellow opened this issue Oct 2, 2018 · 4 comments

Comments

@dellow
Copy link

dellow commented Oct 2, 2018

In one of my Dusk tests I'm testing a Stripe elements form. When I switch to the iframe for the card number it 9 times out of 10 inputs the number incorrectly. If I use a non iframe input everything works fine.

A sample of my test:

/** @test */
public function it_can_save_a_card()
{
  $this->browse(function ($browser) {
    $browser->loginAs($this->user)
      ->visit('/account/business/billing')
      ->type('name', 'Mr Test User')
      ->type('noniframecardnumber', '4242424242424242');

    $browser->click('#stripe-card-number');
    $browser->waitFor('#stripe-card-number iframe', 15);
    $browser->driver->switchTo()->frame($browser->script('return $("#stripe-card-number iframe").attr("name");')[0]);
    $browser->type('cardnumber', '4242424242424242');

    $browser->driver->switchTo()->defaultContent();
  });
}

The failure screenshot (I included a standard input at the bottom):

failure-it_can_save_a_card-0

Any ideas why this might be happening?

Thanks.

@staudenmeir
Copy link
Contributor

Does the Stripe iframe have any JavaScript?

@dellow
Copy link
Author

dellow commented Oct 2, 2018

Yea the Stripe Elements drop in is pretty Javascript heavy. For example, it validates credit card numbers on the fly and also formats the output with spaces and such.

I forgot to mention, this test is pretty old and has always worked fine until recently. That said I understand something could have changed within Stripe just as much as it could have Dusk.

@staudenmeir
Copy link
Contributor

Could be a timing issue, maybe Dusk is typing too fast.

Try a pause after each character:

foreach (str_split('4242424242424242') as $char) {
    $browser->append('cardnumber', $char)->pause(100);
}

@dellow
Copy link
Author

dellow commented Oct 3, 2018

That got it. Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants