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
101 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,660 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,520 points
614 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,520 points
88 views
0 votes
1 answer

Need help to open excel file and read in Python

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

answered Jul 22 in Python by Tina
33 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
62 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,340 points
49 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,720 points
85 views
0 votes
1 answer