Jump to content

IE Automation


Dizzy
 Share

Recommended Posts

Hi all,

i want to automate my login at "mail.hansenet.de" but i cant get the fields.

I search for forms with:

#include <IE.au3>
$oIE = _IECreate ("http://mail.hansenet.de")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.name)
Next

but i get no forms ...

so i try to get frames ...

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "http://mail.hansenet.de")
$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oIE, $i)
    MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl"))
Next

That gives me 2 "Frame Infos".

1.) http://mail.hansenet.de/supp/blank.htm

2.) http://mail.hansenet.de/mail/Login?domain=...ult&plain=0

How can i work with this info?

How do i get the right fields to insert my credentials?

Thanks

Link to comment
Share on other sites

Looking at the source of the page you'll see:

<FRAMESET ROWS="1,1000" BORDER="0" FRAMEBORDER="0">
<FRAME SRC="/supp/blank.htm" SCROLLING="NO" NAME="SessionFrame">
<FRAME SRC="/mail/Login?domain=hansenet.de&style=default&plain=0" SCROLLING="no" NAME="SContentFrame">
</FRAMESET>

I'm guessing you'll want the second frame... it can be accessed with either

$oFrame = _IEFrameGetObjByName($oIE, "SContentFrame") 
or 
$oFrame = _IEFrameGetObjByIndex($oIE, 1)

Then use $oFrame where you would have used $oIE in the form examples...

Dale

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

  • Moderators

I've gotten it this far, but I'm not sure how to call the OnPhoenixLogin() function. Maybe Dale can help with that.

#include <IE.au3>

$sUsername = "Your Username"
$sPassword = "Your Password"

$sURL = "http://mail.hansenet.de"
$oIE = _IECreate($sURL)

$oFrame = _IEFrameGetObjByName ($oIE, "SContentFrame")

$oForm = _IEFormGetObjByName($oFrame, "dataentry")
$oUsername = _IEFormElementGetObjByName($oForm, "username")
$oPassword = _IEFormElementGetObjByName($oForm, "password")

_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
Link to comment
Share on other sites

There are several ways to finish this... one is to click the button image (it is inside a link with an action that executes the Javascript function):

#include <IE.au3>

$sUsername = "Your Username"
$sPassword = "Your Password"

$sURL = "http://mail.hansenet.de"
$oIE = _IECreate($sURL)

$oFrame = _IEFrameGetObjByName ($oIE, "SContentFrame")

$oForm = _IEFormGetObjByName($oFrame, "dataentry")
$oUsername = _IEFormElementGetObjByName($oForm, "username")
$oPassword = _IEFormElementGetObjByName($oForm, "password")

_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEImgClick($oFrame, "/graphics/button_anmelden.gif")

Dale

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

I read the help file on this but not sure of "$s_name" in regards to numeric values.

Does it start with "0"? Would $oFrame = _IEFrameGetObjByIndex($oIE, 0)

get frame NAME=SessionFrame instead?

These replays from both Dale & Big_Daddy have been a big help for me on another 'frame' site.

vim

Looking at the source of the page you'll see:

<FRAMESET ROWS="1,1000" BORDER="0" FRAMEBORDER="0">
<FRAME SRC="/supp/blank.htm" SCROLLING="NO" NAME="SessionFrame">
<FRAME SRC="/mail/Login?domain=hansenet.de&style=default&plain=0" SCROLLING="no" NAME="SContentFrame">
</FRAMESET>

I'm guessing you'll want the second frame... it can be accessed with either

$oFrame = _IEFrameGetObjByName($oIE, "SContentFrame") 
or 
$oFrame = _IEFrameGetObjByIndex($oIE, 1)

Then use $oFrame where you would have used $oIE in the form examples...

Dale

Link to comment
Share on other sites

I read the help file on this but not sure of "$s_name" in regards to numeric values.

Does it start with "0"? Would $oFrame = _IEFrameGetObjByIndex($oIE, 0)

get frame: NAME="SessionFrame" instead?

These replays from both Dale & Big_Daddy have been a big help for me on another 'frame' site.

vim

Edited by vim
Link to comment
Share on other sites

Ooops... I just can't get used to the fact that I replaced most of the *ByIndex functions with *GetCollection...

I'm pretty certain that EVERY index reference in IE.au3 os zero-based, so the first is 0, the second is 1.

The call for getting an indexed frame is $oFrame = _IEFrameGetCollection($oIE, 0-based-index)

Dale

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

Okay ... it isn't soooo easy :whistle:

I try to make a login at this site : https://www.dresdner-privat.de/

On the left site you can see "Finanzstatus".

I've had a look at the source - and i think it should be the frame "nav" or the page "/fb/setzkasten/entryAnonym0.html".

#include <IE.au3>

$sURL = "https://www.dresdner-privat.de/"
$oIE = _IECreate($sURL)

$oFrame = _IEFrameGetObjByName ($oIE, "nav")
_IELinkClickByText ($oIE, "Finanzstatus")

No function :) Whats wrong?

Thanks for help!

Edited by Dizzy
Link to comment
Share on other sites

@Dizzy

There are actually several problems here.

First, you used _IEFrameGetObjByName to get the frame reference, but then you used $oIE in the _IELinkClickByText call.

Second, "nav" is not the name of the frame you want. If you are using SciTe you should see a warning at the console telling you there was noMatch for that name. It is tricky because the page is actually being generated on the fly by the Javascript at the top of the page. Using the browser's View Source, you see the Javascript code, but not the generated HTML. You can see it using IE.au3 with the following (when using SciTe):

#include <IE.au3>
$oIE = _IECreate("https://www.dresdner-privat.de/", 1)
ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)oÝ÷ ØZèØb³*.ßÙe±ç­ëp T@0Kyø§yÚ'¶©jÛazÞÊ°j{b²«¨µºÊ«¨´Ú0Êj{¬xy'$$ÞÆÖî¶Ø^)äµìmʬ¥ç"~'Á«'ßÛjº+^®(!´b±§-¹©eÊ«¨¶Ev§ÎËZ¶ë*ºX¢çǶ¬{azÊ.­Ç®±ârEæ3Ó~¨¶¦zíçèZ0xºÚ"µÍÚ[ÛYH ÒQK]LÉÝÂÌÍÛÒQHHÒQPÜX]J    ][ÝÚÎËÝÝÝËÙ]]][ÝËJBÌÍÛÑ[YHHÒQQ[YQÙ]ØS[YJ   ÌÍÛÒQK  ][ÝØÙI][ÝÊBÌÍÛÓ[ÜÈHÒQS[ÑÙ]ÛÛXÝ[Û  ÌÍÛÑ[YJBÌÍÚHHÜ  ÌÍÛÓ[È[    ÌÍÛÓ[ÜÂPÛÛÛÛUÜ]J ][ÝÒ[^    ][ÝÈ  [È ÌÍÚH [È ][ÝÈ[È^  ][ÝÈ  [È ÌÍÛÓ[Ë[^   [ÈÔBIÌÍÚH
ÏHB^

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

@Dale

:lmao: Everthing looks so easy - but i have to learn and try a little bit more.

Thanks Dale - this is a great explanation for my faults.

OK - the first error (_IEFrameGetObjByName ) is clear.

That came by different tests and was not thought to the end.

I see the Javascript and i know that this would be a problem too. :)

But in your examples i can see as you merge scite for analysis.

For $oLink in $oLinks
    ConsoleWrite("Index: " & $i & " Link Text: " & $oLink.innerText & @CR)
    $i += 1
Next

I haven't known the ".innerText" function. Now i have found it in the IE.au3 - but

is there a little explanation everywhere? :whistle:

And last - i thought that a piece of the link "Finanzstatus" should be enough? It seems

i have to take the hole word including spaces and signs.

Thanks again!!

:)

Link to comment
Share on other sites

You're welcome.

You can find information about .innerText and all other related properties etc. at MSDN. _IE_Introduction() will give you some starting points.

Dale

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

Another one (question) ...

When i use the pretty code from Dale i am on the same page as bevor - just with an different body.

If i use :

#include <IE.au3>
$oIE = _IECreate("https://www.dresdner-privat.de/", 1)
$oFrame = _IEFrameGetObjByName($oIE, "body")
_IELinkClickByText ($oFrame, "> Finanzstatus")

I will get the right body with the same url (https://www.dresdner-privat.de/).

Now i want to list all links (like Dales example) but nothing was given out on the console .. :)

Is the reference false?

OK - next step i look for frames ...

#include <IE.au3>
$oIE = _IECreate("https://www.dresdner-privat.de/", 1)
$oFrame = _IEFrameGetObjByName($oIE, "body")
_IELinkClickByText ($oFrame, "> Finanzstatus")

Sleep (2000)

ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)

$oFrame = _IEFrameGetObjByName($oIE, "body")
$oLinks = _IELinkGetCollection($oFrame)
$i = 0

For $oLink in $oLinks
    ConsoleWrite("Index: " & $i & " Link Text: " & $oLink.innerText & @CR)
    $i += 1
Next

$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oIE, $i)
    ConsoleWrite(_IEPropertyGet ($oFrame, "locationurl") & @CR)
Next

I get following in the console :

<FRAME id=header name=header marginWidth=0 marginHeight=0 src="/servlet/P/getHeader.do" frameBorder=0 noResize scrolling=no><FRAME id=body name=body marginWidth=0 marginHeight=0 src="/fb/setzkasten/entryAnonym0.html" frameBorder=0 noResize>

https://www.dresdner-privat.de/servlet/P/getHeader.do

https://www.dresdner-privat.de/servlet/P/fo...tus_anzeigen.do

I just want to get the fields or names to logon ...

Sure - i can direct jump to the site using the second url and skip with a "tab" from field to field - but i want

to understand the other way. :">

Grummmel ... shit ... hmmm ???? :)

Dale?? :whistle:

Edited by Dizzy
Link to comment
Share on other sites

You need to dig down yet again. The body frame gets rewritten such that it now contans frames... you need to open the frame named "content" in the frame named "body" and your form and form fields live in there...

Dale

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

@Dale

Ok - it's going on :)

With your hints i'm able to use this code:

#include <IE.au3>

$sUsername = "MyName"
$sPassword = "Pass"

$oIE = _IECreate("https://www.dresdner-privat.de/", 1)
$oFrame = _IEFrameGetObjByName($oIE, "body")
_IELinkClickByText ($oFrame, "> Finanzstatus")

;*** START : only for analysis ***
;ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)
;*** END : only for analysis ***

$oFrame1 = _IEFrameGetObjByName ($oIE, "body")
$oFrame2 = _IEFrameGetObjByName ($oFrame1, "content")

;*** START : only for analysis ***
;$oForms = _IEFormGetCollection ($oFrame2)
;For $oForm In $oForms
;   ConsoleWrite("This Form is living in my box =" & $oForm.name & @CR)
;Next
;*** END : only for analysis ***

$oForm = _IEFormGetObjByName($oFrame2, "loginForm")

;*** START : only for analysis ***
;$oQuery = _IEFormElementGetCollection ($oForm, -1)
;For $oQuery1 In $oQuery
;   ConsoleWrite("This are my fields =" & $oQuery1.name & @CR)
;Next
;*** END : only for analysis ***

$oUsername = _IEFormElementGetObjByName($oForm, "identifier")
$oPassword = _IEFormElementGetObjByName($oForm, "RQRVYT2TWXPW2XTaedWTVYWVPT00VRNW")

_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)

_IEFormImageClick ($oForm, "anmelden", "alt")

Ooops :nuke: they are changing the passwords elementsname ...

; *** Get name of index 2 (password)
$oQuery = _IEFormElementGetCollection ($oForm, 1)
;ConsoleWrite("This are my fields =" & $oQuery.name & @CR)

$oUsername = _IEFormElementGetObjByName($oForm, "identifier")
$oPassword = _IEFormElementGetObjByName($oForm, $oQuery.name)

_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)

_IEFormImageClick ($oForm, "anmelden", "alt")

It does what i need! (Yes .. :D )

Is there something (without the analysis stuff) i can make easier? :P

Perhaps the pointing of the 2 frames (body/content)?

And i get one warning from scite "--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch"

starting with the site "$oIE = _IECreate("https://www.dresdner-privat.de/", 1)"

Why?

Is it the https?

Thanks

Edited by Dizzy
Link to comment
Share on other sites

@Dale

Ok - it's going on :P

Good job

Is there something (without the analysis stuff) i can make easier?

$oFrame and $oFrame1 are identical - you don't need both

$oQuery and $oPassword are identical, no need to do the second one and go to that extra work.

And i get one warning from scite "--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch"

starting with the site "$oIE = _IECreate("https://www.dresdner-privat.de/", 1)"

Why?

Notice it is a warning not an error. If you remove the " ,1" that says "try attach" it will disappear.

Otherwise it looks good.

Dale

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

Good job

$oFrame and $oFrame1 are identical - you don't need both

$oQuery and $oPassword are identical, no need to do the second one and go to that extra work.

Notice it is a warning not an error. If you remove the " ,1" that says "try attach" it will disappear.

Otherwise it looks good.

Dale

Hmm - you're right with $oFrame and $oFrame1 - i've not seen the double.

But the second one??

This one is ok :

$oPassword = _IEFormElementGetCollection ($oForm, 1)

But how to change the second one

$oPassword = _IEFormElementGetObjByName($oForm, $oQuery.name)
to use it 'cause the name is changing? :P

Greets Dizzy

Link to comment
Share on other sites

This one is ok :

$oPassword = _IEFormElementGetCollection ($oForm, 1)

But how to change the second one

$oPassword = _IEFormElementGetObjByName($oForm, $oQuery.name)
to use it 'cause the name is changing? :P
_IEFormElementGetCollection ($oForm, 1) will give you a reference to the second form element regardless of what its name is...

Dale

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

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...