【发布时间】:2017-10-02 05:05:43
【问题描述】:
我已经尝试过这个页面的方法: Upload file with Selenium in Python
代码:
file_button = browser.find_element_by_id('fileUploadProxy')
file_button.send_keys('/Users/home/Downloads/1-Students-and-Parent-Email.csv')
但我收到以下错误:
Traceback (most recent call last):
File "test.py", line 110, in <module>
upload_students_results('Surname, Name')
File "test.py", line 91, in upload_students_results
file_button.send_keys('/Users/home/Downloads/1-Students-and-Parent-Email.csv')
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 349, in send_keys
'value': keys_to_typing(value)})
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 493, in _execute
return self._parent.execute(command, params)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 249, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element
(Session info: chrome=58.0.3029.96)
(Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.4 x86_64)
【问题讨论】:
-
请说明带有
id="fileUploadProxy"的元素在HTML中是如何表示的。 -
@alecxe选择文件
标签: python python-2.7 selenium