Sign in to follow this  
Followers 0
Lman

Form Created Using Javascript

9 posts in this topic

Hello,

I am attempting to use AutoIt to interface with the GUI on a website, but the html on the website is generated using a lot of Javascript. Because of this, I do not know what the form objects are called to make use of the IE library in AutoIt.

Is there a way to use the AutoIt functions with dynamically generated HTML like that found at this website? http://blackboard.unl.edu/webapps/portal/frameset.jsp

I could just use keystrokes, but I'd rather use more advanced functionality of the IE library. An example that fills in the two text boxes and presses return would be perfect.

Thanks!!

Share this post


Link to post
Share on other sites



Suggest you try DebugBar (see my sig) as it makes it very easy to see the dynamically generated HTML and its structure. The _IE* functions all work with the dynamically generated page.

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

Share this post


Link to post
Share on other sites

Thanks Dale,

The DebugBar worked really well and I was able to identify the actual form and element names. Unfortunately, the following code modified from the examples does not seem to work:

#include <IE.au3>

; open Internet Explorer to the Blackboard website

$oIE = _IECreate ("http://my.unl.edu/webapps/portal/frameset.jsp")

$oForm = _IEFormGetObjByName ($oIE, "login")

$oQuery = _IEFormElementGetObjByName ($oForm, "user_id")

_IEFormElementSetValue ($oQuery, "some guy")

Here is the original example code which functions normally on my system:

#include <IE.au3>

; open Internet Explorer to the Google website

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

$oForm = _IEFormGetObjByName ($oIE, "f")

$oQuery = _IEFormElementGetObjByName ($oForm, "q")

_IEFormElementSetValue ($oQuery, "some site")

Any idea what could be causing AutoIt to not work with the Blackboard website in particular?

Thanks!!

Share this post


Link to post
Share on other sites

Make sure you run your code in SciTe to get helpful console messages to help you debug. You should see a bunch of NOMATCH and INVALID DATA TYPE messages.

I will make a tiny leap of faith here and assume that since the name of the page you are connect to is frameset.jsp, that the content you want is actually enbedded in a frameset. Please see the _IEFrame* functions and their examples. There is a dropdown on the DebugBar Toolbar to the left of the "eye" icon that will help you find the frames and show your their source.

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

Share this post


Link to post
Share on other sites

Thanks Again Dale,

You were correct, all I had to do was access the Form through the Frame. My script can now successfully log on to Blackboard :P

Unfortunately, I seem to be losing the page when it loads as a result of the IEFormImageClick. I am unable to run any of the IE* methods to click links or images on the new page. Do I have to specifically reconnect my variables to the page, frames, etc. in some fashion?

; *********************************************************

; open Internet Explorer to the Blackboard website

$oIE = _IECreate ($url)

; get the frame

$oFrame = _IEFrameGetObjByName ($oIE, $frameTag)

; get the form inside the frame

$oForm = _IEFormGetObjByName ($oFrame, $formTag)

; get the user and password inputs from frame

$userInput = _IEFormElementGetObjByName ($oForm, $userTag)

$passwordInput = _IEFormElementGetObjByName($oForm, $passTag)

; fill in the user and password fields

_IEFormElementSetValue ($userInput, $user)

_IEFormElementSetValue ($passwordInput, $password)

; click on the Login button

_IEFormImageClick ($oForm, $loginTag, "name")

; *********************************************************

Thanks again!!

Share this post


Link to post
Share on other sites

After a page reload $oIE will still be valid, but all of the other objects were destroyed so you need to connect to them again.

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

Share this post


Link to post
Share on other sites

Hello Dale,

After the page loads, I have tried hooking the new frame objects as you suggested. I appended the following code to the source given in my last post:

; ************************************************************

$nav = _IEFrameGetObjByName ($oIE, "nav")

MsgBox(0, "Frame Info", _IEPropertyGet ($nav , "locationurl"))

; ************************************************************

When I run the script through SciTE (which works great btw) it loads a new IE window, enters the new info and logs in as expected. However, the above code fails to execute. If I close the script, but leave IE window open and run the script again the above code works. The 2nd iteration opens a new IE window, logs in and then pops up the frame info after loading the new page. Clearly I am still missing something...any thoughts?

I'm running WinXP with SP2 and IE6.

Thanks!!

Share this post


Link to post
Share on other sites

Suggest you try SciTe debug mode (see my sig) to get a better understanding of what your script is doing and if it is stalling, where.

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

Share this post


Link to post
Share on other sites

Thanks Dale,

Thank you for your patience in this matter. I did as you suggested and enabled the debugger. First of all, found that adding that AutoIt no code is run beyond (I verified with MsgBox) the IELinkClickByText unless the third and fourth parameters are set e.g.:

_IELinkClickByText($oFrame, "Community", 0, 0)

Secondly, I am still having trouble getting AutoIt to click the links I want. These links are buried in frames and tables, but DebugBar seems to have no trouble extracting them. I've included the results of the debug mode below...

Once again, if I load the script again without closing the IE window, the AutoIt runs as intended in the second IE window. Maybe a problem with loading the DOM? I dug around and found your previous post on true reloads, but Blackboard does not allow (gives an Access Denied message).

$oIE.document.location.reload(true); True reloads from server

0039: 0-0: $oIE = _IECreate ($url)
0042: 0-0: $oFrame = _IEFrameGetObjByName ($oIE, $frameTag)
0045: 0-0: $oForm = _IEFormGetObjByName ($oFrame, $formTag)
0048: 0-1: $userInput = _IEFormElementGetObjByName ($oForm, $userTag)
0049: 0-1: $passwordInput = _IEFormElementGetObjByName($oForm, $passTag)
0052: 0-1: _IEFormElementSetValue ($userInput, $user)
0053: 0-0: _IEFormElementSetValue ($passwordInput, $password)
0057: 0-0: _IEFormImageClick ($oForm, $loginTag, "name", 0, 0)
0064: 0-0: $oFrame = _IEFrameGetObjByName ($oIE, "nav")
0065: 0-0: _IELinkClickByText($oFrame, "Community", 0, 0)
0067: 0-0: $oFrame = _IEFrameGetObjByName ($oIE, "content")
0068: 0-0: _IELinkClickByText($oFrame, "iLOG Testing", 0, 0);
C:\Program Files\AutoIt3\Include\IE.au3 (924) : ==> The requested action with this object has failed.:
$linktext = $link.outerText & ""
$linktext = $link.outerText ^ ERROR
->15:41:57 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 6.105

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  
Followers 0