TA的每日心情 | 奋斗 2020-12-11 22:39 |
---|
签到天数: 120 天 连续签到: 1 天 [LV.7]测试师长
|
源程序:
from selenium import webdriver
import os
import time
driver=webdriver.Ie()
file_path='file:///'+os.path.abspath('upfile.html')
driver.get(file_path)
#定位上传按钮,添加本地文件
driver.find_elements_by_name("file")[0].send_keys('D:\\upload_file.txt')
time.sleep(10)
driver.quit()
报错信息:
Traceback (most recent call last):
File "F:/python/upload_file.py", line 10, in <module>
driver.find_elements_by_name("file").send_keys('D:\\upload_file.txt')
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 374, in find_elements_by_name
return self.find_elements(by=By.NAME, value=name)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 771, in find_elements
{'using': by, 'value': value})['value']
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Finding elements with name == filereturned an unexpected error
补充说明:在Firefox下运行正常,修改为Ie就报上面的错误,希望专业人士能解答。
|
|