Selenium webdriver 取消绑定以单击此按钮

Selenium webdriver 取消绑定以单击此按钮,selenium-webdriver,Selenium Webdriver,我无法选择此按钮。我已经尝试了大部分定位器,即XPath、contain、CSS选择器,但仍然没有单击 在上面的图像链接中,高亮显示了要单击的按钮。如果在Windows上运行此功能,我会尝试使用X/Y坐标和宏工具(如AppRobotic)进行单击。我看到的一个类似问题是,页面继续加载时遇到问题,这会阻止单击。如果是这样的话,我通常会尝试停止页面加载,并与页面进行一些交互,类似这样的操作应该适合您: import win32com.client from win32com.client impor

我无法选择此按钮。我已经尝试了大部分定位器,即XPath、contain、CSS选择器,但仍然没有单击


在上面的图像链接中,高亮显示了要单击的按钮。

如果在Windows上运行此功能,我会尝试使用X/Y坐标和宏工具(如AppRobotic)进行单击。我看到的一个类似问题是,页面继续加载时遇到问题,这会阻止单击。如果是这样的话,我通常会尝试停止页面加载,并与页面进行一些交互,类似这样的操作应该适合您:

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)

Span不可单击。您想改为单击该按钮。如果您可以提供整个DOM元素,我可以创建一个xpath供您使用,但基于所示内容

ul.checkout-types > li > button
这就是你的道路。使用来自用户Mike的变量

driver.click("ul.checkout-types > li > button");
您需要单击,而不是,相关的如下内容:

//button[@title='Proceed to Checkout']
演示:

更多信息:


你能给我提供简单的代码吗。因为我想用java在selenium中实现它。