Hi,
I am fairly new still and I am coming back to use Ranorex after a few months break. My existing code was looking for a username entry box that had the xpath set to:
.//div[#'app']/div/div/div[2]//form[@action='http://SomeMachine/login']/div[1]/div[1]/div/div[1]/?/?/input[@name='username']
After I ran it, it could not find the username entry box anymore. I used the spy tool and noticed that the xpath is now:
.//div[#'app']/div/main/div/div/div/div[2]//form[@action='http://SomeMachine/login']/div[1]/div[1]/div/div[1]/?/?/input[@name='username']
Is there someway I can make this more robust so that it could still find it? Is there a way to reference by name instead of the xpath?
Thanks
R
Xpath change broke automation
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: Xpath change broke automation
Hi AviatorFly,
It appears there may be some dynamic elements in the AUT that change the structure of the application, and therefore break the RxPath to this element. The easiest solution to this is to remove all the differences between the two RxPaths. The below RxPath will work in both scenarios:
If we want to be extra robust, we can use the below, however this can cause a decrease in performance and may cause Ranorex to find the wrong element if there is more than one input with the name 'username'.
For more information on handling dynamic content, check out this user guide page and blog post.
Also, in the newest versions of Ranorex, you can edit the RanoreXPath settings to generate a more robust RxPaths by default when adding a new element so that you do not need to manually edit them to be robust. I hope this helps!
Regards,
Ned
It appears there may be some dynamic elements in the AUT that change the structure of the application, and therefore break the RxPath to this element. The easiest solution to this is to remove all the differences between the two RxPaths. The below RxPath will work in both scenarios:
Code: Select all
.//div[#'app']/div//form[@action='http://SomeMachine/login']/div[1]/div[1]/div/div[1]/?/?/input[@name='username']
Code: Select all
.//div[#'app']//form[@action='http://SomeMachine/login']//input[@name='username']
Also, in the newest versions of Ranorex, you can edit the RanoreXPath settings to generate a more robust RxPaths by default when adding a new element so that you do not need to manually edit them to be robust. I hope this helps!
Regards,
Ned