bengalih Posted June 14, 2016 Share Posted June 14, 2016 I've been grunging around the forums trying to find a solution, and I'm to understand I'll be somewhat limited here, but I'm hoping I can automate this somewhat. This is the web client login for vSphere (5.5). The URL is internal, so I can't provide but I will show all the data The code page is relatively simple, so I will post in its entirety: expandcollapse popup<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- saved from url=(0014)about:internet --> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>vSphere Web Client</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css" media="screen"> body { display: none; } html, body { height: 100%; overflow: auto; margin: 0; padding: 0; font: 13px Arial, 'Helvetica Neue', sans-serif; } p { margin: 20px; padding: 0; } img { border: 0; } #flashContent { display: none; } #container_app { position: absolute; top: 0; left: 0; width: 100%; height: 100%; outline: none; } </style> <link type="text/css" href="history/history.css" rel="stylesheet" /> <link type="image/x-icon" href="assets/application.ico" rel="shortcut icon" /> <script type="text/javascript" src="history/history.js"></script> <script type="text/javascript" src="assets/swfobject.js"></script> <script type="text/javascript" src="assets/jquery.min.js"></script> <script type="text/javascript" src="assets/jquery.scrollbars.js"></script> <script type="text/javascript"> $(window).load(function() { if(self == top) { document.getElementsByTagName("body")[0].style.display='block'; } else { top.location = self.location; } }); //<![CDATA[ swfobject.embedSWF( 'UI.swf', 'flashContent', '100%', '100%', '11.5.0', 'playerProductInstall.swf', false, { quality: 'high', bgcolor: '#ffffff', allowscriptaccess: 'sameDomain', allowfullscreen: 'true', menu: false, flashvars: 'locale=en_US&localeChain=en_US&resourceModuleURLs=locales/UI-en_US.swf', scale: 'noscale', wmode: 'opaque' }, { id: 'container_app', name: 'container_app', align: 'middle' }); swfobject.createCSS('#flashContent', 'display: block; text-align: left;'); $.scrollbars({ swfId: '#container_app' }); //]]> </script> </head> <body> <div id="container"></div> <div id="flashContent"> <p> To view this page ensure that Adobe Flash Player version 11.5.0 or greater is installed. </p> <p> <a href="http://www.adobe.com/go/getflashplayer"> <img src="assets/getFlashPlayer.gif" alt="Get Adobe Flash Player" /> </a> </p> </div> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="container_app"> <param name="movie" value="UI.swf" /> <param name="flashvars" value="locale=en_US&localeChain=en_US&resourceModuleURLs=locales/UI-en_US.swf"/> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="true" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="UI.swf" width="100%" height="100%"> <param name="flashvars" value="locale=en_US&localeChain=en_US&resourceModuleURLs=locales/UI-en_US.swf"/> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="true" /> <!--<![endif]--> <!--[if gte IE 6]>--> <p> Either scripts and active content are not permitted to run or Adobe Flash Player version 11.5.0 or greater is not installed. </p> <!--<![endif]--> <p> <a href="http://www.adobe.com/go/getflashplayer"> <img src="assets/getFlashPlayer.gif" alt="Get Adobe Flash Player" /> </a> </p> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </noscript> </body> </html> When the page starts loading, the swf has a loading bar in the form of "vmware" text filling in: When complete the form shows: As we can see from the code, this is the first object with an id "container_app" The best I have been able to accomplish so far is the following: #include <ie.au3> #include <constants.au3> $oIE = _IECreate("https://xxx.xxx.xxx:9443/vsphere-client") $hwnd = _IEPropertyGet($oIE, "hwnd") WinActivate($hwnd) $oInput = _IETagNameGetCollection($oIE, "object",1) While VarGetType($oInput) <> "object" $oInput = _IETagNameGetCollection($oIE, "object",1) WEnd Sleep(3000) Send("username{tab}password{tab}{tab}{enter}") # more info $strScreenX = _IEPropertyGet($oInput,"screenx") $strScreenY = _IEPropertyGet($oInput,"screeny") MouseMove($strScreenX,$strScreenY) MsgBox($MB_OK,"title",_IEPropertyGet($oInput,"outerhtml")) Now this works, but it isn't very reliable/stable. It seems that the _IETagNAmeGetCollection doesn't return as an Object until the .swf has done loading. Then there is another small delay before the form appears (Sleep). So - I am using this method to wait for the loading bar, but I don't think this should be the best way. Luckily - when the page is loading it seems to have focus on the form in the username field, so most of the time this works. I know I likely can't ControlSend directly to these swf fields, but I'm hoping there is a better way to detect that the form is available and to be able to focus on it better. I've included the "# more info" section to show that I am able to retrieve a property of this object, so I definitely appear to be connecting to it with the $oInput object. The values shown are really the only properties that I can return though (screenx,screeny,outerhtml,innerhtml). Everything else returns a 0. I would like to be able to focus/click so I can at least ensure I am always on the username field for start. I prefer not to revert to pixel recognition, is there any better way? Link to comment Share on other sites More sharing options...
orbs Posted June 15, 2016 Share Posted June 15, 2016 @bengalih, vSphere client and web client allow (some sort of) automatic login. check these articles: http://www.virten.net/2015/02/vsphere-client-parameters-autologin-and-change-language/ http://www.virtuallyghetto.com/2015/08/quick-tip-pre-filled-credentials-in-the-vsphere-6-0-web-client.html if you still want to do it with AutoIt, then the better way would be to open the window in a prefixed position (and size, if applicable), so you know the absolute coordinates of each field, then MouseClick() with the known coordinates and Send() the text. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
bengalih Posted June 15, 2016 Author Share Posted June 15, 2016 11 hours ago, orbs said: @bengalih, vSphere client and web client allow (some sort of) automatic login. check these articles: http://www.virten.net/2015/02/vsphere-client-parameters-autologin-and-change-language/ http://www.virtuallyghetto.com/2015/08/quick-tip-pre-filled-credentials-in-the-vsphere-6-0-web-client.html if you still want to do it with AutoIt, then the better way would be to open the window in a prefixed position (and size, if applicable), so you know the absolute coordinates of each field, then MouseClick() with the known coordinates and Send() the text. The first link deals with the non web client. The second link would be useful if you wanted to enter the same credentials in each time, and would also expose the password in clear text within the file. Clearly if I know the absolute position of every field I could automate mouse clicks, but that is even less reliable than the already demonstrated method. Link to comment Share on other sites More sharing options...
junkew Posted June 15, 2016 Share Posted June 15, 2016 you could try simplespy and iuiautomation https://www.autoitscript.com/wiki/FAQ question 31 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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