Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Upload of File Selenium UI Test not working for Dynamics 365 Portal

(0) ShareShare
ReportReport
Posted on by

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans