Digistras Posted January 31, 2018 Posted January 31, 2018 Hi, I'm trying to code out auto fill by the "Class" name of a webpage. I have done some trial and errors but all resulted in failures. Quite frankly I'm really at a loss and confused state right now on how to code it or is it even possible. Any advise is fully appreciated. Following is my original code: expandcollapse popup#include <Constants.au3> #include <IE.au3> If $CmdLine[0] < 2 Then MsgBox($MB_OK, "Usage", "ps_Cisco SON <username> <password>") Else CiscoSON_login($CmdLine[1], $CmdLine[2]) EndIf Func CiscoSON_login($username, $password) Local $ie = _IECreate("https//10.9.11.2", 1) ; COMMENT OUT THIS SECTION IF NOT REQUIRED Local $oIE = _IEAttach("Cisco SON") _IELinkClickByText($oIE, "Continue to this website (not recommended).") If @error > 0 Then Local $i = 0 Do Sleep(500) $i = $i + 1 $ie = _IEAttach("Cisco SON") Until VarGetType($ie) == "Object" Or $i >= 10 EndIf If VarGetType($ie) == "Object" Then $hwnd = _IEPropertyGet($ie, "hwnd") WinSetState($hwnd, "", @SW_MAXIMIZE) ; $login_form = _IEFormGetObjByName($ie, "login_form") $username_field = _IEGetObjByClass($ie, "internal_login_form_username") $password_field = _IEGetObjByClass($ie, "internal_login_form_password") ;$login_button = _IEGetObjByName($ie, "trig_1") ;Might need to change these _IEFormElementSetValue($username_field, $username) _IEFormElementSetValue($password_field, $password) Send("{ENTER}") ;_IEFormSubmit($login_button) WinWaitClose($hwnd) Else MsgBox($MB_OK, "Cisco SON scripr Failure", "Automation failed to automate the login to Cisco SON. If this problem persists please contact your Automation Administrator.") EndIf EndFunc
Digistras Posted January 31, 2018 Author Posted January 31, 2018 This is the html source code of the website: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Cisco SON</title><link rel="shortcut icon" href="http://10.151.9.87:5000/gui/v3/auth/internal_login/favicon.ico"><meta name="description" content=""><link rel="stylesheet" href="Cisco%20SON_files/design.css" type="text/css"><link rel="stylesheet" href="Cisco%20SON_files/design_new.css" type="text/css"><link rel="stylesheet" href="Cisco%20SON_files/internal_login.css" type="text/css"></head><body><!--header area--><div class="top_section"><a class="float_left" href="http://10.151.9.87:5000/gui/v4/#/"><img src="Cisco%20SON_files/cisco_logo.png" alt="Cisco" title="Cisco"></a></div><!--main content area--><div class="content centered_page"><!--left bar area--><div class="left_bar"><div class="left_bar_box login_box"><div class="blue_gradient_strip white_title">Authentication Credentials</div><form method="post" action="/api/v1/system/auth/backends/internal/login" class="internal_login_form"><input placeholder="User name" class="internal_login_form_username" type="text"><input placeholder="Password" autocomplete="off" class="internal_login_form_password" type="password"><input class="big_button" value="Login" title="Login" type="submit"><br><div class="login_messages"><span class="login_success_message" style="display:none;">Login successful. Redirecting...</span><span class="login_fail_message" style="display:none;">Incorrect login credentials. Try again.</span></div></form></div></div><!--right content area--><div class="right_area"><div class="right_area_box login_box"><div class="blue_gradient_strip white_title">Internal Cisco SON Login</div><img src="Cisco%20SON_files/login_computer.png" alt="" title=""><p>Use the login details given to you by your system administrator.</p></div></div><script src="Cisco%20SON_files/json2.js" type="text/javascript"></script><script src="Cisco%20SON_files/namespacer.js" type="text/javascript"></script><script type="text/javascript">;(function(pageJS,intucell,undefined){'use strict';var ext_dic=JSON.parse("{\u0022nextUrl\u0022: \u0022http://10.151.9.87:5000/gui/v4/\u0022, \u0022rootUrl\u0022: \u0022/gui/v3/\u0022, \u0022sonApiVersion\u0022: \u0022v1\u0022}");for(var key in ext_dic){pageJS[key]=ext_dic[key];}}(nsModule('intucell.gui.pageJS'),intucell||{}));</script><script src="Cisco%20SON_files/jquery-1.js" type="text/javascript"></script><script src="Cisco%20SON_files/sugar-1.js" type="text/javascript"></script><script src="Cisco%20SON_files/xregexp.js" type="text/javascript"></script><script src="Cisco%20SON_files/argspec.js" type="text/javascript"></script><script src="Cisco%20SON_files/jquery.js" type="text/javascript"></script><script src="Cisco%20SON_files/jquery_002.js" type="text/javascript"></script><script src="Cisco%20SON_files/cupcake.js" type="text/javascript"></script><script src="Cisco%20SON_files/logger.js" type="text/javascript"></script><script src="Cisco%20SON_files/utils.js" type="text/javascript"></script><script src="Cisco%20SON_files/son_api_interface.js" type="text/javascript"></script><script src="Cisco%20SON_files/auth.js" type="text/javascript"></script><script src="Cisco%20SON_files/jquery_rest.js" type="text/javascript"></script><script src="Cisco%20SON_files/default_args.js" type="text/javascript"></script><script src="Cisco%20SON_files/internal_login.js" type="text/javascript"></script></div></body></html>
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