selenium 文件上传

 selenium文件上传

 通过input标签实现的上传功能,可将其看做是一个输入框,通过send_key()实现文件上传。

 创建一个test.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>

网页效果:

通过以下代码进行文件上传:

 
原文地址:https://www.cnblogs.com/aszeno/p/10317487.html