爬虫程序的HTML代码
<select size="10" name="ctl00$ContentPlaceHolder1$lstMake" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$lstMake\',\'\')', 0)" id="ctl00_ContentPlaceHolder1_lstMake">
<option value="913163">Abarth</option>
<option value="913229">Acura (USA / CAN)</option>
<option value="910001">Alfa Romeo</option>
<option value="910066">Aro</option>
<option value="910071">Asia</option>
<option value="910002">Aston Martin</option>
<option value="910052">Audi</option>
<option value="910003">Austin</option>
<option value="910004">Bentley</option>
<option value="910005">BMW (EU)</option>
<option value="913536">BMW (USA)</option>
<option value="910072">Brabus</option>
...
</select>
Python代码
^{pr2}$错误日志
Traceback (most recent call last):
File "/Users/MyeongSic/PycharmProjects/crawler/SeriesCounter.py", line 17, in <module>
company_option.select_by_index(2)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/select.py", line 101, in select_by_index
self._setSelected(opt)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/support/select.py", line 212, in _setSelected
option.click()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 77, in click
self._execute(Command.CLICK_ELEMENT)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated
(Session info: chrome=54.0.2840.87)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.1 x86_64)
我很努力。它发生了错误为什么要这样做?我不明白。我尝试了另一个选择选项样本。它没有错误,但这不是执行。你能告诉我这个错误吗?在
添加注释(细节图像)
我需要使摇篮'选择类型'的位置自动
使用以下代码:
在代码中,您试图在元素在DOM上可用之前单击
更新2:根据新要求删除旧代码:
^{pr2}$此代码首先从下拉列表中获取所有值,然后依次选择并打印该车的当前型号
以下是一些汽车的示例输出:
你应该换衣服}
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#ctl00_ContentPlaceHolder1_lstMake > option")))
到{相关问题 更多 >
编程相关推荐