首页 > 解决方案 > VBA Selenium with Chrome - 将文件上传到网页

问题描述

  1. 我正在使用VBA自动Chrome将文件上传到站点,button类型File

  2. 我不知道在 chrome 中上传脚本

我当前的 VBA:

Sub UploadFile()
    Dim bot As WebDriver
    Set bot = New WebDriver
    bot.Start "chrome"
    bot.Get "https://tutorialehtml.com/en/html-tutorial-upload-form/"

         '#continue script here please"
End Sub

标签: excelvbaselenium

解决方案


如果有任何带有属性的输入字段,type = 'file'您可以使用以下代码:

bot.FindElementByCss("input[type='file']").SendKeys "path of file"

推荐阅读