Jump to content

Trivago with _ff.au3


Recommended Posts

Hey guys,
 
I'm trying to do a search with Firefox / _ff.au3 at trivago.de (.com)
The click on the Search-Button works fine, but the search string is not recognized. Do you have any idea?
If I send the Hotelname "Adlon Berlin" with ControlSend to the Window-handle ($h1) it works, but sometimes the search string is in the adressbar or somewhere else...
 

#include <FF.au3>

Local $url=""

_FFStart("http://www.trivago.de","default", 2)
$h1 = _FFWindowGetHandle()
WinActivate($h1)
WinSetState($h1,"",@SW_MAXIMIZE)
_FFSetValue("Adlon Berlin", "df_query_input", "class")
_FFCmd("window.content.document.getElementsByClassName('df_btn_search')[0].click()")
Sleep(3000)
_FFSetValue("Adlon Berlin", "df_query_input", "class")
_FFCmd("window.content.document.getElementsByClassName('df_btn_search')[0].click()")
$url = _FFCmd(".location.href")
MsgBox(0,"URL",$url)

 
Best regards,
Hank

Edited by HankMoody
Link to comment
Share on other sites

Hello and welcome to the AutoIt forums!

Please next time post your code like >this .

I have only worked with InternetExplorer browser with autoit, so I wouldn't say I'm really qualified to give you pointers :) . I think that you should use _IELoadWait (something equivalent with it) after/before you maximize the browser window. Maybe the problem occures because the browser hasn't fully loaded yet.

I don't know what you wanna use the script or where, but If you are okey with some "lower" lvl solutions, you can try to MouseClick in to the search field, to make sure the search string goes where you wanted it to go (I only advise this if you only plan to use it on your computer) How do you get the browserFormElement? Did you manually searched it from the source code? (just guessing here)

Enjoy the forums :)

Link to comment
Share on other sites

What you need to do is some kind of error checking. Every function sets a return value and/or @error and/or @extended.

Only execute a function when the previous returned without an error.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What you need to do is some kind of error checking. Every function sets a return value and/or @error and/or @extended.

Only execute a function when the previous returned without an error.

 

Hello and welcome to the AutoIt forums!

Please next time post your code like >this .

I have only worked with InternetExplorer browser with autoit, so I wouldn't say I'm really qualified to give you pointers :) . I think that you should use _IELoadWait (something equivalent with it) after/before you maximize the browser window. Maybe the problem occures because the browser hasn't fully loaded yet.

I don't know what you wanna use the script or where, but If you are okey with some "lower" lvl solutions, you can try to MouseClick in to the search field, to make sure the search string goes where you wanted it to go (I only advise this if you only plan to use it on your computer) How do you get the browserFormElement? Did you manually searched it from the source code? (just guessing here)

Enjoy the forums :)

 

Hello everybody,

thank you for your answers and your welcome :)

Yes the Element I got from the source code of the Website.

Maybe I didn't explain my problem good enough. The functions itself work fine without any error but the result, means the behavior the website, isn't what I expected. I just wrote this short code without error checking to show a short runnable program to you.

Now I rewrote it with some error checking. No errors occure on runtime but it doesn't work this way. I have some workarounds in my actual program version with some clicking in the input and checking if I get the what I want but I'm still searching for a "clean solution" without clicking in a box and sending the text via controlsend().

I add the new code with the error checking. Maybe you can try it and see what I mean. The input box gets the hotelname but doesn't use it, when the search button is pressed.

#include <FF.au3>

Local $url="", $h1

SetError(0)
If _FFStart("http://www.trivago.de", "default", 2) Then
   $h1 = _FFWindowGetHandle()
   If $h1 Then
      If WinActivate($h1) <> 0 Then
         If WinSetState($h1,"",@SW_MAXIMIZE) Then
            If _FFSetValue("Adlon Berlin", "df_query_input", "class") Then
               _FFCmd("window.content.document.getElementsByClassName('df_btn_search')[0].click()")
               Sleep(3000)
               If @Error = 0 Then
                  If _FFSetValue("Adlon Berlin", "df_query_input", "class") Then
                     _FFCmd("window.content.document.getElementsByClassName('df_btn_search')[0].click()")
                     If @Error = 0 Then
                        $url = _FFCmd(".location.href")
                        MsgBox(0,"URL",$url)
                     EndIf
                  Else
                     MsgBox(0,"Error",@Error)
                  EndIf
               Else
                  MsgBox(0,"Error",@Error)
               EndIf
            Else
               MsgBox(0,"Error",@Error)
            EndIf
         Else
            MsgBox(0,"Error",@Error)
         EndIf
      Else
         MsgBox(0,"Error",@Error)
      EndIf
   Else
      MsgBox(0,"Error",@Error)
   EndIf
Else
   MsgBox(0,"Error",@Error)
EndIf

Thanks in advance.

Best regards, Hank

Edited by HankMoody
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...