无法找到元素Selenium Python

马里奥斯

我正在尝试使用以下代码填写表格:

from selenium import webdriver
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
browser = webdriver.Chrome( chrome_options=chrome_options)
browser.get('https://www.vwe.nl/Autobedrijf/In-en-verkoop/bpm-calculator- 
doorverkoop')

time.sleep(5)

#browser.switch_to_frame(browser.find_element_by_id("_hjRemoteVarsFrame"))  

kenteken = browser.find_element_by_id('InputControl_txtKenteken')
kenteken.send_keys('simple text')

我试图查看是否有一个iframe,但是没有用。

元素的html主体

但是它会抛出一个错误:无法找到元素

朋友

您的元素位于内iframe,您需要先对其进行切换。

这是iframe定位器:By.CLASS_NAME -> iframe_bpm

您可以使用组合WebDriverWaitexpected_conditions然后利用frame_to_be_available_and_switch_to_it方法进行切换。

browser = webdriver.Chrome( chrome_options=chrome_options)
browser.get('https://www.vwe.nl/Autobedrijf/In-en-verkoop/bpm-calculator-doorverkoop')
browser.maximize_window()
WebDriverWait(browser, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CLASS_NAME, 'iframe_bpm')))

kenteken = browser.find_element_by_id('InputControl_txtKenteken')
kenteken.send_keys('simple text')

导入后:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Selenium Python无法找到元素

Selenium:Python无法从elif中找到元素

无法在Selenium Python中找到元素

无法在Selenium Python中找到元素

无法使用 xpath 找到元素 selenium python

Selenium 无法通过 id python 找到元素

Python Selenium错误:无此类元素:无法找到元素

在Python上使用Selenium无法在弹出窗口上找到元素

Python 和 Selenium:无法找到要单击的特定 (href) 元素

无法在 selenium python 中找到一个元素

无法按类名或 xpath selenium python 找到元素

带有Selenium的Python:无法找到元素错误

Selenium Chrome Webdriver无法在Python中找到元素

无法使用Selenium Python找到信用卡号的元素

使用Selenium WebDriver Python无法在iframe中找到元素

Python + Selenium-无法通过类名找到元素

无法在 Selenium 中找到元素,用于提交搜索查询的 Python

Python Selenium无法从类名找到的元素中获取属性

Python Selenium 无法通过类名和 xpath 找到元素

Python中的Selenium错误-消息:没有这样的元素:无法找到元素

没有这样的元素:无法在Python / Selenium中找到ID为ID的元素

Python:xpath 无法找到元素

Python:Xpath无法找到元素

无法找到元素:python + selennium

Selenium Web驱动程序Python无法通过ID找到元素

使用Selenium和Python无法在#shadow-root(打开)中找到Sign In元素

如何跳过带有Selenium的Python中的“无法找到具有类名的元素”错误

无法单击元素,Selenium Python

无法单击元素Python Selenium