13-上传文件之send_keys

简介: 13-上传文件之send_keys

input标签

  • 先定位input标签,type='file'
  • 使用send_keys上传文件
1. # 先点击,再上传
2. driver.find_element_by_name('file').click()
3. driver.find_element_by_name('file').send_keys(文件路径)

代码实例

1. # -*- coding: utf-8 -*-
2. # @Time    : 2021/1/16
3. # @Author  : 大海
4. 
5. import time
6. from selenium import webdriver
7. 
8. # 草料二维-码识别二维码获取网址
9. driver = webdriver.Chrome()
10. driver.maximize_window()
11. driver.get('https://cli.im/tools')
12. ele = driver.find_element_by_id('feature-item-upload')
13. driver.execute_script('arguments[0].scrollIntoView(false);', ele)
14. driver.execute_script("document.getElementById('feature-item-upload').click()")
15. ele.send_keys(r'二维码路径')
16. time.sleep(5)
17. url = driver.find_element_by_xpath("//*[@class='result-outer']/div").text
18. print(url)
19. driver.quit()

 

相关文章
eggjs 项目报错 Cookie need secret key to sign and encrypt. Please set config.keys first
eggjs 项目报错 Cookie need secret key to sign and encrypt. Please set config.keys first
305 0
eggjs 项目报错 Cookie need secret key to sign and encrypt. Please set config.keys first
|
4月前
Error unprotecting the session cookie.The key {...} was not found in the key ring.
Error unprotecting the session cookie.The key {...} was not found in the key ring.
80 0
|
监控 开发工具
Zabbix自定义KEY报错ZBX_NOTSUPPORTED: Unsupported item key.
[root@zabbix bin]# ./zabbix_get -s 192.217.24.47 -k jump-server ZBX_NOTSUPPORTED: Unsupported item key.
9863 0
|
7月前
|
Dubbo 应用服务中间件 对象存储
上传文件Dubbo报错: Data length too large: xxxxx, max payload: 8388608
上传文件Dubbo报错: Data length too large: xxxxx, max payload: 8388608
497 0
|
网络协议 安全 Linux
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
3271 1
|
数据采集 JSON 数据格式
Python爬虫:Request Payload和Form Data的简单区别
Python爬虫:Request Payload和Form Data的简单区别
553 0
|
对象存储
上传文件到OSS报错:[Server]Unable to execute HTTP request: Position is not equal to file length
上传文件到OSS报错:[Server]Unable to execute HTTP request: Position is not equal to file length
1155 0
|
数据安全/隐私保护 Go 存储
|
Web App开发 移动开发 PHP