Jump to content
CharlesStamp

Trouble selecting correct object

Recommended Posts

CharlesStamp

Based on the documentation and tutorials I've read, I expected the following script to go to the page and enter "anything" into the second text box from the top ("Nachname", where the first is "Vorname"). But it doesn't and I'm not sure why.

#Include <FF.au3>

        If _FFStart("http://ff-au3-example.thorsten-willert.de/", "default", 0) Then
    ; Enter keywords into search bar
    
        $sInput = _FFObjGet("text", "type", 1) 
        Sleep (3)
        _FFObj($sInput, "value", "anything")

EndIf

I realize that in this example I could use _FFObject("lname", "name") but I've had problems before getting the correct element using _FFClick as well, where there are several on the page with the same tag. I guess I'm making a really basic error, but I'd appreciate some advice on where I'm going wrong.

Share this post


Link to post
Share on other sites
water

I would add some error checking to your script.
Check @error after each function call to see what goes wrong.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

BTW: "type" isn't a valid mode for _FFObjGet according to the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
CharlesStamp

Thanks. I thought that might've been an issue so I've modified the example to use a different site. The last one couldn't properly replicate the problem I've been facing as all the text box elements had unique names (hence using "type" as they're all distinct), but on this one they don't. Note I'm now using "id" instead of "type". I've added the error checking, but get no errors

#Include <FF.au3>
#include <MsgBoxConstants.au3>

        If _FFStart("http://www.gamefaqs.com/search/index.html?platform=120&game=&contrib=0&rating=0&genre=0&region=0&date=0&developer=&publisher=&dist=0&sort=0&link=0&res=0&title=0", "default", 0) Then
            ; Enter keywords into search bar
    
        $sInput = _FFObjGet("searchtextbox", "id", 1) ; returns a string - no object!
                If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "ObjGet Error")
        Sleep (3)
     _FFObj($sInput, "value", "anything")
                If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "Input Error")
                
EndIf

There are two search boxes with id "searchtextbox" and regardless of which position I specify (in this case, 1, but I've also tried 0, 2 and 5) it always fills in the same box at the top. And I haven't modified FF.au3 at all, so I'm stumped.

Share this post


Link to post
Share on other sites
water

Which version of FF.au3 do you run?
Search the source of the UDF for

Global Const $_FF_AU3VERSION
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
CharlesStamp

$_FF_AU3VERSION = "0.6.0.1b-15"

Share this post


Link to post
Share on other sites
Danp2

Your script appears to work fine for me. There are actually two forms on the page, and both contain an input field with that id. The index parameter doesn't apply when retrieving by id, so the first instance is always retrieved.

I would suggest using _FFXPath for greater flexibility. Here's an example:

#Include <FF.au3>

If _FFStart("http://www.gamefaqs.com/search/index.html?platform=120&game=&contrib=0&rating=0&genre=0&region=0&date=0&developer=&publisher=&dist=0&sort=0&link=0&res=0&title=0", "default", 0) Then
    Local $cForm  = "search"
    Local $cField = "searchtextbox"
    Local $cValue = "anything"

    _FFXPath("//form[@id='" & $cForm & "']//input[@id='" & $cField & "']")
    _FFCmd("FFau3.xpath.value='" & $cValue & "'")
EndIf

 

Edited by Danp2

Share this post


Link to post
Share on other sites
CharlesStamp

The index parameter doesn't apply when retrieving by id, so the first instance is always retrieved.

Oh I see. That'll be where I was going wrong then. Thanks a lot for the example. It should come in handy in helping me make sense of that function.

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

×