I have an issue with one of my Selenium UI tests that is running on a Dynamics 365 portal. The test is very simple.
1. It logs into the portal
2. Navigates to a certain page
3. Uses SendKeys to get the file from a specific location
4. Clicks upload button
When I run this UI test I receive a message stating "Please only upload csv files". This is correct behaviour in the event that a user is attempting to upload a different file type. However, in this scenario the file extension is correct and should upload. If I manually go into the portal and upload the exact same file myself, it uploads without error.
Has anyone experienced a similiar sort of issue with a D365 portal? Or any other portal/ website alike?
Kind Regards, Shea
Here is the Clicking of the upload button. I have used By XPath, Id, LinkText etc all works fine.
public static void BulkUploadBrowse()
{
try
{
//Click upload button
var browse = Driver.Instance.FindElement(By.CssSelector("#AttachFile"));
browse.Click();
Thread.Sleep(1000);
}
catch (Exception ex)
{
throw (ex);
}
}
Here is the logic for uploading the file:
public static void UploadFile()
{
// Method 1 : File Upload Using Send Keys
try
{
SendKeys.SendWait(@"C:\Users\Shea.Leonard\Desktop\Upload20190625161051.csv");
Thread.Sleep(1500);
SendKeys.SendWait(@"{ENTER}");
}
catch (Exception ex)
{
throw (ex);
}
}
I have also attempted another method using the AutoITX3 Library:
//Method 2 : File Upload Using Auto IT || Leaving this here incase method 1 stops working.
AutoItX3 autoIt = new AutoItX3();
autoIt.WinActivate("Open");
autoIt.Send(@"F:\Users\adm_shea.leonard\Desktop\Upload20190625161051.csv");
Thread.Sleep(1000);
autoIt.Send("{ENTER}");
However, still the same result :(
Based on this it should upload a file successfully. Not sure if this is an issue with Selenium WebDriver and the D365 Portal Add-on. The error message we receive, "Please only upload csv files", is specified in the Web Form configuration of the Dynamics portal.
That same file is valid because as mentioned I have been able to successfully upload it manually through the portal.
Any help would be much appreciated.
Thanks, Shea