Automaton Posted February 25, 2008 Share Posted February 25, 2008 Hi guys, If you are presented with a web pages login screen, what approach do you take to filling in the username and password? Do you count the number of tabs to move from the part of the page that has focus to the username entry box? Or do you do something else, like click on a named field? Link to comment Share on other sites More sharing options...
walle Posted February 25, 2008 Share Posted February 25, 2008 Short example, gets a reference to a specific form element and set its value What site are we talking about? #include <IE.au3> $oIE = _IECreate ("http://www.google.com") $oForm = _IEFormGetObjByName ($oIE, "f") $oQuery = _IEFormElementGetObjByName ($oForm, "q") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3") _IEFormSubmit ($oForm, 0) _IELoadWait($oIE) Link to comment Share on other sites More sharing options...
Automaton Posted February 25, 2008 Author Share Posted February 25, 2008 Short example, gets a reference to a specific form element and set its value What site are we talking about? #include <IE.au3> $oIE = _IECreate ("http://www.google.com") $oForm = _IEFormGetObjByName ($oIE, "f") $oQuery = _IEFormElementGetObjByName ($oForm, "q") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3") _IEFormSubmit ($oForm, 0) _IELoadWait($oIE) Interesting script. When run, it opens IE, then spaws a new tab in Firefox, and hangs. Off topic, but I assume Autoit3 is browser agnostic? Link to comment Share on other sites More sharing options...
Automaton Posted February 26, 2008 Author Share Posted February 26, 2008 (edited) Short example, gets a reference to a specific form element and set its value What site are we talking about? #include <IE.au3> $oIE = _IECreate ("http://www.google.com") $oForm = _IEFormGetObjByName ($oIE, "f") $oQuery = _IEFormElementGetObjByName ($oForm, "q") _IEFormElementSetValue ($oQuery, "AutoIt IE.au3") _IEFormSubmit ($oForm, 0) _IELoadWait($oIE) That's not the only interesting thing about this code. When I used the Window Information Tool, I couldn't find any reference to "q" or "f". How did you know they were available for use? Don't mind me! I just looked at the help page for IEFormGetObjByName, and it says the following... Note that the names of the form and form elements can be found by viewing the page HTML source So I viewed the source for the web page with the username and password and got the following. It makes no mention of a form I could grab hold of <HTML> <HEAD> <style type="text/css"> body { overflow: auto; } </style> <script language=javascript> function geturl() { var mm = location.href; var nn = mm.lastIndexOf("/"); var bb = mm.substring(0,nn+1); return(bb); } function getTdRootURL() { var bb = location.protocol +"//"+location.host+"/sabin"; return(bb); } document.writeln('<HEAD>'); document.writeln('<TITLE>HP Quality Center 9.2 Site Administration</TITLE>'); document.writeln('</HEAD>'); <!---------------------------------------------> <!-- *** Declare here you download files *** --> <!---------------------------------------------> function write_ie_object() { document.writeln(' <OBJECT ID="MQC" '); document.writeln(' CLASSID="CLSID:b2fc031d-8c74-46ae-8042-bcf4fc03c1ef" '); document.writeln(' CODEBASE="Spider91.cab#Version=9,2,0,4862"'); document.writeln(' WIDTH=100% '); document.writeln(' HEIGHT=100%> '); document.writeln(' <PARAM NAME="SetupFile" value="' + geturl() +'SiteAdmin_setup.cab"> '); document.writeln(' <PARAM NAME="SetupExtFile" value="' + geturl() +'custom_modules.cab"> '); document.writeln(' <PARAM NAME="BrowserUI" value="0"> '); document.writeln(' <PARAM NAME="ProgColor" value="#663300"> '); document.writeln(' <PARAM NAME="ProgBkColor" value="#FFFFFF"> '); document.writeln(' <PARAM NAME="DomainName" value="Default"> '); document.writeln(' <PARAM NAME="DomainPassword" value=""> '); document.writeln(' <PARAM NAME="TdRootURL" value="' + getTdRootURL() +'"> '); document.writeln(' </OBJECT>'); } // Sniff Browser var ua = navigator.userAgent; var fWin32 = (ua.lastIndexOf('Win') != -1) && (ua.lastIndexOf('Windows 3.1') == -1) && (ua.lastIndexOf('Win16') == -1); var fMSIE67 = (ua.lastIndexOf('MSIE 6.0') != -1)|| (ua.lastIndexOf('MSIE 7.0') != -1); var fActiveX = fWin32 && fMSIE67; var fDownlevel = !fActiveX; // Handle IE if (fActiveX) { document.writeln('<BODY bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" topmargin="0" leftmargin="0">'); write_ie_object(); } // Error for other browser or OS if (fDownlevel) { document.write(navigator.appName + ' : ' + navigator.appVersion + ' is not supported!'); document.write('<br>'); document.write('Only Internet Explore 6 and 7 are supported.'); } </script> <noscript> You need Javascript to see this page correctly. Please install it from CD redist folder. </noscript> </BODY> </HTML> Edited February 26, 2008 by Automaton Link to comment Share on other sites More sharing options...
Automaton Posted February 26, 2008 Author Share Posted February 26, 2008 Would a screen shot help? Link to comment Share on other sites More sharing options...
Automaton Posted March 6, 2008 Author Share Posted March 6, 2008 Would a screen shot help?bump Link to comment Share on other sites More sharing options...
DaleHohm Posted March 6, 2008 Share Posted March 6, 2008 AutoIt has no browser affinity. The IE Management UDF however does only work with IE - this is because IE exposes a programming COM API that is not available in any other browser to date and it opens many possibilities. Using the code in the example posted above, you should not get anything happening in Firefox. If something is happening in Firefox as a result of that script, then you have something exotic in your configuration - perhaps some IE plugins or something else unique. Browsers do not use standard windows controls, so the AutoIt window info tool does little for you. Suggest you use DebugBar (see my sig) to get what you are looking for. 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now