User code created Repository item

Class library usage, coding and language questions.
mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

User code created Repository item

Post by mghali » Thu Jun 25, 2015 2:40 pm

Hello Everyone,

I have a repository that has a dynamic value. I need to take the output from one of the steps that has the following code :

repo.ShellForm.Shell4.Code.PressKeys("Code"+System.DateTime.Now.ToString("MMddyyyy"));

O/P = CodeMMddyyyy,

This would create a new item in the list.

The next step I use should be selecting the repository item that would have a value "CodeMMddyyyy".

How can I code and create a repository Item that would be used for this step.

Thank you
Mona

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: User code created Repository item

Post by krstcs » Thu Jun 25, 2015 3:42 pm

I would suggest a repository variable that you set right before you use the repo item.

If you post your XPath from the repo item you are using we can probably show you exactly what to change.
Shortcuts usually aren't...

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: User code created Repository item

Post by mghali » Thu Jun 25, 2015 3:44 pm

Thank you for the reply.

The xpath that I use is:

/form[@controltypename='ShellForm']//tabpage[@title='Reporting Configuration' and @controltypename='TabPage']/?/?/container[@controltypename='SplitContainer']/container[2]/element/container[1]/tabpagelist/tabpage[1]/?/?/table[@controltypename='ReadOnlyDataGridView']/row[@accessiblename='Row 50']/cell[@text> 'Code']

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: User code created Repository item

Post by krstcs » Thu Jun 25, 2015 7:34 pm

I would add a variable like so, to the xpath in the repo:

Code: Select all

/form[@controltypename='ShellForm']//tabpage[@title='Reporting Configuration' and @controltypename='TabPage']/?/?/container[@controltypename='SplitContainer']/container[2]/element/container[1]/tabpagelist/tabpage[1]/?/?/table[@controltypename='ReadOnlyDataGridView']/row[@accessiblename='Row 50']/cell[@text=$codeValue]
This will add a repository variable that will automatically be added to any recording module that you use this repo object in. It will be called "codeValue" in the recording module. (Always preface variables with '$' in XPath.)

Then, in your usercode do this:

Code: Select all

codeValue = "Code"+System.DateTime.Now.ToString("MMddyyyy");

repo.ShellForm.Shell4.Code.PressKeys(codeValue);
Now you just need to add the mouse-click action to the repo element either in the usercode or in the action table after the call to this above code.
Shortcuts usually aren't...

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: User code created Repository item

Post by mghali » Thu Jun 25, 2015 10:58 pm

Thank you so much!!
That helped.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: User code created Repository item

Post by krstcs » Fri Jun 26, 2015 1:14 pm

You're quite welcome!
Shortcuts usually aren't...