Ask a Question

XPath slow

SOLVED
mfoster711
Frequent Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Lee_M
Community Leader

Re: XPath slow

@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

View solution in original post

7 REPLIES 7
mfoster711
Frequent Contributor

Re: XPath slow

 
 
I did another testing using the following code. The root object is the child object immediately under the Page object.  This code also takes the same 10 seconds to complete.
 

 

 

Set objRoot = PageObj.FindChildByXPath("//*[@id='root']", true)

 

 

Lee_M
Community Leader

Re: XPath slow

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

AlexKaras
Community Hero

Re: XPath slow

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...).

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
mfoster711
Frequent Contributor

Re: XPath slow


@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. 

mfoster711
Frequent Contributor

Re: XPath slow


@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.

mfoster711
Frequent Contributor

Re: XPath slow

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.

Lee_M
Community Leader

Re: XPath slow

@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

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: