creating qwiklabs account: get person info from randomuser.me api using requests
parent
ecf5a061bb
commit
022b5c967b
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,110 @@
|
|||
from utils import browser_manager
|
||||
from selenium.webdriver.common.by import By
|
||||
import time
|
||||
from selenium.webdriver.common.alert import Alert
|
||||
from selenium.webdriver.common.alert import Command
|
||||
import requests
|
||||
|
||||
class QL_DeleteAccount:
|
||||
def __init__(self, proxy, account):
|
||||
self.proxy = proxy
|
||||
self.account = account
|
||||
|
||||
def create_account(self):
|
||||
self.driver = browser_manager.start_browser(self.proxy)
|
||||
self.temp_mail = TempMail(self.driver).get_new_temp_mail()
|
||||
self.name = RandomNameGenerator(self.proxy).get_person_info()
|
||||
self.sign_up()
|
||||
self.delete()
|
||||
|
||||
def sign_up(self):
|
||||
print("[+] Signing in using account [{}:{}]".format(self.account[0], self.account[1]))
|
||||
|
||||
self.driver.get("https://www.qwiklabs.com/users/sign_in")
|
||||
time.sleep(1.5)
|
||||
|
||||
#accept goddamn cookies
|
||||
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/div[2]/div/button')
|
||||
time.sleep(2)
|
||||
|
||||
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_email", self.account[0])
|
||||
time.sleep(1.5)
|
||||
browser_manager.inputText(self.driver, By.CSS_SELECTOR, "#user_password", self.account[1])
|
||||
time.sleep(1.5)
|
||||
browser_manager.clickButton(self.driver, By.CSS_SELECTOR, "#new_user > div.form-actions > button")
|
||||
time.sleep(5)
|
||||
|
||||
def delete(self):
|
||||
|
||||
# Click on profile icon, it's under a shadow-dom element
|
||||
root1 = self.driver.find_element_by_css_selector("#my_account")
|
||||
shadow = browser_manager.expand_shadow_element(self.driver, root1)
|
||||
profile = shadow.find_element_by_css_selector('.ql-icon-button')
|
||||
profile.click()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
# head over to settings
|
||||
settings = self.driver.find_element_by_css_selector('#settings')
|
||||
settings.click()
|
||||
time.sleep(2)
|
||||
|
||||
#accept goddamn cookies
|
||||
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/div[2]/div/button')
|
||||
time.sleep(2)
|
||||
|
||||
# select 'security' tab
|
||||
root1 = browser_manager.waitForElement(self.driver, By.XPATH, '/html/body/ql-drawer-container/ql-drawer/ql-sidenav/ql-sidenav-item[4]')
|
||||
shadow = browser_manager.expand_shadow_element(self.driver, root1)
|
||||
root1.click()
|
||||
time.sleep(2)
|
||||
|
||||
# button = shadow.find_element_by_css_selector('.sidenav-item')
|
||||
# button.click()
|
||||
|
||||
browser_manager.clickButton(self.driver, By.XPATH, '/html/body/ql-drawer-container/ql-drawer-content/main/div[3]/div[2]/div/a')
|
||||
time.sleep(5)
|
||||
|
||||
#delete history
|
||||
browser_manager.clickButton(self.driver, By.CSS_SELECTOR, '#delete_account_history_are_you_sure > div > div > div > a:nth-child(2)')
|
||||
time.sleep(8)
|
||||
|
||||
# finally accept the deletition of the account
|
||||
al = self.driver.switch_to.alert
|
||||
al.accept()
|
||||
|
||||
print("Account {} deleted!".format(self.account))
|
||||
|
||||
class RandomNameGenerator():
|
||||
def __init__(self, proxy):
|
||||
self.proxy = proxy
|
||||
self.proxyDict = {
|
||||
"socks" : proxy,
|
||||
"socksVersion" : 5
|
||||
}
|
||||
|
||||
def get_person_info(self):
|
||||
if self.proxy:
|
||||
r = requests.get('https://randomuser.me/api', proxies=self.proxyDict)
|
||||
else:
|
||||
r = requests.get('https://randomuser.me/api')
|
||||
|
||||
firstname = r.json()['results'][0]['name']['first']
|
||||
lastname = r.json()['results'][0]['name']['last']
|
||||
#use city as company
|
||||
company = r.json()['results'][0]['location']['city']
|
||||
return (firstname, lastname, company)
|
||||
|
||||
class TempMail:
|
||||
def __init__(self, browser):
|
||||
self.browser = browser
|
||||
|
||||
# Open a new tab, head over to temp-mail.org, click the delete button and get a new temp mail
|
||||
def get_new_temp_mail(self):
|
||||
# open new tab and switch to it
|
||||
self.browser.execute_script("window.open('https://temp-mail.org', 'tmp-mail');")
|
||||
self.browser.switch_to.window('tmp-mail')
|
||||
|
||||
# Wait for qwiklabs confirmation email to arrive, click it
|
||||
def accept_email(self):
|
||||
pass
|
Loading…
Reference in New Issue