添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I tried everything I can find online, still can't solve this issue. I am using selenium to login a site. There is a javascript login popup windows that requires username and password. enter image description here Below is the code which doesn't work.

driver.get(url)
sleep(5)
alert=driver.switch_to.alert

I also tried use request.get(https://username:password@site), it works, but I can't get the content after login. I assume it is javascript page. Anyone can help me with this issue. I would really appreciate. I have worked on this issue for whole day long.

This is not an alert, rather an example of a page with basic authentication. If you are using Selenium4, then here is an article by Simon Stewart about how you can handle this - link

Also, you can see this blog post which takes a slightly different approach to same problem, using Selenium 4 and Chrome Devtools - link

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.