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

时间:2019-05-16 18:59:48

标签: css selenium-webdriver

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

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

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

enter image description here 元素:

在提供的摘要中,24212 int是动态的。

1 个答案:

答案 0 :(得分:-1)

您可以尝试类似的方法,而不要使用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

相关问题