
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fill Username and Password Using Selenium in Python
We can fill username and password fields in a login page with Selenium. This is considered an authentication step for any application. Once the username and password is entered, we have to click the login button.
Example
Code Implementation.
import time from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") driver.get("https://mail.rediff.com/cgi-bin/login.cgi") # identify username, password and signin elements driver.find_element_by_name("login").send_keys("tutorialspoint") time.sleep(0.2) driver.find_element_by_name("passwd").send_keys("pass123") time.sleep(0.4) driver.find_element_by_class_name("signinbtn").click() driver.close
If a valid username and password is provided, we shall be directed to the home page of the application.
Output
Advertisements