Page 1 of 1

Can I update an XPath address dynamically in code?

Posted: Tue Jun 07, 2016 2:50 pm
by stapes
I have a variable in my Repository defined as:
/mobileapp[@title='com.365agile.enterprise.365Agile-TEST']/form/container[@caption='' and @containertype='LayoutContainer']/container/container/container/container/container/container/table/
container[1]/container/cell/text[@accessibilitylabel=$currentFormName]
Rather than us $currentFormName here, which is described as an Unbound Variable, I would rather use a C# Global Variable, like this:

Code: Select all

public static string GlobalCurrentForm
	    {
	    	get{return _globalCurrentForm ;}
	    	set{_globalCurrentForm =value ;}
	    }
Can I set this 'path' dynamically in my code, so it does not keep showing up on my reports as an Unbound Variable?

I need to use this path to access the control described.

Re: Can I update an XPath address dynamically in code?

Posted: Tue Jun 07, 2016 3:00 pm
by odklizec
Sadly, unless you bind the variable to a data source, it will always show as "unbinded". However, there is already a feature request to disable/hide "unbound variable warning" per variable (in variable editor) in Ranorex feature requests. And the good news is that it's already in planning stage (according to Ranorex support)! So I would recommend to send an email to [email protected] and they will add your voice to the already existing feature request, which may improve request priority ;)

Re: Can I update an XPath address dynamically in code?

Posted: Sat Aug 20, 2016 7:01 am
by rahulkasana
You can dynamically update your variable in user code modules without needing to bind them to data source.

/mobileapp[@title='com.365agile.enterprise.365Agile-TEST']/form/container[@caption='' and @containertype='LayoutContainer']/container/container/container/container/container/container/table/
container[1]/container/cell/text[@accessibilitylabel=$currentFormName]

if you have your repository instance named as repo, then you can access this variable as below

repo.currentFormName, now you can assign a value you desire for example,

repo.currentFormName="xyz";

once you have assigned the variable your desired value you can now use your element.