Jump to content
Sign in to follow this  
bhodi78

I don't understand what I wrong.

Recommended Posts

bhodi78

Hello everyone,

I whant take all contents of the form's field "departing from" of the site www.ryanair.com.

The next code don't work, I don't understand that I wronging.

#include <IE.au3>
#include <String.au3>

$oIE = _IECreate ("http://www.ryanair.com/")
_IELoadWait ($oIE)

;Returns a collection object variable representing the Forms in the document or a single form by index.
$SBform = _IEFormGetCollection ($oIE,0)

;Returns an object reference to a Form by name.
$o= _IEFormElementGetObjByName ($SBform,"sector1_o")

;check if "_IEFormElementGetObjByName" generated an error
Switch @error
    case 0 
        MsgBox(0,"","No error [0]") 
    case 3
        MsgBox(0,"","Invalid Data Type [3]")
    Case 4
        MsgBox(0,"","Invalid Object Type [4]")
    Case 5 
        MsgBox(0,"","Invalid Value [5]")
    Case 7
        MsgBox(0,"","No Match [7]")  ;<-------- This is the error, what I wrong?
EndSwitch

;append all content of $o.text in a string
$tmp=""
For $tmp in $o
    $tmp&=$tmp.text&"|"
Next

;print all departures separated from the character "|"
MsgBox(0,"Finish!!",$tmp) 
_IEQuit ($oIE)
Exit

I thank all in advance.

bye

Share this post


Link to post
Share on other sites
PsaltyDS

Are you sure it's in the first form (you specified index = 0), and the name is correct? Did you check with a DOM inspector, like DebugBar, to see if the form is inside a Frame, or some other issue?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
bhodi78

Are you sure it's in the first form (you specified index = 0), and the name is correct? Did you check with a DOM inspector, like DebugBar, to see if the form is inside a Frame, or some other issue?

:)

You are right, is not the first form, and the form is inside a Frame in fact I used DebugBar and I have find this tree:

Document

|

|---Body

|---|

|---|---DIV id="colB"

|---|---|

|---|---|---IFRAME

|---|---|---|

|---|---|---|---Body

|---|---|---|---|

|---|---|---|---|---DIV class="tab"

|---|---|---|---|---|

|---|---|---|---|---|---FORM name="SBform"

|---|---|---|---|---|---|

|---|---|---|---|---|---|---SELECT name="sector1_o"

How can I take all option of SELECT name="sector1_o"?

How can I surf in the dom?

Thank you very much.

bye

Share this post


Link to post
Share on other sites
PsaltyDS

Use _IEFrameGetCollection($oIE, 0) to get a reference to the Frame, then you can do _IEFormGetObjByName($oFrame, "SBForm") for the form, and then _IEFormElementGetObjByName ($SBform,"sector1_o") should work.

Also, if you had tested this by running from SciTE with _IEErrorHandlerRegister() first, you would have seen the warnings in the console that _IEFormGetCollection() was what failed in the original. Would have saved you some steps.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×