【发布时间】:2020-09-12 17:16:59
【问题描述】:
我正在尝试使用 Behat/Mink 在我的 Drupal 网站上测试 Stripe。
我配置了一个 Stripe 测试支付网关。我的
我的FeatureContext.php 看起来像这样:
/**
* @Then I enter my US JCB credit card info
*/
public function iEnterMyUsJcbCreditCardInfo() {
$this->enterCardDetails('3566 0020 2036 0505', '11 / 21', '777');
}
private function enterCardDetails($card_number, $exp_date, $cvc) {
$this->getSession()->wait(2000);
// Switch to the payment iframe.
$this->getSession()->switchToIFrame(self::STRIPE_CARDNO_IFRAME);
$this->getSession()->wait(1000);
$this->fillField('cardnumber', "$card_number");
$this->getSession()->wait(2000);
我添加了wait(),因为信用卡号填写不正确。
例如,当我有步骤And I enter my US JCB credit card info 时,我得到的不是正确的测试卡号 (3566 0020 2036 0505),而是:3566 0000 3605 5022。
错误的卡号不一致;当我重新运行 3 次测试时,我得到了这些数字:
- 3566 0022 3005 5600
- 3566 0002 0360 5502
- 3566 0006 5500 3220
因此,stripe.js 似乎干扰了我的信用卡号输入。
信用卡有效期和CVC/安全码输入没有这个问题。
当我把信用卡号中的空格去掉后,我仍然有同样的问题(输入时数字随机乱码)。
即使我将输入卡号前后的等待时间分别设置为5秒,卡号仍然会出现乱码。
如何在behat/mink中输入信用卡号而不乱码?
【问题讨论】:
标签: testing stripe-payments behat mink