Page 1 of 1

Reading files on the fly

Posted: Fri Jul 26, 2013 10:51 am
by Mozzytm
is there any way to do this in ranorex. put simply what i want to do is:
(windows/web)

kick off the automation
the automation runs a sahi web script which creates a random username and drops this into a text file
ranorex to read this text file and assign the content to a variable
ranorex kicks off desktop app and logs in with the newly created username

Re: Reading files on the fly

Posted: Fri Jul 26, 2013 1:24 pm
by krstcs
Why don't you just create the random name in Ranorex? It is .NET based, so anything you can do with .NET you can do with Ranorex.

Code: Select all

class NameGenerator {

  string lowerChars = "abcdefghijklmnopqrstuvwxyz";
  string upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  Random r = new Random();

  public string GetNewRandomName(int length, bool initialCap) {
    StringBuilder name = new StringBuilder();

    if (initialCap) {
      name.Append(upperChars.ToCharArray()[r.Next(0, upperChars.Length)]);
    } else {
      name.Append(lowerChars.ToCharArray()[r.Next(0, lowerChars.Length)]);
    }

    for (int i = 0; i < length -1; i++) {
      name.Append(lowerChars.ToCharArray()[r.Next(0, lowerChars .Length)]);
    }

    return name.ToString();
  }
}