- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the different ways of handling authentication popup window using Selenium?
We can handle authentication pop-up window using Selenium webdriver by incorporating the username and password within the application URL. The format of an URL along with credential should be − https://username:password@URL
Let us launch a web page having the authentication pop-up generated at page load −
The user Name and Password fields are having value as admin.
If we ignore this pop-up on clicking the Cancel button, we shall be navigated to the below page.
If proper credentials are entered and then the OK button is clicked, we shall be navigated to the below page.
In the above example, to handle the authentication pop-up, using the get method, the URL to be passed as a parameter should be - https://admin:admin@the−nternet.herokuapp.com/basic_auth.
Example
from selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") #implicit wait driver.implicitly_wait(0.5) #maximize browser driver.maximize_window() #username, password value p = "admin" #url format url = "https://" + p + ":" + p + "@" + "the-internet.herokuapp.com/basic_auth" #launch URL driver.get(url) #identify element l = driver.find_element_by_tag_name("p") #obtain text s = l.text print("Text is: ") print(s) #close browser driver.close()
Output
- Related Articles
- Handling Browser Authentication using Selenium
- How to handle authentication popup with Selenium WebDriver using Java?
- How can we handle authentication popup in Selenium WebDriver using Java?
- What is data handling? What are the different ways to represent data?
- What are the different ways to select an option from a dropdown using Selenium Webdriver?
- How do I create a popup window using Tkinter?
- What are the different ways of cooking eggs?
- What is the best way to handle a Javascript popup using Selenium Webdriver?
- How to center a popup window on screen using JavaScript?
- How do I create a popup window using Tkinter Program?
- What are different selenium versions?
- What are the different ways to install pandas?
- What are the different cookies methods in Selenium?
- What are the different types of wait available in Selenium?
- What are the ways of submitting a form in Selenium with python?
