如何使用VBA上载文件(输入文件) [英] How to upload a file using VBA (input file)

查看:190
本文介绍了如何使用VBA上载文件(输入文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个CSV文件,它需要上传到网站上,但是这个网站有一个输入文件。



我知道这是不可能的,因为我花了就像三个星期的回答,我找到了另一种方式来上传文件没有使用输入类型文件* ,所以我想知道是否有人找到了解决我的问题



这是我有:

这是我的firt尝试像任何一般人使用VBA:

 设置UploadCSV = IEDoc.getElementById(namecsv)
UploadCSV.Value =something\toto.csv


$ b

这是我的输入文件:

$ p $ < input name =filenameclass =text align_centerid =nomfichiercsvtype =filesize =24accept =text / html,text / plainvalue =/>

谢谢




我试过了SendKeys函数,没有运气。在VB中,你可以使用下面的代码。标识元素:

  driver.FindElementById(元素的ID)SendKeys(输入文件的路径) 

如果在您尝试上传文件时框架发生变化,则需要切换到新的帧。
如果元素不存在Id,则使用其他Web元素选择器方法。


I have this CSV file that it need to be uploaded in a WebSite , but this website have an input type file.

I know its pretty impossible because i spent like three weeks loking for an answer,i found another way to upload the file WITHOUT USING THE INPUT TYPE FILE* so i was wondering if anyone found a solution to my probleme

This is what i have :

This is my firt attempt like any average personne using VBA :

  Set UploadCSV = IEDoc.getElementById("namecsv") 
  UploadCSV.Value = "something\toto.csv" 

This is my input type file:

    <input name="filename" class="text align_center" id="nomfichiercsv" type="file" size="24" accept="text/html,text/plain" value=""/> 

Thank's


I tried the SendKeys function no luck

解决方案

In VBA, you can use the below code after you have identified the element:

driver.FindElementById("Id of the element").SendKeys ("path to the input file")

If the frame changes when you are trying to upload the file, you will need to switch to the new frame. If Id is not present for the element, use other Web Element selector methods.

这篇关于如何使用VBA上载文件(输入文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆