Код: Выделить всё
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException
import pyautogui
import time
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://tinder.com/app/recs")
time.sleep(2)
# login = driver.find_element(By.CSS_SELECTOR,'a.c1p6lbu0 Miw(120px)')
login = driver.find_element(By.XPATH,'//*[@id="c-1330188189"]/div/div[1]/div/main/div[1]/div/div/div/div/div/header/div/div[2]/div[2]/a')
login.click()
time.sleep(2)
login_facebook = driver.find_element(By.XPATH,'//*[@id="c1236398031"]/div/div[1]/div/div[1]/div/div/div[2]/div[2]/span/div[2]/button')
login_facebook.click()
base_window = driver.window_handles[0]
fb_login_window = driver.window_handles[1]
driver.switch_to.window(fb_login_window)
print(driver.title)
driver.implicitly_wait(2)
phone_no = driver.find_element(By.XPATH,' /html/body/div/div[2]/div[1]/form/div/div[1]/div/input')
phone_no.send_keys("XXXXX")
# phone_no = driver.find_element(By.CSS_SELECTOR,"div input")
pass_word = driver.find_element(By.XPATH,'//*[@id="pass"]')
pass_word.send_keys( "XXXXXXx!",Keys.ENTER)
old = driver.window_handles[0]
new = driver.window_handles[1]
driver.switch_to.window(new)
print(driver.title)
driver.switch_to.window(base_window)
# Tinder Setup - sleeping for 8 seconds to load everythingbutton Lts($ls-s) Z(0) CenterAlign Mx(a) Cur(p) Tt(u) Bdrs(50%) P(0) Fw($semibold) focus-button-style Bxsh($bxsh-btn) Expand Trstf(e) Trsdu($normal) Wc($transform) Pe(a) Scale(1.1):h Scale(.9):a Bgi($g-ds-background-like):a
time.sleep(20)
location_accept = driver.find_element(By.XPATH,'//*[@id="c1236398031"]/div/div/div/div/div[3]/button[1]')
location_accept.click()
notify_button = driver.find_element(By.XPATH,'//*[@id="c1236398031"]/div/div[1]/div/div/div[3]/button[2]')
notify_button.click()
time.sleep(6)
accept_cookies = driver.find_element(By.XPATH,'//*[@id="c-1330188189"]/div/div[2]/div/div/div[1]/div[2]/button')
accept_cookies.click()
time.sleep(12)
game_on = True
driver.switchTo().window(mainwindow);
while game_on:
try:
accept = driver.find_element(By.XPATH,'//*[@id="c-1330188189"]/div/div[1]/div[2]/div/div/main/div/div/div[1]/div/div[3]/div/div[4]/button')
game_on = True
while game_on:
accept.click()
except NoSuchElementException:
print("testing again")
time.sleep(3)
like = driver.find_element(By.XPATH,'//*[@id="q1503199108"]/div/div[1]/div[2]/div/div/main/div/div/div[1]/div/div[3]/div/div[4]/button/span/span')
like.click()
Чтобы иметь возможность нажать целевую кнопку
Подробнее здесь: https://stackoverflow.com/questions/787 ... ing-an-err