I am trying to upload an attachment using Selenium (C#).
Upon checking the DOM of the site, I noticed that the link to attach files is using object tags
. Below is the HTML excerpt:
<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>
I have tried this so far:
IWebElement fileAttachTA = driver.FindElement(By.XPath("//object[@class='ruObject']")); fileAttachTA.Click(); String filePath = "C:/User/My Documents/file.txt";
Selenium was able to find the object, but, should I switch to the Windows Upload Dialog? Hoping to hear from anyone who has experience in this.
Thanks!