Page 1 of 1

How to perform file based operation in Ranorex

Posted: Thu Nov 29, 2018 8:32 am
by mohan.pentyala
Hi Team,

I have a scenario i.e navigate to a path in D Drive save a file from my application.validate that whether that file is saved in the specified location.
Scenario 2 : Navigate to the same path and validate that file is available and if yes select that file .

Can you please help me to achieve this

Note : When i click on save from my application it will open the local windows file save window

Re: How to perform file based operation in Ranorex

Posted: Thu Nov 29, 2018 2:38 pm
by odklizec
Hi,

I'm afraid, there are not enough details about the AUT and your scenario, to provide a reasonable help. Generally speaking, you will have to use some code, to validate the file availability. I'm not sure what you mean by navigating to the file? In your app or by using windows explorer, or what?

For example, to validate the file availability, you can use something like this:

Code: Select all

		public static void TestFileExists(string FilePath)
		{
			if (!System.IO.File.Exists(@FilePath))
			{
				// skip the iteration in case of missing file
				throw new RanorexException("File Does not exist! File: " + @FilePath); 
			}
			else
				Report.Log(ReportLevel.Success, "Validation", "File " + FilePath + " exists.");
		}

Re: How to perform file based operation in Ranorex

Posted: Fri Nov 30, 2018 7:14 am
by mohan.pentyala
Hi ,

Thank you for some inputs.

yes, I need to navigate to windows explorer path and select a file. When I click on import from my application windows explorer will open in a different path, So I need to navigate to where my file is saved and select that file.

Re: How to perform file based operation in Ranorex

Posted: Fri Nov 30, 2018 8:58 am
by odklizec
Hi,

What's the point of just selecting the file in explorer? I mean, I'm sure that windows explorer is well tested by MS folks, so why to automate it or actions related to windows explorer? I'm obviously missing a crucial point you want to achieve by navigating to the explorer and selecting the file :)

My point is, that if you, for example, just want to start the file from its location, there is no need to use explorer at all. You can do it by Run action. So please elaborate, what exactly you want to achieve after validating if the file exists? If you insists on using explorer, then simply record the actions you would normally do manually. And instead of clicking through the dir structure in explorer (to find the file), type the path to file in explorer's navigation bar.

Re: How to perform file based operation in Ranorex

Posted: Fri Nov 30, 2018 12:32 pm
by mohan.pentyala
Hi ,

As attached in below screenshot, when I click on import from my application windows explorer will open. From there I need to navigate to where my files were saved and then validate that file is available. If yes select that.
Hope it gives to some picture

Re: How to perform file based operation in Ranorex

Posted: Fri Nov 30, 2018 12:55 pm
by odklizec
So, the validation of file existence, can be done with the code I showed you above. Then you should paste/type the path to the file name input element. And finally, if you click Open button, it should open the file as expected.

Re: How to perform file based operation in Ranorex

Posted: Tue Dec 04, 2018 9:39 am
by Stub
What Pavel said. That's exactly what I do in our AUT with File/Open and SaveAs dialogs.