Page 1 of 1

Passing variables into code modules to be used as repository paths

Posted: Mon Feb 25, 2019 2:18 pm
by andy.simpson
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

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

Posted: Mon Feb 25, 2019 3:30 pm
by odklizec
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?

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

Posted: Tue Feb 26, 2019 12:22 pm
by andy.simpson
Great help thanks :D