How to perform file based operation in Ranorex

Ask general questions here.
mohan.pentyala
Posts: 20
Joined: Thu Sep 20, 2018 7:43 am

How to perform file based operation in Ranorex

Post by mohan.pentyala » Thu Nov 29, 2018 8:32 am

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4047
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to perform file based operation in Ranorex

Post by odklizec » Thu Nov 29, 2018 2:38 pm

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.");
		}
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mohan.pentyala
Posts: 20
Joined: Thu Sep 20, 2018 7:43 am

Re: How to perform file based operation in Ranorex

Post by mohan.pentyala » Fri Nov 30, 2018 7:14 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4047
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to perform file based operation in Ranorex

Post by odklizec » Fri Nov 30, 2018 8:58 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mohan.pentyala
Posts: 20
Joined: Thu Sep 20, 2018 7:43 am

Re: How to perform file based operation in Ranorex

Post by mohan.pentyala » Fri Nov 30, 2018 12:32 pm

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
Attachments
Import.png
Import.png (28.69 KiB) Viewed 61 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4047
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to perform file based operation in Ranorex

Post by odklizec » Fri Nov 30, 2018 12:55 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Stub
Posts: 175
Joined: Fri Jul 15, 2016 1:35 pm

Re: How to perform file based operation in Ranorex

Post by Stub » Tue Dec 04, 2018 9:39 am

What Pavel said. That's exactly what I do in our AUT with File/Open and SaveAs dialogs.