首页 > 解决方案 > 如何使用appium在移动应用程序中自动支付卡?

问题描述

我正在尝试自动化一个场景,我需要输入卡上的姓名、卡号、到期日期和 CVC 号码等卡详细信息。当我尝试发送到期日期为“2318”时,默认情况下它接受值为“23/8”。理想情况下,它应该接受值为“23/18”。我试图在月份和年份中提供空间,但仍然无法正常工作。知道如何自动化吗?

以下是我的一段代码:

 @Override
    public void enterCardDetails() {
        waitForElement(appiumDriver,enterNameOnCardEditField).sendKeys("test");
        waitForElement(appiumDriver,enterCardNumberEditField).sendKeys("0000000000000000");
        waitForElement(appiumDriver,enterExpiryMMYYEditField).sendKeys("2518");
        waitForElement(appiumDriver,enterCVCNumberField).sendKeys("000");
        waitForElement(appiumDriver,makePaymentOption).click();
    } 

我正在使用以下 appium 和 selenium 版本:

  1. appium-java 客户端:6.0.0-BETA5
  2. appium 桌面版:1.6.1
  3. Selenium java 版本:3.9.1

不幸的是,我无法提供 appium 检查器的任何屏幕截图。

标签: javaseleniumselenium-webdriverwebdriverappium

解决方案


As per your question what you are seeing is pretty much expected and is a result of validation error on the field for expiry date.

Essentially, the expiry date on any Credit Card would consist of MM/YY format, where:

  • MM field would accept character sequence e.g. 01, 10, 12, etc
  • YY field would accept character sequence e.g. 18, 19, 20, etc

Now whenever you try to send the character sequence of 2318 the js involved for the validation doesn't accepts the characters and in absence of a proper js validator allows the characters 23 and 8 within the MM and YY fields respectively.

这是一个潜在的错误,可能已经逃脱了手动验证

解决方案

发送一个有效的字符序列如下:

waitForElement(appiumDriver,enterExpiryMMYYEditField).sendKeys("0718");

推荐阅读