Sign in to follow this  
Followers 0
IanN1990

_XPath() need exact match only.

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I would suggest changing the xpath to "//span['@id=loading-indicator']". Once you have successfully called _FFXPath, you should be able to retrieve the class for further comparison using

$class = _FFCmd("FFau3.xpath.className")

 

1 person likes this

Share this post


Link to post
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.

Share this post


Link to post
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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0