Skip to content

Instantly share code, notes, and snippets.

@shellkore
Created May 2, 2019 15:52
Show Gist options
  • Save shellkore/68bc03dfc825c1dcb33e4f55eb5cba19 to your computer and use it in GitHub Desktop.
Save shellkore/68bc03dfc825c1dcb33e4f55eb5cba19 to your computer and use it in GitHub Desktop.
import json
def user_auth():
username=input('Enter username(reg. no.):-')
password=getpass.getpass('Enter password:-')
data={'username':username,
'password':password}
with open('data.json','w') as outfile:
json.dump(data,outfile)
#if using for first time
if(os.path.isfile('./data.json')==False):
print("It's your first time....")
user_auth()
#opening data file which contains username and password
with open('data.json') as json_file:
data = json.load(json_file)
#selecting and filling username
elem = browser.find_element_by_css_selector('#txtUserName')
elem.send_keys(data['username'])
#selecting and filling password
elemp = browser.find_element_by_css_selector('#Password1')
elemp.send_keys(data['password'])
#entering the page by clicking submit button
logb = browser.find_element_by_css_selector('#Submit1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment