如何在Appium中检索短信确认码
我正在使用 Appium 和 TestNG 对应用程序运行测试。但是,我必须首先登录该应用程序,该应用程序需要输入短信确认码。有什么方法可以将其包含在我的代码中吗?有什么方法可以拦截该短信代码并将其输入到应用程序中吗?
I am running tests to an app with Appium and TestNG. However, I must first log in to the app which requires an SMS confirmation code to be entered. Is there any way I can include this in my code? Some way to intercept that SMS code and enter it in the app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的解决方案是单击 OTP 输入框,然后会出现“自动填充代码”文本,然后等待“验证”按钮显示“启用/选中”。然后单击它并继续测试。
第二个解决方案是我在 appium 论坛上找到的
https://discuss.appium.io/t/how-to-read-sms-from-native-messaging-app-pe-to-read-otp/10409
Simplest solution is click on the OTP inputbox then there would be text to 'Autofill code' and make a wait till your "Verify" button says either is "enabled/checked". Then click on it and proceeds with the test .
2nd Solution would be something i found on appium discussion forum
https://discuss.appium.io/t/how-to-read-sms-from-native-messaging-app-p-e-to-read-otp/10409
这在 java、C# 和 Python 中运行良好。返回的 JSON 格式错误,因此需要进行字符串操作来读取它。这里贴出Java代码供大家参考。
This works well in java, C#, and Python. The returned JSON format is wrong so work on string manipulation to read it. Posting here Java code for your reference.