gpt4 book ai didi

How to test OTP verification with appium(如何用Appium测试动态口令验证)

转载 作者:bug小助手 更新时间:2023-10-25 23:39:44 24 4
gpt4 key购买 nike



How to test OTP verification with Appium.
I want to do OTP verification by appium can any one help me?.

如何用Appium测试动态口令验证。我想用Appium做动态口令验证,有人能帮我吗?


更多回答

what you tried so far ?

到目前为止你都试了些什么?

Hi Raj, did you get any solution for your problem? If so, please post it here.

嗨,拉杰,你的问题有什么解决办法吗?如果是的话,请把它贴在这里。

优秀答案推荐

Using Appium you can automate and control your app but there are certain limitations You need to understand the process of generating OTP. Whenever you do some transaction OTP will get generated and send to your Mobile device. So you can automate the process to perform such transaction. But after that to enter OTP which is in your Inbox you need to open your Inbox, Find the Message, Extract the OTP, Enter it. This is very complex process to automate using Appium.

使用Appium,您可以自动化和控制您的应用程序,但您需要了解生成动态口令的过程有一定的限制。每当你做一些交易时,动态口令都会被生成并发送到你的移动设备上。因此,您可以自动执行该流程以执行此类交易。但在那之后,要进入收件箱中的动态口令,您需要打开收件箱,找到邮件,提取动态口令,输入它。使用Appium实现自动化是一个非常复杂的过程。



I think the better alternative is to Set one fix OTP number for testing purpose instead of requesting OTP Real time.

我认为更好的选择是设置一个固定的动态口令号码用于测试目的,而不是请求动态口令实时。



You can switch between apps in Android. On sending OTP using your app, switch to android default message app and read OTP and then switch back to your test app.

你可以在Android的应用程序之间切换。在使用你的应用程序发送动态口令时,切换到Android默认消息应用程序并阅读动态口令,然后切换回测试应用程序。



driver.startActivity(AppPackageName, AppActivityName);


The above call can be used to switch between different app. Replace AppPackageName and AppActivityName with your test app package name / activity name and android default message app name respectively.

上面的调用可以用于在不同的APP之间切换。将AppPackageName和AppActivityName分别替换为您的测试应用程序包名称/活动名称和Android默认消息应用程序名称。



You can automate OTP validation from Appium in two ways.

您可以通过两种方式从Appium自动执行OTP验证。




  1. By opening messages application in android and reading OTP from there.

  2. By opening notifications and read OTP.



To open messages application we need to open the app using below code:

要打开消息应用程序,我们需要使用以下代码打开该应用程序:



driver.startActivity(AppPackageName, AppActivityName);


To Read OTP from notification pane we can open notification pane using below code:

要从通知窗格中读取OTP,我们可以使用以下代码打开通知窗格:



driver.openNotifications()


Now you can inspect OTP text element and read the text. For example, if your OTP text is

现在您可以检查OTP文本元素并阅读文本。例如,如果您的OTP文本是




Your OTP is 3357




You will get otp as below:

您将获得如下所示的OTP:



string otp = driver.findElementByXpath("//*[contains(@text,"Your OTP is")]").getText().split(" is")[1]


Above code will return OTP into the string variable. Now you can use below code to come back to the application.

上面的代码将把OTP返回给字符串变量。现在,您可以使用以下代码返回到应用程序。



driver.navigate().back();


This solution is for Android only.

该解决方案仅适用于Android。



yes, i think you are right but, i need to login before use the app and login page have a OTP verification thats why i need to check OTP.
i can build a app with out OTP for testing but can not do every time because i have to test production build which are going to far user and in this build i can not hide OTP verification.

是的,我认为你是对的,但是,我需要登录前使用应用程序和登录页面有一个动态口令验证,这就是为什么我需要检查动态口令。我可以为测试建立一个没有动态口令的应用程序,但不能每次都这样做,因为我必须测试生产版本,这将是远用户的,在这个版本中,我不能隐藏动态口令验证。



For OTP verification you can use Android messenger. Download android messenger apk, create test scrips to launch and read message using this app.

对于OTP验证,您可以使用Android Messenger。下载Android Messenger APK,创建测试脚本以使用此应用程序启动和阅读消息。



I don't know how to do for iOS, Can any one suggest here how to do for iOS based application.

我不知道iOS该怎么做,有没有人能在这里建议一下,基于iOS的应用该怎么做?



Thanks,
Sadik

谢谢,萨迪克


更多回答

My suggestion is to do OTP Varification part Manually. And it must work if you tested it well with fake OTP's. an automated testing script which can handle all possible situations by itself without manual intervention is good. But by doing so, we will end up in developing another software which is again very difficult to design, develop and maintain.

我的建议是手动做OTP变型部分。如果你用假的动态口令测试得很好,它必须工作。一个自动测试脚本,可以自己处理所有可能的情况,而不需要人工干预是很好的。但通过这样做,我们最终将开发另一个软件,该软件再次非常难以设计、开发和维护。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com