Reputation: 1
I am unable to select this button. I have tried most of the locator i.e XPath, contain, CSS selector still not clicking.enter image description here
In the above image link, the highlight shows the button to be clicked.
Upvotes: 0
Views: 68
Reputation: 168072
You need to click the <button>
, not the <span>
, the relevant XPath locator would be something like:
//button[@title='Proceed to Checkout']
Demo:
More information:
Upvotes: 1
Reputation: 11
Span is not clickable. You want to click the button instead. If you can provide the entire DOM element, I can create a xpath for you to use but based on what is shown,
ul.checkout-types > li > button
is your path. Using the variable from user Mike,
driver.click("ul.checkout-types > li > button");
Upvotes: 0
Reputation: 26
I'd try clicking by using X/Y coordinates with a macro tool like AppRobotic if you're running this on Windows. A similar question I saw was running into issues with the page continuing to load, which was preventing the click. If so, I usually try stopping the page load, and interacting with the page a bit, something like this should work for you:
import win32com.client
from win32com.client import Dispatch
x = win32com.client.Dispatch("AppRobotic.API")
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://www.google.com')
# wait 20 seconds
x.Wait(20000)
# scroll down a couple of times in case page javascript is waiting for user interaction
x.Type("{DOWN}")
x.Wait(2000)
x.Type("{DOWN}")
x.Wait(2000)
# forcefully stop pageload at this point
driver.execute_script("window.stop();")
# if clicking with Selenium still does not work here, use screen coordinates
x.MoveCursor(xCoord, yCoord)
x.MouseLeftClick
x.Wait(2000)
Upvotes: 0