请尝试使用相对xpath尝试以下解决方案
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r"chromedriver.exe")
driver.maximize_window()
driver.get("https://playlists.bubbleapps.io/playlists")
print driver.current_url
element=WebDriverWait(driver,20).until(EC.visibility_of_element_located((By.XPATH,"//div[@class='bubble-element GroupItem group-item entry-1']//button[@class='fa fa-spotify inner-element bubble-element clickable-element']")))
element.click()
# print(elements)
# driver.find_element_by_xpath("//div[@class='bubble-element GroupItem group-item entry-1']//button[@class='fa fa-spotify inner-element bubble-element clickable-element']").click()
print driver.current_url
输出:
https://playlists.bubbleapps.io/playlists
https://open.spotify.com/playlist/5rl5QaWjWtEPv9a057w3qc
本文链接:https://www.f2er.com/3165441.html