Python selenium Error: no such element: Unable to locate element

Python selenium Error: no such element: Unable to locate element

我在尝试填写表格时遇到此错误。

错误:

"no such element: Unable to locate element:

{"method":"id","selector":"formId:codEmpresa"}".

如有任何帮助,我们将不胜感激。

这是我的代码:

from selenium import webdriver
chrome = webdriver.Chrome()
chrome.get("https://www3.honda.com.br/newihs")

chrome.find_element_by_id("formId:codEmpresa").send_keys("Text1")
chrome.find_element_by_id("formId:codUsuario").send_keys("Text2")
chrome.find_element_by_id("formId:senha").send_keys("Text2")
chrome.find_element_by_id("formId:j_id68").click

问题是包含您的 ID 的登录表单位于 iframe 中。尝试 https://www3.honda.com.br/newihs/pages/loginExterno.iface

from selenium import webdriver

chrome = webdriver.Chrome()
chrome.get("https://www3.honda.com.br/newihs/pages/loginExterno.iface")

chrome.find_element_by_id("formId:codEmpresa").send_keys("Text1")
chrome.find_element_by_id("formId:codUsuario").send_keys("Text2")
chrome.find_element_by_id("formId:senha").send_keys("Text2")
chrome.find_element_by_id("formId:j_id68").click