我正尝试使用Selenium(C#)上传附件。如何在Selenium中使用Windows上传对话框处理文件上传
在检查网站的DOM时,我注意到附加文件的链接是使用object tags
。 下面是HTML摘录:
<object id="ctl00_mainContent_rauFilessilverlight03" class="ruObject" height="22px" type="application/x-silverlight-2" data="data:application/x-silverlight-2," style="width: 100%;">
<param value="/App/somelongjunkyparameters" name="source"/>
<param value="true" name="windowless"/> <param value="transparent" name="background"/>
<param value="some number" name="minRuntimeVersion"/>
<param value="PostData=anotherlongjunkyparameters,SilverlightRowId=ctl00_mainContent_rauFilessilverlight03,AsyncUploadId=ctl00_mainContent_rauFiles,MultipleSelection=Disabled,AllowedFileExtensions=,ServiceHandlerUrl=/App/Telerik.Web.UI.WebResource type=rau,MaxFileSize=0" name="InitParams"/>
<param value="true" name="autoUpgrade"/>
</object>
到目前为止,我已经试过这样:
IWebElement fileAttachTA = driver.FindElement(By.XPath("//object[@class='ruObject']"));
fileAttachTA.Click();
String filePath = "C:/User/My Documents/file.txt";
硒能找到对象,但是,我要切换到Windows上传对话框?希望听到任何有此经验的人。
谢谢!
你的代码有什么问题?有什么异常或其他什么? –
它只是不会切换到Windows上传对话框 – Marj