Python 如何使用selenium查找输入

Python 如何使用selenium查找输入,python,selenium,Python,Selenium,我需要通过在以下输入上单击selenium来提交此表单: <div align="center"> <input type="submit" class="boton" value="Aceptar"> </div> 我也尝试过使用类名“boton”,但不起作用,您可以使用Javascript executor来实现 button = driver.find_element_b

我需要通过在以下输入上单击selenium来提交此表单:

<div align="center">
 <input type="submit" class="boton" value="Aceptar">
</div>

我也尝试过使用类名“boton”,但不起作用,

您可以使用Javascript executor来实现

button = driver.find_element_by_xpath("//input[@value='Aceptar']")
driver.execute_script("arguments[0].click();", button)

您可以使用Javascript执行器来执行

button = driver.find_element_by_xpath("//input[@value='Aceptar']")
driver.execute_script("arguments[0].click();", button)

利用
execute\u script
设置输入字段的值属性。检查以下代码块:

input_field= driver.find_element_by_xpath("//input[@value='Aceptar']")

driver.execute_script("[0].click();",input_field)

利用
execute\u script
设置输入字段的值属性。检查以下代码块:

input_field= driver.find_element_by_xpath("//input[@value='Aceptar']")

driver.execute_script("[0].click();",input_field)

要单击
input
元素,需要首先切换到
iframe

诱导
WebDriverWait
()并等待
frame\u可用,然后切换到\u it
()

诱导
WebDriverWait
()并等待
元素可点击
()

您需要导入以下库

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

更新

Input元素
存在于嵌套的iframe中。为了访问,您需要切换到嵌套的
iframe

WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.iframeTGR")))
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"busqueda")))
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//input[@value='Aceptar'][@class='boton']"))).click()

要单击
input
元素,需要首先切换到
iframe

诱导
WebDriverWait
()并等待
frame\u可用,然后切换到\u it
()

诱导
WebDriverWait
()并等待
元素可点击
()

您需要导入以下库

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

更新

Input元素
存在于嵌套的iframe中。为了访问,您需要切换到嵌套的
iframe

WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.iframeTGR")))
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"busqueda")))
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//input[@value='Aceptar'][@class='boton']"))).click()

你能详细说明一下“不起作用”吗?有错误吗?有什么事情发生吗?我的意思是什么都没有发生,尝试下面的答案我得到消息:没有这样的元素:找不到元素:{“method”:“xpath”,“selector”:“//input[@value='Aceptar']”}尝试检查您的DOM树,如果在输入元素上方有
iframe
?我有一个隐式的\u wait(20)@JaSONCan请详细说明“不起作用”?有错误吗?发生了什么事吗?我的意思是什么都没有发生,尝试下面的答案我得到消息:没有这样的元素:无法定位元素:{“方法”:“xpath”,“选择器”:“//input[@value='Aceptar']”“}尝试检查您的DOM树,如果输入元素上方有
iframe
?我有一个隐式的等待(20)@Jason谢谢你的回答,这对我帮助很大。仍然不起作用(TimeoutException)但现在我知道我需要在iframe上搜索。事实上,我需要访问的输入在另一个iframe中的一个iframe中,这是html代码的简历#document…#document…#document…#这是我的输入@fukurowl:我已经更新了
嵌套iframe
的答案。希望这有帮助。谢谢你的回答,谢谢你帮了我很多忙。仍然不工作(TimeoutException)但现在我知道我需要在iframe上搜索。事实上,我需要访问的输入是在另一个iframe中的一个iframe中,这是html代码的简历#document…#document..#这是我的输入@fukurowl:我已经更新了
嵌套iframe
的答案。希望这有帮助。