Page 1 of 1

Using a Variable as value to pass into "Delay"

Posted: Thu Dec 20, 2018 4:07 pm
by ancleg
So it seems that the "Delay" function takes in a value-checked String, but passing a similarly formatted String causes it to fail to compile.

Could workaround this by writing my own Delay function that would parse the string itself, but would obviously like to avoid that.

The goal with parameterizing the Delay value is to test if we are getting all of our HTTP responses back before the time at which we are marking the Module as "Completed." Not a huge deal to not be able to do it, but it would simplify our testing process.

Any thoughts?

Thanks.

Re: Using a Variable as value to pass into "Delay"

Posted: Fri Dec 21, 2018 9:47 am
by RobinHood42
Hi,

The Ranorex Delay() accepts an int value for it's duration. So, you would need to ensure that your value get's casted properly:
string duration = "3000";
Delay.Duration(int.Parse(duration));
Cheers,
Robin

Re: Using a Variable as value to pass into "Delay"

Posted: Wed Jan 02, 2019 4:44 pm
by ancleg
So I actually did solve that one, and realized what caused my initial problem in the first place.

I used a Variable named "Delay"

This created the variable in the local .cs file, which overwrote the Ranorex.Delay (or Ranorex.Core.Delay, whatever it is) as being the correct "Delay" that it should have been pointed at.

This fully broke that rxrec module, and I had to delete it and recreate it, which was a minor inconvenience due to it being a simple thing, but for anyone with a complicated module could be problematic.

Not sure how to file a bug report on this but seems like it would be worth taking a look at.

Re: Using a Variable as value to pass into "Delay"

Posted: Fri Jan 04, 2019 2:15 pm
by Support Team
Hello ancleg,

Thank you for letting us know. I am glad that you found the issue.
May I ask what do you mean by "This fully broke that rxrec module"? When using "Delay" as a variable name you should only get an error when building the solution.

When adding the code in Ranorex Studio, I get the message below.
string Delay = "1234";
Delay.Duration(Int32.Parse(Delay), false);

'string' does not contain a definition for 'Duration' and no extension method 'Duration' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) (CS1061) ...

After fixing the code the error disappears.

Sincerely,
Bernhard