Using a Variable as value to pass into "Delay"

Best practices, code snippets for common functionality, examples, and guidelines.
ancleg
Posts: 7
Joined: Thu Dec 20, 2018 4:03 pm

Using a Variable as value to pass into "Delay"

Post by ancleg » Thu Dec 20, 2018 4:07 pm

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.

User avatar
RobinHood42
Posts: 265
Joined: Fri Jan 09, 2015 3:24 pm

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

Post by RobinHood42 » Fri Dec 21, 2018 9:47 am

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

ancleg
Posts: 7
Joined: Thu Dec 20, 2018 4:03 pm

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

Post by ancleg » Wed Jan 02, 2019 4:44 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11737
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Fri Jan 04, 2019 2:15 pm

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
.
Image