上传文件2

# -*- coding: utf-8 -*-
from os.path import dirname, abspath
import sys
from selenium import webdriver

filePath = dirname(abspath(__file__))
print(filePath)

driver = webdriver.Firefox()
driver.get('http://sahitest.com/demo/php/fileUpload.htm')
upload = driver.find_element_by_id('file')

# driver.get('https://pan.baidu.com/disk/home?#/all?path=%2F&vmode=list')
# upload = driver.find_element_by_id('h5Input1')

upload.send_keys(filePath + '\\异常.py')  # send_keys
print(upload.get_attribute('value'))# check value


driver.quit()

 



posted @ 2020-02-15 21:48  gupanpan  阅读(64)  评论(0)    收藏  举报