Passing variables into code modules to be used as repository paths

Ask general questions here.
andy.simpson
Posts: 6
Joined: Fri Jun 22, 2018 8:59 am

Passing variables into code modules to be used as repository paths

Post by andy.simpson » Mon Feb 25, 2019 2:18 pm

Hi,

I have an issue where I have created a code module to extract a class from a web text, Ideally I want to be able to specify this as a variable so it can be reused throughout the suite. It runs fine using the standard repo.workflow..etc address but when I attempt to substitute that for a local variable (in my example FieldToBeValidated then it throws the error
'string' does not contain a definition for 'GetAttributeValueText' and no extension method 'GetAttributeValueText' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) (CS1061) - C:\AS3\ColartTrainingExample\IMS recording modules\AdditionalDocuments\ValidateAdditionalDocumentMandatoryStatus.UserCode.cs:42,44
Not sure if this is within Ranorex's capabilities or I'm getting the wrong end of the stick, I've attached a photo the examples of what I have and what I want to achieve are boxed any help would be appreciated
Attachments
code example.png
code example.png (26.73 KiB) Viewed 44 times

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

Re: Passing variables into code modules to be used as repository paths

Post by odklizec » Mon Feb 25, 2019 3:30 pm

Hi,

From your description, I understood that you created a code module variable FieldToBeValidated. But because the module variables are strings, this will not work for repo elements! What you can do is to pass the repo element directly to method via parameter, as you are already doing for tdTagInfo element. Simply add new parameter to your method, either RepoItemInfo or Adapter and use this parameter as a starting point for GetAttributeValueText. Of course, in case of RepoItemInfo, you must first create an adapter from RepoItemInfo parameter. Hope this helps?
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

andy.simpson
Posts: 6
Joined: Fri Jun 22, 2018 8:59 am

Re: Passing variables into code modules to be used as repository paths

Post by andy.simpson » Tue Feb 26, 2019 12:22 pm

Great help thanks :D