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
34 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.

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
• 67,200 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
360 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
37 views
0 votes
0 answers
0 votes
1 answer

Need help to open excel file and read in Python

You can use pandas module to do ...READ MORE

answered 1 day ago in Python by Tina
9 views
+1 vote
3 answers
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
42 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
32 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
65 views
0 votes
1 answer
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
• 67,200 points
44 views