1

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>
4
  • Are you getting any error? Commented Jun 1, 2021 at 12:01
  • i'm getting this Commented Jun 1, 2021 at 12:05
  • 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> Commented Jun 1, 2021 at 12:06
  • Show your code as well Commented Jun 1, 2021 at 12:07

4 Answers 4

2

"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()
Sign up to request clarification or add additional context in comments.

3 Comments

Same problem as before : 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> (Session info: chrome=90.0.4430.212)
You have to accept the cookies by this xpath ".//button[@id='rcc-confirm-button']" and then try the xpath for Next button
You were very close to the full answer. Click did not work because of cookies button.
1

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)

1 Comment

As soon as DOM structure changes, even this approach will stop working. It is recommended to not use full xpath in UI automation because it's unstable. But is is a good option when Selenium's click does not work even with short locators.
1

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

2 Comments

it does not locate the button : selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //span[@class="MuiButton-label" and contains(text()," because of the following error: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//span[@class="MuiButton-label" and contains(text(),"' is not a valid XPath expression.
You are right, sorry. My mistake with copy-pasting the locator. I've corrected the answer
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.