I use the following code to create an instance of an Accessible Object where 'int' can change based upon other code. This works well for using some methods suck as .click, but I really want to use all the methods available. Is there a way to turn this accessible object into a repo item? Thanks
int AScount = 2;
Accessible pic1 = @"/form[@title~'^TacViewC2\ \ \ \(map:\ .*']/element/container/picture" + "[" + AScount + "]";
pic1.Click(MouseButtons.Right, "Center");
Create Repo Item in Code
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Create Repo Item in Code
Hi,
If you want to use the RxPath in your Repository for a new element and add a variable to your RxPath, this is not possible at the moment. With Ranorex 3.0 you will have the possibility to add variables to your RxPath. A possible solution at the moment would be to add the RxPath to your repository and modify the RxPath of the element in code. If you want to use an adapter instead of "Accessible", I would suggest you to use the Ranorex.Picture for this RxPath.
Regards,
Peter
Ranorex Team
If you want to use the RxPath in your Repository for a new element and add a variable to your RxPath, this is not possible at the moment. With Ranorex 3.0 you will have the possibility to add variables to your RxPath. A possible solution at the moment would be to add the RxPath to your repository and modify the RxPath of the element in code. If you want to use an adapter instead of "Accessible", I would suggest you to use the Ranorex.Picture for this RxPath.
Regards,
Peter
Ranorex Team
- Gunner1980
- Posts: 89
- Joined: Mon Apr 05, 2010 8:44 pm
- Location: Austin, Texas
Re: Create Repo Item in Code
Can we get an example of how to modify the RxPath of the element in code and tie it to the repo item like you suggested?Support Team wrote:Hi,
If you want to use the RxPath in your Repository for a new element and add a variable to your RxPath, this is not possible at the moment. With Ranorex 3.0 you will have the possibility to add variables to your RxPath. A possible solution at the moment would be to add the RxPath to your repository and modify the RxPath of the element in code. If you want to use an adapter instead of "Accessible", I would suggest you to use the Ranorex.Picture for this RxPath.
Regards,
Peter
Ranorex Team
We want to use the accessible name for this item as it is unique and changes every time we run the test. The number of pictures on the screen can change based on the circumstances you are running the test under.
-
- Posts: 94
- Joined: Tue Jun 16, 2009 10:27 pm
Re: Create Repo Item in Code
I have tried the following:
int AScount = 2;
Ranorex.Picture pic1 = @"/form[@title~'^TacViewC2\ \ \ \(map:\ .*']/element/container/picture" + "[" + AScount + "]";
pic1.click();
This works to click on an object, but I want to test its existence first. I would like to be able to do this:
if (pic1Info.exists())
{
// click it
}
But I am not able to compile the above code when I create the repo item within in my code. Thanks
int AScount = 2;
Ranorex.Picture pic1 = @"/form[@title~'^TacViewC2\ \ \ \(map:\ .*']/element/container/picture" + "[" + AScount + "]";
pic1.click();
This works to click on an object, but I want to test its existence first. I would like to be able to do this:
if (pic1Info.exists())
{
// click it
}
But I am not able to compile the above code when I create the repo item within in my code. Thanks
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Create Repo Item in Code
Hi,
http://www.ranorex.com/forum/repository ... html#p5820
Peter
Ranorex Team
To change the RxPath during runtime in code please take a look to following postSupport Team wrote: Can we get an example of how to modify the RxPath of the element in code and tie it to the repo item like you suggested?
http://www.ranorex.com/forum/repository ... html#p5820
Please use the Validation class of Ranorex. In this class you will find a method named Exists() with tons of overloads. For example I would write following code for your issuecostamesakid wrote:This works to click on an object, but I want to test its existence first. I would like to be able to do this:
Validate.Exists(yourRepoItem or RxPath); yourItem.Click();Regards,
Peter
Ranorex Team
- Gunner1980
- Posts: 89
- Joined: Mon Apr 05, 2010 8:44 pm
- Location: Austin, Texas
Re: Create Repo Item in Code
I need to be able put the item I am creating as a repo item in a while loop or if statement. I also need to be able to specify the search time out.
Here is an example of how I want to utilize the item I am creating dynamically. Where repo.FormTacViewC2.PictureTrackCreateDrop is the item I want to create dynamically using the accessible name of the picture.
I am trying to get away from using the picture because the pictures can only be identified by their index number. The accessible name is what is always unique and is how I want to identify the item I am clicking on. In my application I can have any number of pictures on the application when I start my test, I need to identify the specific picture I want to click on by the accessible name and this is not something that can be satisfied by a repo item with a regular expression. I really need to be able to create this item on the fly in the code and perform the following actions below with that item.
Here is an example of how I want to utilize the item I am creating dynamically. Where repo.FormTacViewC2.PictureTrackCreateDrop is the item I want to create dynamically using the accessible name of the picture.
Code: Select all
public static void DropTrackSequence()
{
Duration OrigDur1 = repo.FormTacViewC2.PictureTrackCreateDropInfo.SearchTimeout;
repo.FormTacViewC2.PictureTrackCreateDropInfo.SearchTimeout = 2000;
while (repo.FormTacViewC2.PictureTrackCreateDropInfo.Exists())
{
Report.Warn("Previous track did not drop delaying 5 seconds...");
Delay.Milliseconds(5000, false);
repo.FormTacViewC2.PictureTrackCreateDrop.Click(MouseButtons.Right);
}
repo.FormTacViewC2.PictureTrackCreateDropInfo.SearchTimeout = OrigDur1;
}
I am trying to get away from using the picture because the pictures can only be identified by their index number. The accessible name is what is always unique and is how I want to identify the item I am clicking on. In my application I can have any number of pictures on the application when I start my test, I need to identify the specific picture I want to click on by the accessible name and this is not something that can be satisfied by a repo item with a regular expression. I really need to be able to create this item on the fly in the code and perform the following actions below with that item.
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Create Repo Item in Code
Can you please explain how you would solve the problem presented using Ranorex 3.0? The example "Using variables within the repository" only explains how to set the text of a rxpath to a variable, not how to insert a variable into an rxpath as costamesakid described.With Ranorex 3.0 you will have the possibility to add variables to your RxPath.
it looks like the Ranorex 3.0 tool only allows you to do the following through the GUI:int AScount = 2;
Ranorex.Picture pic1 = @"/form[@title~'^TacViewC2\ \ \ \(map:\ .*']/element/container/picture" + "[" + AScount + "]";
Ranorex.Picture pic1 = @"/form[@title=AScount]"
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Create Repo Item in Code
Hello,
in 3.0 you can use variables in the GUI, i.e. in the rxrep file:
- open the path editor for a repository item in the path (magic wand)
- there you can add a variable in one of the attributes
For a path like
That corresponds to
Regards,
Roland
Ranorex Support Team
in 3.0 you can use variables in the GUI, i.e. in the rxrep file:
- open the path editor for a repository item in the path (magic wand)
- there you can add a variable in one of the attributes
For a path like
when code is generated for the repository file $variable is replaced by the value of the variable (a string property of the class) at the moment you access the adapter class property. At his point an adapter class is generated and the element is searched repeatedly until the specified timeout has elapsed."/form[@controlname='formVipApplication']/list/list/listitem[@accessiblename=$variable]"
That corresponds to
Code: Select all
Ranorex.ListItem li = "/form[@controlname='formVipApplication']/list/list/listitem[@accessiblename="+variable+"]";
Roland
Ranorex Support Team
-
- Posts: 169
- Joined: Thu Jan 13, 2011 2:06 pm
Re: Create Repo Item in Code
Thank you. This example worked for me, such a better implementation!