Hi,
I have an issue I need to find a solution to: I need to click on a random directory :
and afterwards click on a random file:
How can I choose a random object with ranorex?
Thx!
Random object choosing
Random object choosing
You do not have the required permissions to view the files attached to this post.
Re: Random object choosing
Ranorex is built on .NET. You can use the .NET Random class to choose a number between 0 and 1 and then multiply by the number of items in the list. This will give you the zero-based index of the folder to pick. Then add 1 (XPath uses 1 based indexing) and store the result in a module variable. You can use that variable in your item's path like ".//element[$FolderIndex]".
Shortcuts usually aren't...
Re: Random object choosing
I would like to add some hint on directories:
First make sure, that the proper dll-s are used:
First make sure, that the proper dll-s are used:
using System; using System.IO;To count the numbers of directories in C:\ directory
int countDir = System.IO.Directory.GetDirectories.("C:\").Length;To count the files in a directory:
string targetDirectory = "C:\"; string [] fileEntries = Directory.GetFiles(targetDirectory ); int countFiles = filEntries.Length;