css - 如何使用带有 selenium 网络驱动程序的 python 将数据发送到此复选框

标签 css selenium-webdriver

我正在尝试自动化此网页并将一些数据发送到具有动态@id 的复选框。

我使用了网上找到的示例代码,但由于找不到元素,测试一直失败。

网页文本框的 XPath://*[@id="undefined-Filter-undefined-24212"]

enter image description here 元素:

在提供的片段中,24212 int 是动态的。

最佳答案

您可以尝试使用 x_path 代替名称:

elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)

供引用:https://selenium-python.readthedocs.io/getting-started.html

关于css - 如何使用带有 selenium 网络驱动程序的 python 将数据发送到此复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56175009/

相关文章:

css - 有两个同名的类。如何在 Webdriver.IO 中使用 css/xpath 选择其中一个元素?

python - 需要可见元素的 xpath 定位器

python - 通过 Expected_conditions 在元素上调用 .click() 时,selenium.common.exceptions.TimeoutException

javascript - 在 IE 8 中单击标签时触发单击输入

html - div背景颜色未设置所有区域

javascript - wdCalendar buddle mousedown 事件

由于边框折叠属性,HTML 表格有一条奇怪的粗体水平线

python - 如何通过Selenium python初始化JS变量?

python - Selenium:等到文本不出现在元素中

javascript - 动画菜单 : shall I use canvas or javascript?