我正在尝试从此选择使用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中选择带有硒的单选按钮
发布评论