Reading files on the fly

Class library usage, coding and language questions.
Mozzytm
Posts: 36
Joined: Fri Feb 08, 2013 11:18 am

Reading files on the fly

Post by Mozzytm » Fri Jul 26, 2013 10:51 am

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

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Reading files on the fly

Post by krstcs » Fri Jul 26, 2013 1:24 pm

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();
  }
}

Shortcuts usually aren't...