So, i make a automation to log into podcaster.spotify.com, but for some reason the code sometimes stop after it click the spotify_button
Sometimes the code work and click the next button, but more often than not it just stuck there and not doing anything.
What i've Tried to solve that :
- Implementing time.sleep
- Implementing wait_for_element_clickable
- Implementing WebDriverWait
from seleniumbase import Driver
from seleniumbase import page_actions
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from time import sleep
import pickle
# Setup
driver = Driver(headless=False, uc=True)
driver.get('https://podcasters.spotify.com/pod/dashboard/home/')
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies :
cookie['domain'] = '.spotify.com'
try :
driver.add_cookie(cookie)
except :
pass
page_actions.wait_for_element_clickable(driver,'//button[@data-encore-id="buttonPrimary"]', By.XPATH, 10)
spotify_button = driver.find_element(By.XPATH, '//button[@data-encore-id="buttonPrimary"]')
spotify_button.click()
# CODE SOMETIMES STOPS HERE
sleep(1)
page_actions.wait_for_element_clickable(driver, '//button[@data-testid="auth-accept"]', By.XPATH, 3)
driver.find_element(By.XPATH, '//button[@data-testid="auth-accept"]').click()