首页 > Web开发 > 详细

文件上传

时间:2020-11-18 15:25:52      阅读:32      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>upload_file</title>
<link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
  <div class="row-fluid">
    <div class="span6 well">
    <h3>upload_file</h3>
      <input type="file" name="file" />
    </div>
  </div>
</body>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.js"></scrip>
</html>
from selenium import webdriver
import os
from time import sleep
import win32gui
import win32con

driver = webdriver.Chrome()
file_path = file:/// + os.path.abspath(upfile.html)
# print(file_path)
driver.get(file_path)

# 定位上传按钮,添加本地文件
# 不使用同目录下的text.txt文档,是因为G盘的text.txt文档在选择文件时的windows窗口太小了,查找不到G盘无法点击
driver.find_element_by_name("file").send_keys(rC:\Users\chenyu\Desktop\1.txt)
sleep(2)
driver.quit()

 

文件上传

原文:https://www.cnblogs.com/cy-zjs/p/13999986.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!