Repo Object - Update RegEx Path in Code

Ask general questions here.
travis.jones
Posts: 2
Joined: Fri Nov 07, 2014 4:11 pm

Repo Object - Update RegEx Path in Code

Post by travis.jones » Fri Nov 07, 2014 4:23 pm

I'm working with a client that has a web app that includes multiple pages. The client has multiple test environments and they way they direct to each is via a different URL. So, since the pages have the same content across all of these environments, I'm about to just update those URL's in a few places in the spy view and it allows one repository to support all of the environments.

All of that being said, I want to be able to change those URL's at a coding level rather than have to change them all in the spy view. I know the framework creates a repo object that allows me to access all of the items but it's read-only. Is there any way for me to change the ranorexpath of an existing repo object? It's key that I'm able to change the existing object and not create a new one since the existing object is already referenced in the test scripts everywhere. I just need to be able to change the ranorexpath on 3 webdoc items in the repository at a coding level so I don't have to do it manually every time. Is there a way I can do that?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Repo Object - Update RegEx Path in Code

Post by Support Team » Tue Nov 11, 2014 1:55 pm

Hi Travis,

When you want to use one repo item which should reference different URLs I would recommend to use a repository variable to change the value of the used PageUrl attribute.
This repository variable can then be also accessed via UserCode as shown below:
NameOfYourRepo repo = NameOfYourRepo.Instance;
repo.NewRepoVariable = "New Value";
Regards,
Markus

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

Re: Repo Object - Update RegEx Path in Code

Post by krstcs » Tue Nov 11, 2014 2:33 pm

In addition to what Markus said, you can also "variable-ize" your XPath.

For example, my test domain has 6 different test domains, so I set my base repo object (the web document) to use the @domain attribute like this:

Code: Select all

MyWebSite ==> /dom[@domain=$domain]
$Domain is defined as a global parameter in each test and is bound to every module that uses MyWebSite. That may seem like a lot of work, but it really isn't.

The Global Parameter allows me to pass in the desired domain at the command-line when I run the tests (I use Jenkins for test execution, so it does this for me). My tests are bit more complex than this example, but you get the picture.
Shortcuts usually aren't...

travis.jones
Posts: 2
Joined: Fri Nov 07, 2014 4:11 pm

Re: Repo Object - Update RegEx Path in Code

Post by travis.jones » Tue Nov 11, 2014 2:45 pm

Thanks for your help guys!