首先确保Button元素已经正确定位,然后使用以下代码尝试Click事件:
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
button = driver.find_element_by_xpath('YOUR XPATH HERE')
# 首先使用ActionChains激活元素
ActionChains(driver).move_to_element(button).perform()
# 尝试使用Click事件
button.click()
# 如果click无效,尝试使用Enter键来模仿单击事件
button.send_keys(Keys.ENTER)
这将尝试使用Click事件来激活Button元素。如果Click仍然无效,它将模拟Enter键以触发Button的单击事件。