Jump to content

File path in file upload dialog is taking // to special characters.

Recommended Posts

Hi All,

All my tests are written in selenium. There is a functionality related to file upload for which i am using Auto it to upload the file. Here is the code which will enter file path in the dialog. Browser i am using is IE9. Language C#

            //enter file path 
            if (autoIt.ControlSend("", windowName, textBoxLocator, """+filePath+""") == 0)
                throw new Exception("Control dosent exists or control is not enabled");
            //click button
            if (autoIt.ControlClick("", windowName, buttonLocator) == 0)
                throw new Exception("Control dosent exists or control is not enabled");
It actually entering file path but it's considering some of portion as special characters.
For example the path i was is 
C:SCA2.6SCA2_6ProjectsSage.CRE.Cloud.UIAutomation.Package2InputFilesFilesToUpload audit (1).csv
Autually It was entering .
C:SCA2.^|SCA2_6ProjectsSage.CRE>Cloud.UIAutomation.package2InputFilesFilesToupload audit (1).csv
Can any one help me on this.Is there any escape sequence to skip this special charcters.
Edited by ademsandeep
Link to comment
Share on other sites

Hi ademsandeep,

  And welcome to the forum!

If it is always going to be the exact same path you could tie it to a variable and insert that instead:

  if (autoIt.ControlSend("", windowName, textBoxLocator, "\""+filePath+"\"") == 0)
$filePath = "C:\SCA2.^|SCA2_6\Projects\Sage.CRE>Cloud.UIAutomation.package2\InputFiles\FilesToupload\ audit (1).csv"

  if (autoIt.ControlSend("", windowName, textBoxLocator, $filePath) == 0)

otherwise you might need StringRegExpReplace .



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...