XPath slow
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
XPath slow
I am using the following code in one of my projects and I am testing two different releases of our software (let's call them alpha and beta release). On the beta release this line of code executes in less than a second. On the alpha release, this line of code takes 10 seconds.
Set objField = PageObj.FindChildByXPath("//*[contains(@aria-labelledby, '" & AriaLabelValue & "')]", true)
What could be causing this line of code to take 10 seconds on the alpha release? This line of code is how we identify every field in our web application so I can't have it taking 10 seconds to find a field.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set objRoot = PageObj.FindChildByXPath("//*[@id='root']", true)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried changing to FindChildByXPath to FindElement, maybe this helps ?
Set objRoot = PageObj.FindElement("//*[@id='root']", true)
sometimes the code will take time to search when the search is too generic
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Does this problem occur for the same test project with the same settings?
I am not sure, but you may check the value of the Playback | Object Search Strategy option (https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/properties/playback.h...).
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Lee_M wrote:
Set objRoot = PageObj.FindElement("//*[@id='root']", true)
sometimes the code will take time to search when the search is too generic
I understand that but in this example the @id=root object is the immediate child object of the page. This should be the first object searched so it should be quick to find. Also, I am searching by ID.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@AlexKaras wrote:Hi,
Does this problem occur for the same test project with the same settings?
I am not sure, but you may check the value of the Playback | Object Search Strategy option (https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/properties/playback.h...).
I was using the same project on the same PC to test both releases of our software so this isn't an issue with a difference in settings.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strangely, this issue stopped occurring. The XPath search is responding properly on both versions of our software and I have not changed anything in my code or project. The only thing that changed is a new daily update to our software applications that we are testing.
I have no idea what was causing this issue or what suddenly made it go away.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@mfoster711 Thanks for the update, I'm glad your issue seems to have 'disappeard'
There are so many factors that could have caused this
- internet speed
- conflict
- wrong code
- multiple browsers
- system load
I suggest if you notice this again you open dev tools and check the network tab to check if the page and dom are loading correctly
feel free to reach out with more debug information should you encounter this issue again
