Issue with object recognition when using variable XPath

Ask general questions here.
romil
Posts: 2
Joined: Tue Jul 02, 2013 11:46 am

Issue with object recognition when using variable XPath

Post by romil » Thu Dec 05, 2013 3:47 pm

Hi Everyone,

I am trying to test a sample scenario involving use of variables in XPath.

There is a test suite library and a test solution. The library contains Login and Logout modules whereas the test solution contains Search module

I used a variable in the Base Xpath as the domain attribute pointed to my application and the requirement was to be able to run the tests on different URLs running the same application.

The Base XPath looks like this

Code: Select all

/dom[@domain=$domain]
When i try to run Login and Logout modules independently, they work just fine.

In the Test solution, I again use a variable in the Xpath for the Domain attribute for the same reason as mentioned above. I use the same variable name so the base path again looks like this

Code: Select all

/dom[@domain=$domain]
The reason for using the same domain name is because I plan to use an excel sheet to provide values for the variables and as logically both variables point to the same domain, the same cell in the excel sheet can be used.

Now I add this test library into the test solution as a reference. The test case I create has the following steps
  • Login (from the test library)
    Search (from the test solution)
    Logout (from the test library)
The problem is that when I try to run this test case, the login action fails with the following error message

Code: Select all

Failed to find item 'SharedRepoRepository.Login.JUsername'.
No element found for path '/dom[@domain='http://<mydomain>']//input[#'j_username']' within 1m
Am I missing something? I have been looking for a solution for this for a couple of days but could not find it. Appreciate any help in solving this issue.
Last edited by romil on Fri Dec 06, 2013 6:13 am, edited 1 time in total.

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

Re: Issue with object recognition when using variable XPath

Post by krstcs » Thu Dec 05, 2013 6:00 pm

Domain is technically not the whole URL.

For the URL "http://www.ranorex.com/forum", the domain is "www.ranorex.com".

For you situation, the domain is actually "purdws1fe221.es.ad.adp.com:8080" so it will not match the XPath you have given.

Just remember that the domain and URL are not the same thing and that should help a bunch.
Shortcuts usually aren't...

romil
Posts: 2
Joined: Tue Jul 02, 2013 11:46 am

Re: Issue with object recognition when using variable XPath

Post by romil » Fri Dec 06, 2013 6:56 am

krstcs wrote:
Just remember that the domain and URL are not the same thing and that should help a bunch.
Thanks for pointing it out. There were multiple instances where the same variable was being used and there were many different values stored there. Fixing the values at all the places did the trick. Thanks a lot !!!

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

Re: Issue with object recognition when using variable XPath

Post by krstcs » Fri Dec 06, 2013 3:39 pm

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