zoukankan      html  css  js  c++  java
  • 文件上传

    <!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(r'C:UserschenyuDesktop1.txt')
    sleep(2)
    driver.quit()
  • 相关阅读:
    网页导出PDF文件
    图片翻转导航
    瀑布流之ajax
    楼梯效果
    数码时钟
    数字字母随机验证码
    kafka shell
    zookeeper shell
    正则
    Linux(一)
  • 原文地址:https://www.cnblogs.com/cy-zjs/p/13999986.html
Copyright © 2011-2022 走看看