Forum Discussion

mfoster711's avatar
mfoster711
Regular Contributor
3 years ago
Solved

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.

  • Lee_M's avatar
    Lee_M
    3 years ago

    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

7 Replies

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    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's avatar
      Lee_M
      Community Hero

      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

  • mfoster711's avatar
    mfoster711
    Regular Contributor
     
     
    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's avatar
      Lee_M
      Community Hero

      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

      • mfoster711's avatar
        mfoster711
        Regular Contributor

        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.