You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromtimeimportsleepimportdatetimeimportDBUsers, Constantsimporttracebackimportrandomdeflogin(webdriver):
#Open the instagram login pagewebdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher')
#sleep for 3 seconds to prevent issues with the serversleep(3)
#Find username and password fields and set their input using our constantsusername=webdriver.find_element_by_name('username')
username.send_keys(Constants.INST_USER)
password=webdriver.find_element_by_name('password')
password.send_keys(Constants.INST_PASS)
#Get the login buttontry:
button_login=webdriver.find_element_by_xpath(
'//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button')
except:
button_login=webdriver.find_element_by_xpath(
'//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[6]/button/div')
#sleep againsleep(2)
#click loginbutton_login.click()
sleep(3)
#In case you get a popup after logging in, press not now.#If not, then just returntry:
notnow=webdriver.find_element_by_css_selector(
'body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
notnow.click()
except:
return
fromselenium.webdriverimportChrome, ChromeOptionsimporttimeEMAIL_ID="<your email ID>"defslow_typing(element, text):
forcharacterintext:
element.send_keys(character)
time.sleep(0.3)
# Visit chrome://version/ and copy profile path in place of '<chrome user profile>'options=ChromeOptions().add_argument("--user-data-dir=<chrome user profile>")
browser=Chrome(chrome_options=options)
browser.get('https://www.browserstack.com')
time.sleep(2)
# to accept cookie notification so that it doesn't interferecookie_cta=browser.find_element_by_id('accept-cookie-notification')
cookie_cta.click()
# Navigate to Signup Pagebutton=browser.find_element_by_id('signupModalButton')
button.click()
time.sleep(2)
# Fill user's full nameusername=browser.find_element_by_id('user_fudll_name')
# username.send_keys('John Doe')slow_typing(username, 'John Doe')
time.sleep(1)
# Fill user's email IDemail=browser.find_element_by_id('user_email_login')
slow_typing(email, EMAIL_ID)
time.sleep(2)
# Fill user's passwordpassword=browser.find_element_by_id('user_password')
# Reads password from a text file because# it's silly to save the password in a script.withopen('password.txt', 'r') asmyfile:
Password=myfile.read().replace('\n', '')
slow_typing(password, Password)
time.sleep(1)
# click on Terms and Conditionstoc=browser.find_element_by_name('terms_and_conditions')
toc.click()
# click on signup pagesignupbutton=browser.find_element_by_id('user_submit')
signupbutton.click()
time.sleep(20)
browser.close()