如何使用selenium web驱动程序自动化OTP?

Nar*_*raR 7 selenium selenium-webdriver

我正在为网站注册做自动化,但问题是,一旦我进入手机号码,它就会发送OTP.输入otp后,它会要求输入密码,而且我可以进行注册.

一旦我进入手机号码,有没有办法获得OTP代码?或者我们可以使用selenium webdriver自动化OTP吗?

Kum*_*mar 7

您可以尝试其中任何一个:

解决方案1:

步骤1:通过USB将电话/加密狗连接到COM端口.

第2步:调用代码通过smslib.jar获取短信

用于获取短信的示例代码:

public void sendSMS() throws Exception{
    OutboundNotification outboundNotification = new OutboundNotification();
    SerialModemGateway gateway = new SerialModemGateway("modem.com5", "COM5", 9600, "ZTE", "COM5");
    gateway.setInbound(true);
    gateway.setOutbound(true);
    gateway.setSmscNumber("+91XXXXXXXXXX"); // 10-digit Mobile Number
    Service.getInstance().setOutboundMessageNotification(outboundNotification);
    Service.getInstance().addGateway(gateway);
    Service.getInstance().startService();
    OutboundMessage msg = new OutboundMessage(ExcelConnect.strSMSTo, ExcelConnect.strSMSText);
    Service.getInstance().sendMessage(msg);
    System.out.println(msg);
    System.out.println(ExcelConnect.strSMSTo + "-" + ExcelConnect.strSMSText);
    Service.getInstance().stopService();
    Service.getInstance().removeGateway(gateway);
}
Run Code Online (Sandbox Code Playgroud)

步骤3:解析短信以通过最新收到的短信从获取的列表中获取OTP

.

解决方案2:

第1步:连接Android手机/ iPhone.

步骤2:在手机中的任一个中自动化SMS应用程序,如果它的android - 通过appium(或任何其他自动化应用程序)自动化SMS应用程序或者如果它的iphone - 自动化其SMS应用程序功能,

获取SMS并解析它以获得OTP

.

解决方案3:

步骤1:注册HTTP SMS网关(其中大多数提供付费API调用,只需很少的免费API调用进行测试).

第2步:调用方法来获取SMS.

步骤3:解析消息(在用最新收到的短信对其进行排序后)以获得OTP

.

这三种方式可以获得OTP,然后您可以将它发送给您的Web应用程序.

.

解决方案4:

从DB获取OTP,如果是内部应用程序,或者是否可以访问它.

.

" 解决方案3和解决方案4 "效率最高,并且对接收平台的短信没有任何依赖性.

.

以下合并解决方案

在此输入图像描述