IanN1990 Posted January 17, 2017 Share Posted January 17, 2017 (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 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 January 17, 2017 by IanN1990 Link to comment Share on other sites More sharing options...
Danp2 Posted January 17, 2017 Share Posted January 17, 2017 It isn't clear what type of element you are trying to locate. Can you show us the HTML for this object? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
IanN1990 Posted January 23, 2017 Author Share Posted January 23, 2017 (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. The other idea i had was polling _FFReadHtml() and doing a string search? Edited January 23, 2017 by IanN1990 Link to comment Share on other sites More sharing options...
Danp2 Posted January 23, 2017 Share Posted January 23, 2017 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") IanN1990 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
IanN1990 Posted January 23, 2017 Author Share Posted January 23, 2017 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 More sharing options...
Danp2 Posted January 23, 2017 Share Posted January 23, 2017 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 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now