Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- @app.get("/paypal2")
- async def _paypal2(email :str,
- password :Optional[str] =None,
- limit :Optional[int] =None,
- mean_arrival_rate:Optional[float]=None,
- )->Response:#Union[Response,FileResponse]:
- """
- Sign me up! (PayPal)
- Use Case: shekeler heckler
- """
- await logger.adebug('_paypal2 %s %s %s %s', email, password, limit, mean_arrival_rate)
- _url:str = 'https://www.paypal.com/us/webapps/mpp/account-selection'
- return await _login_helper(_paypal2_helper, _url, email, password, limit, mean_arrival_rate)
- def _paypal_security_challenge(driver:WebDriver)->None: # FIXME captchas are hard
- nonlocal timeout
- try:
- logger.debug('looking for the get captcha')
- #by = By.XPATH
- #cond = "//div[@aria-labelledby='ally-label']"
- by = By.ID
- cond = "checkbox"
- _captcha = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- logger.debug('scrolling the captcha')
- #driver.execute_script('arguments[0].scrollIntoView();', _captcha)
- try:
- logger.debug('waiting for captcha to become visible')
- _captcha = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- try:
- logger.debug('waiting for captcha to become clickable')
- _captcha = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- logger.debug('found the captcha')
- driver.execute_script("arguments[0].click();", _captcha)
- ActionChains(driver).move_to_element(_captcha) .click(_captcha) .perform()
- logger.debug('pressed enter')
- except TimeoutException as e:
- logger.exception(e)
- def _paypal2_helper(driver:WebDriver, email:str, passwd:str, mean_arrival_rate:Optional[float])->Optional[str]:
- """ demonstrate the paypal signup sequence """
- logger.debug('_paypal2_helper %s %s', email, passwd)
- assert isinstance(passwd,str)
- nonlocal timeout
- #logger.debug('looking for the get account')
- #by = By.XPATH
- #cond = "//input[@value='Personal']"
- #_account = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- #logger.debug('scrolling the account')
- ##driver.execute_script('arguments[0].scrollIntoView();', _account)
- #try:
- # logger.debug('waiting for account to become visible')
- # _account = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #try:
- # logger.debug('waiting for account to become clickable')
- # _account = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #logger.debug('found the account')
- #driver.execute_script("arguments[0].click();", _account)
- #
- #ActionChains(driver).move_to_element(_account) .click(_account) .perform()
- #logger.debug('pressed enter')
- #
- logger.debug('looking for the start')
- by = By.XPATH
- cond = "//a[text()='Get Started']"
- _start = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- logger.debug('scrolling the start')
- #driver.execute_script('arguments[0].scrollIntoView();', _start)
- try:
- logger.debug('waiting for start to become visible')
- _start = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- try:
- logger.debug('waiting for start to become clickable')
- _start = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- logger.debug('found the start')
- driver.execute_script("arguments[0].click();", _start)
- ActionChains(driver).move_to_element(_start) .click(_start) .perform()
- logger.debug('pressed enter')
- #
- _paypal_security_challenge(driver)
- #
- logger.debug('looking for the get email')
- by = By.XPATH
- cond = "//input[@aria-labelledby='paypalAccountData_email-label']"
- _email = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- logger.debug('scrolling the email')
- #driver.execute_script('arguments[0].scrollIntoView();', _email)
- try:
- logger.debug('waiting for email to become visible')
- _email = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- try:
- logger.debug('waiting for email to become clickable')
- _email = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- logger.debug('found the email')
- driver.execute_script("arguments[0].click();", _email)
- ActionChains(driver).move_to_element(_email) .click(_email).send_keys(email).send_keys(Keys.ENTER) .perform()
- logger.debug('pressed enter')
- #
- _paypal_security_challenge(driver)
- #
- #logger.debug('looking for the get next')
- #by = By.XPATH
- #cond = "//button[text()='Next']"
- #_next = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- #logger.debug('scrolling the next')
- ##driver.execute_script('arguments[0].scrollIntoView();', _next)
- #try:
- # logger.debug('waiting for next to become visible')
- # _next = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #try:
- # logger.debug('waiting for next to become clickable')
- # _next = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #logger.debug('found the next')
- #driver.execute_script("arguments[0].click();", _next)
- #ActionChains(driver).move_to_element(_next) .click(_next) .perform()
- #logger.debug('pressed enter')
- #
- logger.debug('looking for the get phone')
- by = By.XPATH
- cond = "//input[@aria-describedby='message_paypalAccountData_phone']"
- _phone = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- logger.debug('scrolling the phone')
- #driver.execute_script('arguments[0].scrollIntoView();', _phone)
- try:
- logger.debug('waiting for phone to become visible')
- _phone = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- try:
- logger.debug('waiting for phone to become clickable')
- _phone = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- logger.debug('found the phone')
- driver.execute_script("arguments[0].click();", _phone)
- phone = ''.join([randrange(0,9) for _ in range(10)])
- ActionChains(driver).move_to_element(_phone) .click(_phone).send_keys(phone).send_keys(Keys.ENTER) .perform()
- logger.debug('pressed enter')
- #
- #logger.debug('looking for the get next')
- #by = By.XPATH
- #cond = "//button[text()='Next']"
- #_next = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- #logger.debug('scrolling the next')
- ##driver.execute_script('arguments[0].scrollIntoView();', _next)
- #try:
- # logger.debug('waiting for next to become visible')
- # _next = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #try:
- # logger.debug('waiting for next to become clickable')
- # _next = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- #except TimeoutException as e:
- # logger.exception(e)
- #logger.debug('found the next')
- #driver.execute_script("arguments[0].click();", _next)
- #ActionChains(driver).move_to_element(_next) .click(_next) .perform()
- #logger.debug('pressed enter')
- # FIXME phones are hard
- for k in range(1, 6+1):
- assert (1 <= k and k <= 6)
- logger.debug('looking for the get security')
- by = By.XPATH
- cond = str(f"//input[@aria-label='Security code digit {k}']")
- _security = WebDriverWait(driver, timeout).until( EC.presence_of_element_located ((by, cond)))
- logger.debug('scrolling the security')
- #driver.execute_script('arguments[0].scrollIntoView();', _security)
- try:
- logger.debug('waiting for security to become visible')
- _security = WebDriverWait(driver, timeout).until( EC.visibility_of_element_located((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- try:
- logger.debug('waiting for security to become clickable')
- _security = WebDriverWait(driver, timeout).until( EC.element_to_be_clickable ((by, cond)))
- except TimeoutException as e:
- logger.exception(e)
- logger.debug('found the security')
- driver.execute_script("arguments[0].click();", _security)
- security = randrange(1, 9)
- ActionChains(driver).move_to_element(_security) .click(_security).send_keys(security).send_keys(Keys.ENTER) .perform()
- logger.debug('pressed enter')
- #
- # TODO
- try:
- logger.debug('looking for logout')
- raise NotImplementedError()
- logger.debug('found the logout')
- return passwd
- except NoSuchElementException as e:
- logger.error('could not find logout: %s', e)
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement