Variable types in UserCodeMethods

Class library usage, coding and language questions.
seurrep
Posts: 36
Joined: Tue Aug 07, 2018 10:19 am

Variable types in UserCodeMethods

Post by seurrep » Thu Feb 14, 2019 12:04 pm

I'm trying to add a function that tests an API end point that would normally expect a number as part of the input. Obviously one of the tests I would like to do is check what happens when other things (blank string or 'A' for example) are passed instead.

I had initially added a UserCodeMethod to actually call the API with a parameter of type object used to pass this value in. The intention being that the type of the parameter would be tested within the code and the JSON suitably generated within it before that JSON is then passed to the API.

The problem seems to be though that Ranorex doesn't seem to show this method in the list when I try and select it from the library to use in a recording. If I change the datatype of the object parameter to something like int then it appears.

Why are object parameters not recognised in functions that I've added to the project? Is it possible to have a function of some sort that can be agnostic in terms of the input and only tests the type of input internally? What would be the best way of going about this?

My colleague has also mentioned another potential issue: if he runs a recording by only running that recording rather than a wider test plan then Ranorex complains about the DPI (after having failed to find elements and subsequently fail the test). If the recording is run as a part of a wider test plan then it appears to work. Is there any reason why this might be the case? I've also just been told he has already looked at your documentation and followed your suggestions but none of these helped solve the issue.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5155
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Variable types in UserCodeMethods

Post by odklizec » Thu Feb 14, 2019 12:36 pm

Hi,

I'm afraid Ranorex user code methods currently supports only these types:
Argument_types.png
Argument_types.png (11.49 KiB) Viewed 259 times
Feel free to post a feature request for more datatypes here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex

As for DPI, you should always make sure the test machine uses the same DPI scaling across all displays and ideally 100% zoom:
https://www.ranorex.com/#DifferentDispl ... lingValues
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration