我正在开发一个涉及以下关注者的instagram漫游器。它通过登录,单击“关注”来与硒一起使用,然后对于每个用户都应单击“取消关注”按钮。有一个问题:当我尝试单击它时,发生此异常:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button class="sqdOP L3NKy _4pI4F _8A5w5 " type="button">...</button> is not clickable at point (594, 155). Other element would receive the click: <span class="">...</span>
(Session info: chrome=79.0.3945.130)
有我的代码:
unfollow_buttons = driver.find_elements_by_css_selector('.sqdOP.L3NKy._8A5w5')
for button in unfollow_buttons:
ui.WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.CSS_SELECTOR,
'.sqdOP.L3NKy._8A5w5')))
button.click()
ui.WebDriverWait(driver, 2).until(
EC.element_to_be_clickable((By.XPATH, '/html/body/div[5]/div/div/div[3]/button[1]')))
driver.find_element_by_xpath('/html/body/div[5]/div/div/div[3]/button[1]').click()
我知道其他项目会获得点击,但是我不知道它是什么项目。有谁可以帮助我吗?
[如果有人看到了,我以这种方式解决了这个问题:
unfollow_buttons = driver.find_elements_by_css_selector('.sqdOP.L3NKy._8A5w5')
for button in unfollow_buttons:
if button.text == "Following":
ui.WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.CSS_SELECTOR,
'.sqdOP.L3NKy._8A5w5')))
actions = ActionChains(driver)
actions.move_to_element(button).click().perform()
ui.WebDriverWait(driver, 2).until(
EC.element_to_be_clickable((By.XPATH,'/html/body/div[5]/div/div/div[3]/button[1]')))
driver.find_element_by_xpath('/html/body/div[5]/div/div/div[3]/button[1]').click() # UNFOLLOW CONFIRMATION
time.sleep(1)