Advertisement
Guest User

Untitled

a guest
Feb 1st, 2024
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import selenium.webdriver.common.action_chains
  2. import undetected_chromedriver as uc
  3. from selenium.webdriver.common.by import By
  4. from selenium.common.exceptions import NoSuchElementException
  5. from time import sleep
  6. from random import randint
  7.  
  8.  
  9. def wait():
  10.     return randint(1000, 2000) / 1000
  11.  
  12.  
  13. driver = uc.Chrome()
  14. actions = selenium.webdriver.common.action_chains.ActionChains(driver)
  15.  
  16. driver.get('https://allegro.pl/logowanie')
  17. sleep(10)
  18.  
  19. try:
  20.     input_login_element = driver.find_element(By.NAME, 'login')
  21.     input_password_element = driver.find_element(By.NAME, 'password')
  22.     login_button_element = driver.find_element(By.XPATH, '//*[@id="authForm"]/div[3]/button')
  23.     actions.pause(wait())
  24.     actions.send_keys_to_element(input_login_element, 'elo')
  25.     actions.pause(wait())
  26.     actions.send_keys_to_element(input_password_element, '320')
  27.     actions.pause(wait())
  28.     actions.click(login_button_element)
  29.     actions.perform()
  30.     actions.reset_actions()
  31. except NoSuchElementException as e:
  32.     print('NoSuchElementException:', e)
  33.  
  34. sleep(1000)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement