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?
Repo Object - Update RegEx Path in Code
- Support Team
- 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
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:
Markus
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
Re: Repo Object - Update RegEx Path in Code
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:
$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.
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]
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...
-
- Posts: 2
- Joined: Fri Nov 07, 2014 4:11 pm
Re: Repo Object - Update RegEx Path in Code
Thanks for your help guys!