Page 1 of 1

Issue with object recognition when using variable XPath

Posted: Thu Dec 05, 2013 3:47 pm
by romil
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.

Re: Issue with object recognition when using variable XPath

Posted: Thu Dec 05, 2013 6:00 pm
by krstcs
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.

Re: Issue with object recognition when using variable XPath

Posted: Fri Dec 06, 2013 6:56 am
by romil
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 !!!

Re: Issue with object recognition when using variable XPath

Posted: Fri Dec 06, 2013 3:39 pm
by krstcs
You're welcome!