selenium+JS网页免弹框上传图片or文件

这里以上传图片为例

 

 

 找到上传按钮附近的input元素下type=file

selenium直接执行代码

file_path = r'C:\Users\Administrator\Desktop\imge\xxxxxx.jpg'需要上传的图片路径
upload_div_loc = 'input[type="file"]'#操作元素
driver.find_elements_by_css_selector(upload_div_loc)[0].send_keys(file_path)

  

两个参数,轻松解决

posted @ 2023-04-11 15:42  究极不吃香菜  阅读(23)  评论(0编辑  收藏  举报