how to login to the alert window when we navigate to the browser through selenium

和自甴很熟 提交于 2020-07-31 05:52:14

问题


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?


回答1:


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

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




回答2:


This provides multiple approaches for handling Authentication pop-ups.

I would suggest to use WebDriver’s switchTo.alert() syntax to access them and then use methods such as sendKeys(), accept() or dismiss()



来源:https://stackoverflow.com/questions/44722353/how-to-login-to-the-alert-window-when-we-navigate-to-the-browser-through-seleniu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!