0

I'm trying to use Chrome Webdriver to click the shopping cart button on https://papajohns.com/order/menu. So far, I've tried using

driver.find_element_by_xpath('''//*[@id="cart"]/a''').click()
driver.find_element_by_id('cart').click()
driver.execute_script("arguments[0].click();", element)
element.send_keys(Keys.ENTER)

This is the HTML of the cart button object:

<li id="cart" class="nav-main-item nav-main-cart" data-freight-target="nav-total"> <a href=" /order/view-cart" data-track-click="top-nav|Shopping cart"> <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" class="icon"><title>Shopping cart</title> <path fill="currentColor" d="M12 12c.8 0 1.5.7 1.5 1.5S12.8 15 12 15s-1.5-.7-1.5-1.5.7-1.5 1.5-1.5zM0 0h2.5l.7 1.5h11.1c.5 0 .8.4.8.8 0 .1 0 .2-.1.4l-2.7 4.9c-.3.4-.8.6-1.4.6H5.3l-.6 1.2v.1c0 .1.1.1.2.1h8.7v1.5h-9c-.9.1-1.6-.6-1.6-1.4 0-.2.1-.5.1-.7l1-1.9-2.6-5.6H0V0zm4.5 12c.8 0 1.5.7 1.5 1.5S5.3 15 4.5 15 3 14.3 3 13.5 3.7 12 4.5 12z"></path> </svg> <span class="badge nodisplay" aria-label="items in cart">0</span> <span class="price"><span class="sup">$</span>0.00</span> </a> </li>

I keep getting the following exception:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element ... is not clickable at point (955, 35). Other element would receive the click: ...

It seems something is different about the cart button compared to other buttons I've inspected and clicked on the site. Can anyone give this a try and see if they can find a solution? Thanks

  • The XPath worked fine for me and I also used the CSS selector, `"#cart > a"`, successfully. You might try those again. – JeffC Jun 09 '18 at 16:34
  • JeffC - Could you include the HTML of the specific item you used the XPath / CSS selector for? I'm thinking I may be using the wrong object or something. – Yung_Grasshopper Jun 09 '18 at 16:46
  • In your question you stated that you were trying to click the shopping cart button. That's what I clicked. You should add the HTML that *you* are trying to click in your question and then update with the results of the newer code attempts. – JeffC Jun 09 '18 at 17:22
  • The most common cause is not waiting to finish pageloading. I'm using explicit waits (java): WebDriverWait wait5s = new WebDriverWait(driver,5); WebElement myElement = wait5s.until(ExpectedConditions.elementToBeClickable(locator));myElement.click(); But without html source code I can't say, this is the case. – pburgr Jun 11 '18 at 06:52

0 Answers0