72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
|
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
|
||
|
|
||
|
class QL_DeleteAccount:
|
||
|
def __init__(self, account):
|
||
|
self.account = account
|
||
|
|
||
|
def delete_account(self):
|
||
|
self.driver = browser_manager.start_browser()
|
||
|
self.sign_in()
|
||
|
self.delete()
|
||
|
|
||
|
def sign_in(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))
|