Jump to content

IE : input a date in pop calendar


ionmang20
 Share

Recommended Posts

How can I input a date in the Departure date field at www.lot.com ?

Using the below method I succeeded with the other fields, but not with the Departure date.

I also tried _IEImgClick, but without success.

#include <IE.au3>

Func Click_Id($_IE, $_Id, $_Text = "")
    Local $_Obj = _IEGetObjById($_IE, $_Id)
    _IEAction($_Obj, "click")
    If $_Text = "" Then Return
    Sleep(1500)
    Send($_Text)
    Sleep(1000)
    Send("{ENTER}")
EndFunc   ;==>Click_Id

$IE = _IECreate("http://www.lot.com", 0, 1, 1, 1)

Click_Id($IE, "ext-gen7", "Budapest [BUD]")
Click_Id($IE, "ext-gen19", "Sofia [SOF]")
Click_Id($IE, "selectedStartDate", "30-09-2010")
Link to comment
Share on other sites

Suggest you use DebugBar to figure out how that calendar is structured... it is encapsulated in a DIV element with an ID of ui-datepicker-div, in turn there is a table with the days of the month... with TRs and TDs.

$oDiv = _IEGetObjById($oIE, "ui-datepicker-div")

$oTable = _IETagnameGetCollection($oDiv, "table", 0)

To click on the 5th row, 3rd cell you would

$oTR = _IETagnameGetCollection($oTable, "tr", 4)

$oTD = _IETagnameGetCollection($oTR, "td", 2)

_IEAction($oTD, "click")

Dale

Edit: fix typos

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Try this Posted Image

#include <IE.au3>

$oIE = _IECreate("http://www.lot.com", 0, 1, 1, 1)
$oForm = _IEFormGetObjByName ($oIE, "miniBookerForm")
$oText = _IEFormElementGetObjByName ($oForm, "selectedStartDate")
_IEFormElementSetValue ($oText, "30-09-2010")
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

@DaleHohm : Thanks, but your solution is a little bit complicated for me, and I can't make it work.

@wakillon : Thanks, your solution is simple and I understand it.

I have run into another problem, how can I click the Search button ?

It does't have a name or ID:

<A class=button-red onclick="bookFlightRequest(); return false;" href="javascript:void(0);">SEARCH</A>

I tried with _IEFormSubmit($Obj) and _IEImgClick($Obj, "SEARCH", "name"), but witout succes.

Can I run bookFlightRequest() java function ?

#include <IE.au3>

Flight()

Func SetObjValue($_Form, $_Id, $_Text)
    Local $_Obj = _IEGetObjById($_Form, $_Id)
    _IEFormElementSetValue($_Obj, $_Text)
EndFunc   ;==>SetObjValue

Func Flight()

    Local $IE = _IECreate("http://www.lot.com", 0, 1, 1, 1)
    Local $Obj = _IEFormGetObjByName($IE, "miniBookerForm")
    SetObjValue($Obj, "originId", "Budapest [BUD]")
    SetObjValue($Obj, "destinationId", "Sofia [SOF]")
    SetObjValue($Obj, "selectedStartDate", "02-10-2010")
    SetObjValue($Obj, "selectedAdultNumber", "2")
    SetObjValue($Obj, "selectedChildNumber", "2")
    
EndFunc   ;==>Flight
Edited by ionmang20
Link to comment
Share on other sites

@DaleHohm : Thanks, but your solution is a little bit complicated for me, and I can't make it work.

@wakillon : Thanks, your solution is simple and I understand it.

I have run into another problem, how can I click the Search button ?

It does't have a name or ID:

<A class=button-red onclick="bookFlightRequest(); return false;" href="javascript:void(0);">SEARCH</A>

I tried with _IEFormSubmit($Obj) and _IEImgClick($Obj, "SEARCH", "name"), but witout succes.

Can I run bookFlightRequest() java function ?

Thanks, I will see that....

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Thanks a lot, it works just fine.

#include <IE.au3>

Flight()

Func SetObjValue($_Form, $_Id, $_Text)
    Local $_Obj = _IEGetObjById($_Form, $_Id)
    _IEFormElementSetValue($_Obj, $_Text)
EndFunc   ;==>SetObjValue

Func Flight()

    Local $IE = _IECreate("http://www.lot.com", 0, 1, 1, 1)
    Local $Obj = _IEGetObjById($IE, "flightOnewayLabel")
    _IEAction($Obj, "click")
    Local $Obj = _IEFormGetObjByName($IE, "miniBookerForm")
    SetObjValue($Obj, "originId", "Budapest [BUD]")
    SetObjValue($Obj, "destinationId", "Sofia [SOF]")
    SetObjValue($Obj, "selectedStartDate", "02-10-2010")
    SetObjValue($Obj, "selectedAdultNumber", "2")
    SetObjValue($Obj, "selectedChildNumber", "2")
    _IELinkClickByText ( $IE, "SEARCH" )

EndFunc   ;==>Flight
Link to comment
Share on other sites

I'm struggling for a few hours to get the thicket price values form the following week table in the IE page:

post-56641-12858477200123_thumb.jpg

But I don’t seem to get it right.

Can you point me in the right direction or tell me where I made mistakes?

If an object, form or element has a name or ID, I think, I can manage it, but if not, it seems I’m not up to the challenge.

Also if you know of a better explained topic regarding IE functions, I’ll be glad if you’ll share it with me, because I don’t seem to understand the AutoIt help file.

#include <IE.au3>

Flight()

Func SetObjValue($_Form, $_Id, $_Text)
    Local $_Obj = _IEGetObjById($_Form, $_Id)
    _IEFormElementSetValue($_Obj, $_Text)
EndFunc   ;==>SetObjValue

Func Flight()

    Local $IE = _IECreate("http://www.lot.com", 0, 1, 1, 1)
    Local $Obj = _IEGetObjById($IE, "flightOnewayLabel")
    _IEAction($Obj, "click")
    Local $Obj = _IEFormGetObjByName($IE, "miniBookerForm")
    SetObjValue($Obj, "originId", "Budapest [BUD]")
    SetObjValue($Obj, "destinationId", "Sofia [SOF]")
    SetObjValue($Obj, "selectedStartDate", "06-10-2010")
    SetObjValue($Obj, "selectedAdultNumber", "2")
    SetObjValue($Obj, "selectedChildNumber", "2")
    _IELinkClickByText ( $IE, "SEARCH" )
    _IELoadWait($IE)

    $Form = _IEFormGetCollection($IE, 0)
    $Elem = _IEFormElementGetCollection($Form)
    $n = 0
    For $oElem In $Elem
        ConsoleWrite($n & " Name:" & $oElem.name& ":" & _IEFormElementGetValue($oElem) & @LF)
        $n += 1
    Next

EndFunc   ;==>Flight
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...