如何使用 Selenium 和 Java 手动输入 OTP 后继续自动化
使用 selenium webdriver 我正在使用 eclipse、maven、testng 测试登录页面和更多选项卡,但在登录页面中有 OTP 验证。所以我手动输入OTP。如何自动化继续下一个流程?
Using selenium webdriver I am testing login page and some more tabs using eclipse, maven, testng, but in Login page there is OTP verification. So I put OTP manually so. How to continue next proces as a automation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要使用 Selenium 手动输入 OTP 后继续自动化,将使用 Scanner 类如下:
参考资料
您可以在以下位置找到一些相关的详细讨论:
To continue automation after entering OTP manually using Selenium would be to use the Scanner class as follows:
References
You can find a couple of relevant detailed discussions in:
你不需要手动输入,你可以使用别人的otp生成器库,比如python中的pyotp。
对于java你有吗
https://github.com/BastiaanJansen/otp-java
要解析 OTP,通常需要需要首先选择“iframe”,例如在 python 中。
为了可靠,我喜欢逐键发送,并记住iframe,它非常重要。
例如(java):
并记住在以下之后转到默认框架:
You don't need to enter that manually, you can use someone's otp generator library, like pyotp in python.
for java do you have
https://github.com/BastiaanJansen/otp-java
To resolve the OTP, you generally need to select the "iframe" first, for example in python.
To be reliable, I like to send key by key, and remember about the iframe, it is very important.
For example (java):
And remember go to default frame after: