Html 选择按钮

Html 选择按钮,html,python-3.x,selenium,Html,Python 3.x,Selenium,我正在尝试自动化这个网站,你可以在那里参加测验。我试着按一个按钮,但我不能 去 您可以先等待元素可单击,然后单击它。 你可以这样做: WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Go!']"))).click() 注意:您必须添加以下导入: 尝试使用xpath查找元素更改该按钮。单击以按钮。提交 以下是使用selenium和geckodriver登录的简单代码:

我正在尝试自动化这个网站,你可以在那里参加测验。我试着按一个按钮,但我不能


您可以先等待元素可单击,然后单击它。 你可以这样做:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Go!']"))).click()
注意:您必须添加以下导入:


尝试使用xpath查找元素更改该按钮。单击以按钮。提交 以下是使用selenium和geckodriver登录的简单代码:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("write the site here")

username = "write your username here"
password = "write your pass here"

username_path = 'write xpath'
password_path = 'write xpath'
loginbutton_path = 'write xpath'

username_element = driver.find_element_by_xpath(username_path)
pass_element = driver.find_element_by_xpath(password_path)
button_element = driver.find_element_by_xpath(loginbutton_path)

username_element.send_keys(username)
pass_element.send_keys(password)
button_element.submit()

要查找xpath,请右键单击所需内容并选择inspect元素,然后再次右键单击突出显示的代码,然后从“复制”中选择“复制xpath”,然后再将其传递到“代码”。

它给出了以下错误:selenium.common.exceptions.TimeoutException:Message:@shmifful您可以检查html结构中是否存在iframe吗?它是什么检查html结构并检查是否有任何标记。页面上没有带有tasso-button__绿色类的按钮。我相信绿色按钮应该在登录后可见。尝试等待,直到它变得可见。
from selenium import webdriver

driver = webdriver.Firefox()
driver.get("write the site here")

username = "write your username here"
password = "write your pass here"

username_path = 'write xpath'
password_path = 'write xpath'
loginbutton_path = 'write xpath'

username_element = driver.find_element_by_xpath(username_path)
pass_element = driver.find_element_by_xpath(password_path)
button_element = driver.find_element_by_xpath(loginbutton_path)

username_element.send_keys(username)
pass_element.send_keys(password)
button_element.submit()