t1ck3ts Posted June 21, 2014 Share Posted June 21, 2014 The problem is almost that of this topic:'?do=embed' frameborder='0' data-embedContent>> I am trying to automate Juniper Network Connect, it runs a webpage within its software. I am having issues attaching to the IE page thats running inside the software. Im trying to wait for the page to fully load, once its loaded i want to put the username and password in and then click "Sign In" button. I've gotten to this point by using normal ControlCommand's and such with Sleep(xxx) to wait, but its no ideal as some sites will load the page faster and some slower, so its not going to work on all my client sites. Im hoping that Dale's IE functions could help me. Here is the webpage that runs in Juniper Network Connect software: expandcollapse popup<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="robots" content="none"> <title>SSL VPN</title> <script src="/dana-na/css/ds.js"></script> <script> WriteCSS(); </script> <noscript> <link rel="stylesheet" href="/dana-na/css/ds.css"> </noscript> <script> <!-- if (window.top != self) { top.location = location; } if(window.name == "newpincancel" || window.name == "nexttokencancel") { window.close(); } //--></script> <script src="/dana-na/auth/lastauthserverused.js"></script> </head> <body onload="FinishLoad(1)" bgcolor="#FFFFFF" color="#000000" link="#3366CC" vlink="#CC6699" alink="#3366CC" leftmargin="0" topmargin="0" rightmargin="0" marginwidth="0" marginheight="0"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr> <td src="welcome.cgi?p=signinId=url_default" </td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td bgcolor="#000000" colspan="2"><img border="0" src="/dana-na/imgs/space.gif" width="1" height="1"></td> </tr> </table> <blockquote><form name="frmLogin" action="login.cgi" method="POST" autocomplete="off" onsubmit="return Login(1)"> <input type="hidden" name="tz_offset"> <table border="0" cellpadding="2" cellspacing="0"> <tr> <td nowrap colspan="3"><b>Welcome to the</b></td> </tr> <tr> <td nowrap colspan="3"><span class="cssLarge"><b>SSL VPN</b></span></td></tr> <tr> <td colspan="3"> </td> </tr> <tr> <td valign="top"> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td>Username</td> <td> </td> <td><input id="username_3" type="text" name="username" size="20" style="border: 1px inset #CCC;"/></td> </tr> <tr> <td>Password</td> <td> </td> <td><input id="password_3" type="password" name="password" size="20" style="border: 1px inset #CCC;"/></td> </tr> <tr> <input type="hidden" name="realm" value="Users"> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" value="Sign In" name="btnSubmit"> </td> </tr> </table> </td> <td valign="top"> </td> <td valign="top"><table border="0" cellspacing="0" cellpadding="2"> <tr><td>Please sign in to begin your secure session.<br><br><noscript>Note: Javascript is disabled on your browser.</noscript></tr></td></table></td> </tr> </table> </form> </blockquote> </body> </html> I've tried $oPopup = _IEAttach ("SSL VPN", "embedded") $oInput = _IEGetObjByName($oPopup, "btnSubmit") _IEAction($oInput, "click") But it gives me the following error --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEAction(click), $_IESTATUS_InvalidDataType Any idea's how i could get this to work? Link to comment Share on other sites More sharing options...
Danp2 Posted June 21, 2014 Share Posted June 21, 2014 $oPopup = _IEAttach ("SSL VPN", "embedded") According the the help file, you need to use the title or HWND of the containing window, not the title of the web page. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted June 21, 2014 Author Share Posted June 21, 2014 (edited) According the the help file, you need to use the title or HWND of the containing window, not the title of the web page. I've tried using the containing window title (Network Connect - Sign In) This too does not work. Here is the main window of the software: expandcollapse popup>>>> Window <<<< Title: Network Connect - Sign In Class: #32770 Position: 842, 192 Size: 475, 492 Style: 0x14CE0044 ExStyle: 0x00010100 Handle: 0x00000000006504D0 >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 883, 209 Cursor ID: 0 Color: 0xFEFEFE >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< https://xxxx.xxxxxxx.xxx/ https://xxxx.xxxxxxx.xxx/ Go Sign-in Page: SizeGrip >>>> Hidden Text <<<< This is the embeded IE window expandcollapse popup>>>> Window <<<< Title: Network Connect - Sign In Class: #32770 Position: 842, 192 Size: 475, 492 Style: 0x14CE0044 ExStyle: 0x00010100 Handle: 0x00000000006504D0 >>>> Control <<<< Class: Internet Explorer_Server Instance: 1 ClassnameNN: Internet Explorer_Server1 Name: Advanced (Class): [CLASS:Internet Explorer_Server; INSTANCE:1] ID: Text: Position: 11, 67 Size: 438, 356 ControlClick Coords: 307, 152 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x0000000000690280 >>>> Mouse <<<< Position: 1168, 461 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< https://xxxx.xxxxxxx.xxx/ https://xxxx.xxxxxxx.xxx/ Go Sign-in Page: SizeGrip >>>> Hidden Text <<<< Edited June 21, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
Danp2 Posted June 21, 2014 Share Posted June 21, 2014 Did you try it with a partial title, ie: "Network Connect"? Repost your code along with the Scite output window results. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted June 22, 2014 Author Share Posted June 22, 2014 (edited) Did you try it with a partial title, ie: "Network Connect"? Repost your code along with the Scite output window results. Yeah, tried that. For now, im just trying to get it to click the submit button, from there i will fill in the rest of the code, so im just working with this right now: #include <IE.au3> ControlFocus("Network Connect - Sign In","","[CLASS:Internet Explorer_Server; INSTANCE:1]") $oPopup = _IEAttach ("Network Connect", "title") $oInput = _IEGetObjByName($oPopup, "btnSubmit") _IEAction($oInput, "click") Console Output: --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Error from function _IEAction(click), $_IESTATUS_InvalidDataType Edited June 22, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
Danp2 Posted June 22, 2014 Share Posted June 22, 2014 $oPopup = _IEAttach ("Network Connect", "title") This won't work to connect to an embedded IE object. You have to use "embedded" as the sMode parameter. Try this: #include <IE.au3> $oPopup = _IEAttach ("Network Connect", "embedded") $oInput = _IEGetObjByName($oPopup, "btnSubmit") _IEAction($oInput, "click") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted June 22, 2014 Author Share Posted June 22, 2014 $oPopup = _IEAttach ("Network Connect", "title") This won't work to connect to an embedded IE object. You have to use "embedded" as the sMode parameter. Try this: #include <IE.au3> $oPopup = _IEAttach ("Network Connect", "embedded") $oInput = _IEGetObjByName($oPopup, "btnSubmit") _IEAction($oInput, "click") Ok, i see what you mean now! Its working, thanks so much Danp2 Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 3, 2014 Author Share Posted July 3, 2014 (edited) Hmmm, so i got back from my work trip to continue my little project and it seems using a loop causes some problems. (Basically i want the program to run and wait till the embedded page has loaded, then send my log in information, then stop) If i use: #include <IE.au3> #include <MsgBoxConstants.au3> Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe") While 1 Sleep(1000) WinActivate("Network Connect - Sign In") $Attach = _IEAttach ("Network Connect", "embedded") If _IELoadWait($Attach) = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Complete",1) Exit Else MsgBox($MB_SYSTEMMODAL, "", "Incomplete",1) EndIf WEnd It works and runs the loop until it loads then stops when its loaded. Now, if i do anything else, say use the code i want, the loop bugs out and cant find the attached IE window. #include <IE.au3> #include <MsgBoxConstants.au3> Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe") While 1 Sleep(1000) WinActivate("Network Connect - Sign In") $Attach = _IEAttach ("Network Connect", "embedded") If _IELoadWait($Attach) = 1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Complete",1) $Button = _IEGetObjByName($Attach, "btnSubmit") _IEAction($Button, "click") Exit Else ;MsgBox($MB_SYSTEMMODAL, "", "Incomplete",1) Sleep(1000) EndIf WEnd The output would just be --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IELoadWait, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IELoadWait, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IELoadWait, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch --> IE.au3 T3.0-1 Error from function _IELoadWait, $_IESTATUS_InvalidDataType Any ideas as to whats going on? Edited July 3, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
Danp2 Posted July 3, 2014 Share Posted July 3, 2014 A few thoughts... It's possible that the MsgBox is affecting the outcome. Does your initial code still work if you change MsgBox to ConsoleWrite? Add some error checking after the _IEAttach call. No point in calling _IELoadWait if the _IEAttach failed. According to the help file, _IELoadWait has a default timeout of 5 mins. Is your While loop even necessary? If you need to stick with the While loop, I would recommend moving the WinActivate / _IEAttach commands outside of the loop. You may also want to replace WinActivate with WinWaitActive. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 3, 2014 Author Share Posted July 3, 2014 (edited) 1. I have only been using the MsgBox to show me whats happening inside the loop, it just so happens its the only thing that is getting the loop check to work. ConsoleWrite Outputs still don't get the _IELoadWait to succeed, as with the MsgBox, it does 2. I'm still not as good as i hoped to be with using Autoit for the time i have been using it. Only thing i could see was an output error of 7, which is: 7 ($_IEStatus_NoMatch) - No Match 3. Already tried to use just _IELoadWait, script stops running after with error output of 3, which is: 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4. Using WinWaitActive forces me to click the window if its running behind something before the rest of the script continues, which is what i want to avoid, so WinActivate brings the window back to the front. I've tried setting a delay and timeout for _IELoadWait but ended up and trying, all the different loops and nothing works unless i have MsgBox in it Edited July 3, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 7, 2014 Author Share Posted July 7, 2014 *bump* Anyone got an idea as to whats up? Link to comment Share on other sites More sharing options...
Danp2 Posted July 9, 2014 Share Posted July 9, 2014 Run the following in Scite and post the results from the Output window: #include <IE.au3> Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe", @SW_MAXIMIZE) If WinWait("Network Connect - Sign In", "", 10) = 0 Then ConsoleWrite("WinWait failure" & @CRLF) EndIf $oIE = _IEAttach ("Network Connect", "embedded") If @error = $_IEStatus_Success Then ConsoleWrite("_IEAttach success" & @CRLF) _IELoadWait($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IELoadWait success" & @CRLF) $Button = _IEGetObjByName($oIE, "btnSubmit") _IEAction($Button, "click") Else ConsoleWrite("_IELoadWait failure" & @CRLF) EndIf Else ConsoleWrite("_IEAttach failure" & @CRLF) EndIf Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 9, 2014 Author Share Posted July 9, 2014 (edited) Hey Danp2 Thanks for getting back to me The code you gave me didnt work, the @SW_MAXIMIZE cause the software to not load. So i used your code, less @SW_MAXIMIZE #include <IE.au3> Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe") If WinWait("Network Connect - Sign In", "", 10) = 0 Then ConsoleWrite("WinWait failure" & @CRLF) EndIf $oIE = _IEAttach ("Network Connect", "embedded") If @error = $_IEStatus_Success Then ConsoleWrite("_IEAttach success" & @CRLF) _IELoadWait($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IELoadWait success" & @CRLF) $Button = _IEGetObjByName($oIE, "btnSubmit") _IEAction($Button, "click") Else ConsoleWrite("_IELoadWait failure" & @CRLF) EndIf Else ConsoleWrite("_IEAttach failure" & @CRLF) EndIf Output: --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop --> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch _IEAttach failure +>00:32:59 AutoIt3.exe ended.rc:0 +>00:32:59 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.8168 I have also noticed that if i dont click on the Network Connect window that pops up, nothing will attach to it. I have to actually click on the little software window in order for the attach to work. (Thats why i use the WinActivate("Network Connect - Sign In")) Edited July 9, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
Solution Danp2 Posted July 9, 2014 Solution Share Posted July 9, 2014 This seems to work for me: expandcollapse popup#include <IE.au3> Local $hWin, $siteURL $siteURL = "https://your.url.here/" Run("C:\Program Files (x86)\Juniper Networks\Network Connect 7.1.17\dsNetworkConnect.exe") $hWin = WinWait("Network Connect - Sign In", "", 10) If $hWin = 0 Then ConsoleWrite("WinWait failure" & @CRLF) Exit EndIf ControlSetText($hWin, "", "[CLASS:Edit; INSTANCE:1]", $siteURL) ControlClick($hWin, "", "[CLASS:Button; INSTANCE:1]") Do Sleep(2000) $oIE = _IEAttach ($hWin, "embedded") Until IsObj($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IEAttach success" & @CRLF) _IELoadWait($oIE) If @error = $_IEStatus_Success Then ConsoleWrite("_IELoadWait success" & @CRLF) $Button = _IEGetObjByName($oIE, "btnSubmit") _IEAction($Button, "click") Else ConsoleWrite("_IELoadWait failure" & @CRLF) EndIf Else ConsoleWrite("_IEAttach failure" & @CRLF) EndIf t1ck3ts 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 10, 2014 Author Share Posted July 10, 2014 (edited) Oh wow, OK! It didnt occur to me to push the url on program startup since after a sucsessful connect, the url is remembered for next time use. I'll continue with my script and see if the complete automation was a success, Thanks again Danp2, ill like for now and update with 'Solved' as soon as im done Edited July 10, 2014 by t1ck3ts Link to comment Share on other sites More sharing options...
t1ck3ts Posted July 10, 2014 Author Share Posted July 10, 2014 Updated with 'Solved' Danp2. For now it seems to be behaving, as i tweak and add more things, i will be sure to post back in here Thanks for the help, really appreciate it. Link to comment Share on other sites More sharing options...
Danp2 Posted July 10, 2014 Share Posted July 10, 2014 You're welcome! Latest Webdriver UDF Release Webdriver Wiki FAQs 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