Symfony Panther – Testing Stripe form

  forms, phpunit, stripe-payments, symfony, testing

in my app I would like to test my Stripe form created with Stripe Elements. So I want to fill out the form with Panther ( https://github.com/symfony/panther ), but it seems totally impossible.

Here’s an example of a Stripe form: https://stripe.dev/elements-examples/

For example, if I want to automatically fill in the field corresponding to the card number (in the 1st example, this is the input with the name ‘cardnumber’), I tried two things:

$crawler->filter("input[name=cardnumber]")->sendKeys("4242 4242 4242 4242");

or

$this->client->getWebDriver()->findElement(WebDriverBy::name('cardnumber'))->sendKeys("4242 4242 4242 4242");

This returns me the following error :

FacebookWebDriverExceptionNoSuchElementException : no such element:
Unable to locate element: {"method":"css
selector","selector":"[name=’cardnumber’]"}

So I tried by running a javascript line :

$this->client->executeScript("$('input[name=cardnumber]').value = '4242 4242 4242 4242'");

It didn’t bring anything.

As a result, I find myself completely blocked and I do not know how to overcome this problem

Source: Symfony Questions

LEAVE A COMMENT