无法在Python中选择带有硒的单选按钮

编程入门 行业动态 更新时间:2024-10-28 00:28:20
本文介绍了无法在Python中选择带有硒的单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从此选择使用Python Selenium的房间数"字段网址.

我当前的代码是:

inputBHK = driver.find_element_by_id("No_of_Rooms_newpap") input1BHK = driver.find_element_by_id("No_of_Rooms1") ActionChains(driver).click(inputBHK).click(input1BHK).perform()

除了通常的导入和初始化. 引发的异常是:

Apart from the usual import and the Initialization. The exception Raised is:

raise exception_class(message, screen, stacktrace) seleniummon.exceptions.MoveTargetOutOfBoundsException: Message: u'Offset within element cannot be scrolled into view: (0, 0): [object HTMLInputElement]' ; Stacktrace:

关于如何进行的任何想法?

Any ideas on how to proceed?

推荐答案

尝试在2次点击事件之间等待,此网站的实施看起来比较棘手且缓慢 docs.seleniumhq/docs/04_webdriver_advanced.jsp

try to wait between the 2 click events, the implementation of this site looks like tricky and slow docs.seleniumhq/docs/04_webdriver_advanced.jsp

好的,我发现了一些问题,下拉菜单存在一些问题,例如在本网站中,它们使用隐藏的单选按钮,因此,我们将单击包含单选按钮的标签(而不是单击它)也适用于span元素,而不是单击它包含文本,如果您愿意的话,可以通过text()选择

edit: OK I found something, there is some problems with tricky drop down list like in this website, they use hidden radio button, so instead of click it we will click on the label which contains the radio button (it works also on the span element which contains the text, if you prefer select by text())

from selenium import webdriver URL = 'kolkata.quikr/post-classifieds-ads/?postadcategoryid=971' driver = webdriver.Firefox() driver.get(URL) inputBHK = driver.find_element_by_id("No_of_Rooms_newpap") inputBHK.click() container = driver.find_element_by_id("No_of_Rooms_l4Attr_RadioBox_div") input1BHK = container.find_element_by_xpath(".//label[1]") input1BHK.click()

更多推荐

无法在Python中选择带有硒的单选按钮

本文发布于:2023-11-27 20:41:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639529.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单选   按钮   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!