Jump to content

_XPath() need exact match only.


 Share

Recommended Posts

Hi,

I have a script which assists in some admin work via automation.

There is a section where i need the script to wait (for search results) before carrying on.

 

When no Search is happening a ID (loading-indicator) has the class name "input-group-addon-clear ng-hide"

When it is searching this changes to "input-group-addon-clear" 

When it is finished it goes back to "input-group-addon-clear ng-hide."

So i thought easy enough :D This should do the trick 

#include "FF V0.6.0.1b-15.au3"

_FFConnect()
;Input information to trigger search

Do
Until sleep(10) and _FFXPath(".//*[@Class='input-group-addon-clear']", "", 10) 

Do
Until sleep(10) and _FFXPath(".//*[@Class='input-group-addon-clear ng-hide']", "", 10)

The problem it isn't waiting. The _FFXPath seems to be  doing a part search. Taking input-group-addon-clear as input-group-addon-clear ng-hide.

Then it checks for input-group-addon-clear ng-hide (and finds it as the search hasn't started yet)

How can i make _FFXPath only return if it is a full match?

 

 

Edited by IanN1990
Link to comment
Share on other sites

Here is a picture from the DOM inspector :) When you type into the search box it the ng-hide disappears until it has finished loading and it appears.

Capture.PNG

The other idea i had was polling _FFReadHtml() and doing a string search?

Edited by IanN1990
Link to comment
Share on other sites

Hi Danp2.

Didn't know you could get class names like that, i have made a note of this as i am sure it will help in the future!

I tired StringinString which worked, though slowly and not very reliably. Went back to _FFXPath and discovered something interesting.

Do
Until sleep(10) and  _FFXPath(".//*[@Class='input-group-addon-clear']", "", 10) 

Do
Until sleep(10) and _FFXPath(".//*[@Class='input-group-addon-clear ng-hide']", "", 10)

Fails, as it doesn't wait. I did ConsoleWrite on the _FFXPath and it was returning 0 until a match was found. The code above should be working. As the loop shouldn't end until True and True. 1 = true and 0 = false. sleep returns = 1 and _FFXpath returns 0 (no match)  and 1 (match).

Do
Until sleep(10) and  _FFXPath(".//*[@Class='input-group-addon-clear']", "", 10) = 1

Do
Until sleep(10) and _FFXPath(".//*[@Class='input-group-addon-clear ng-hide']", "", 10) = 1

The code above though works perfectly :) I guess the _XPath is returning something classed as positive despite being 0.

Link to comment
Share on other sites

Glad you found a solution. Here's another option, untested mind you ---

$iState = 0

_FFXPath("//span['@id=loading-indicator']")

If @error = $_FF_ERROR_Success Then
    While True
        Sleep(10)

        $class = _FFCmd("FFau3.xpath.className")
        
        $result = StringInStr($class, 'ng-hide')

        If $iState = 0 And $result = 0 Then
            $iState = 1
            ContinueLoop
        EndIf
        
        If $iState = 1 And $result <> 0 Then
            ExitLoop
        EndIf
    WEnd
EndIf

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...