Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

0 votes
Jan 31 in Python by VIBHU
23 views
@Vibhu can you share the work you have done for this till now?
Along with the code, could you also share how the username and passwords are stored in the file?

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

I had a similar requirement. I had saved the username and password in a single file in the form of a key-value pair. Like this

account.details.txt:

username1:password1
username2: password2

You can use something like this:

...

....

....

with open('accountdetailss.txt', 'r') as file:
   for details in file:
        username, password = details.split(':')

        driver.get('https://<your website>')

        username_entry= driver.find_element_by_id('Username')
        username_entry.send_keys(username)

        password_entry = driver.find_element_by_id('Password')
        password_entry.send_keys(password)

        login_button= driver.find_element_by_id('Submit')
        login_button.submit()
answered Jan 31 by Omkar
• 65,820 points

Related Questions In Python

0 votes
1 answer

Need help extracting a schema to make use for an avro file in Python

Hi, nice question. So what I daily use ...READ MORE

answered Jan 10 in Python by Nymeria
• 3,500 points
195 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,500 points
12 views
0 votes
2 answers

What do you mean by python scripting? What is a script and a module in python?

A scripting language is a programming language ...READ MORE

answered Mar 14 in Python by rajesh kumar
1,520 views
0 votes
1 answer

Create and open a file in Python

file = open('text.txt', 'w+) READ MORE

answered May 24, 2018 in Python by Nietzsche's daemon
• 4,260 points
34 views
0 votes
0 answers

Storing a list of arrays into a CSV file and retrieving it back in a different program

This is the code that I am ...READ MORE

Jun 6, 2018 in Python by ariaholic
• 7,320 points
24 views
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,710 points
41 views
0 votes
1 answer

how to exit a python script in an if statement

This works fine for me: while True: ...READ MORE

answered Sep 19, 2018 in Python by bug_seeker
• 14,960 points
206 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 9,380 points
61 views
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2 in Python by Omkar
• 65,820 points
24 views
0 votes
1 answer

How to list only text files in a directory using python?

Well, you are using a complex way. ...READ MORE

answered Feb 3 in Python by Omkar
• 65,820 points
75 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.