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, 2019 in Python by VIBHU
3,348 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, 2019 by Omkar
• 69,030 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, 2019 in Python by Nymeria
• 3,520 points
1,910 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, 2019 in Python by Nymeria
• 3,520 points
398 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 Jul 22, 2019 in Python by Tina
168 views
+1 vote
0 answers

Sum the values of column matching and not matching from a .txt file and write output to a two different files using Python

Name                                                    value DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 15657 DR_CNDAOFSZAPZP_GPFS_VOL.0 139264 DR_CNDAOFSZAPZP_GPFS_VOL.1 156579 DR_CNDAOFSZAPZP_GPFS_VOL.2 156579 DR_CNDAOFSZAPZP_GPFS_VOL.3 ...READ MORE

Nov 20, 2019 in Python by Sagar
• 130 points
450 views
0 votes
1 answer
0 votes
1 answer

how can i extact all the links from a website using python and save it in a csv file ?

Hi, @Shubham, Web scraping is the technique to ...READ MORE

answered Jun 16 in Python by Gitika
• 50,540 points
691 views
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15 in Python by Niroj
• 78,120 points
194 views
0 votes
2 answers