通过硒导航到浏览器时如何登录警报窗口 [英] how to login to the alert window when we navigate to the browser through selenium

查看:58
本文介绍了通过硒导航到浏览器时如何登录警报窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要凭证的URL,并且正在通过Selenium + Java导航到该URL. https://用户名:password.example.com/

但是,它仍然显示登录窗口,但不显示为警报窗口.附上截图.我尝试了下面的代码,但是没有用

 UserAndPassword UP = new UserAndPassword("username","password");
 driver.switchTo().alert().authenticateUsing(UP);

反正我能做到吗?

解决方案

用户名和密码后,您缺少@符号.您可以尝试以下操作,

https://username:password@test.discoverykidsplay.com/

I have the url which needs credentials and I am navigating to that through selenium + Java https://username:password.example.com/

However it still shows the login window but not as an alert window. Attached the screenshot. I tried the below code but it did not work

 UserAndPassword UP = new UserAndPassword("username","password");
 driver.switchTo().alert().authenticateUsing(UP);

Is there anyway I can do it?

解决方案

You are missing @ symbol after user name and password. You can try like below,

https://username:password@test.discoverykidsplay.com/

这篇关于通过硒导航到浏览器时如何登录警报窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆