abc
abc

Reputation: 25

Python Selenium. Can't click on a button

Hi I'm trying to click on this button "Next" on this link: https://www.sneakql.com/en-GB/launch/culturekings/womens-air-jordan-1-high-og-court-purple-au/register

I tried this but It didn't work...

chrome.find_element_by_xpath('//*[@id="gatsby-focus-wrapper"]/main/div[2]/div[2]/div[2]/div/div/div[2]/div/form/div[3]/div/div/div/button').click();

I'm getting this:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-fullWidth" tabindex="0" type="submit">...</button> is not clickable at point (456, 870). Other element would receive the click: <div class="jss3" style="flex: 1 0 300px; margin: 15px;">...</div>

Upvotes: 1

Views: 3360

Answers (4)

vitaliis
vitaliis

Reputation: 4212

You can click it as I suggested in another your question, with xpath and waiting till it's clickable:

wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'Next')]"))).click()

But before clicking this button, you will have to accept the cookies:

wait = WebDriverWait(driver, 15)
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'AGREE')]"))).click()

For this you will need to import:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

Upvotes: 0

Prophet
Prophet

Reputation: 33371

Try this:

from selenium.webdriver.common.action_chains import ActionChains

next_btn = driver.find_element_by_xpath('//span[@class="MuiButton-label" and contains(text(),"Next")]')

actions = ActionChains(driver)
actions.move_to_element(next_btn).perform()

If this doesn't help - try adding a simple

time.sleep(5)

before clicking on that button

Upvotes: 1

Pedro Kaneto Suzuki
Pedro Kaneto Suzuki

Reputation: 196

You can just click with JS

button = chrome.find_element_by_xpath('//*[@id="gatsby-focus-wrapper"]/main/div[2]/div[2]/div[2]/div/div/div[2]/div/form/div[3]/div/div/div/button')
chrome.execute_script("arguments[0].click();", button)

Upvotes: 1

itronic1990
itronic1990

Reputation: 1441

"Agree" button and "Next button" has similar class name and so "Agree" button is receiving the click.

See if this works:-


driver.find_element_by_xpath(".//button[contains(@class,'MuiButton-containedPrimary') and @type='submit']").click()

Upvotes: 2

Related Questions