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
8,231 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,230 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,560 points
4,903 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,560 points
1,991 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
882 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
1,134 views
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,890 points
2,329 views
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, 2020 in Python by Gitika
• 65,890 points
4,057 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, 2020 in Python by Niroj
• 82,880 points
6,659 views
–1 vote
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP