Jump to content
Sign in to follow this  
kelso

vSphere Web Page - Automation of Username and Password

Recommended Posts

Hi,

 

I'm having a problem with vSphere webpage, for some reason, I can't automate the injection of username and password...

 

<div id="loginForm">
   <p class="loginRow">
      <span class="loginLabel">User name:</span>
      <input class="margeTextInput" id="username" type="text">
    </p>
    <p class="loginRow">
      <span class="loginLabel">Password:</span>
      <input class="margeTextInput" id="password" type="password">
    </p>
    <p id="sessionID">
       <label id="checkboxLabel"><input disabled="true" id="sspiCheckbox" onchange="enableSspi(this);" type="checkbox">Use Windows session authentication</label>
    </p>
    <p id="loginButtonRow">
       <input disabled="" class="button blue" id="submit" onclick="submitentry()" type="submit" value="Login">
    </p>
</div>

 

What I tried:

 

.....
      $login_form = _IEGetObjById($ie, "loginForm")

      $email_field = _IEGetObjById($login_form, "username")
      $pass_field = _IEGetObjById($login_form, "password")

      _IEFormElementSetValue($email_field, $email)
      _IEDocInsertText($email_field, $email)
      _IEFormElementSetValue($pass_field, $password)
      _IEDocInsertText($pass_field, $password)
 ....
 
 Also Tried -
 
 _IEFormElementGetObjByName instead of _IEGetObjById

what am I doing wrong here???

Share this post


Link to post
Share on other sites
5 minutes ago, JLogan3o13 said:

@kelso why don't you just install the integration plug-in, so you don't have to use a username and password?

@JLogan3o13 The integration plug-in will only help me with AD accounts, right? I need this for local accounts as well.

 

Share this post


Link to post
Share on other sites

I would drop the call to _IEDocInsertText as I don't believe you are using it in the intended way.

You didn't state where your code was failing, but I'm guessing it's on the calls to _IEGetObjById. Again, I believe you are trying to use it improperly. Try this --

$email_field = _IEGetObjById($ie, "username")
$pass_field = _IEGetObjById($ie, "password")

_IEFormElementSetValue($email_field, $email)
_IEFormElementSetValue($pass_field, $password)

 

Share this post


Link to post
Share on other sites

So you're trying to log into the client as a \vSphere.local account? My personal experience trying to automate the login page has never gone well; I finally gave up and just script anything I want to do through PowerCLI rather than trying to do it through the GUI. One of our IUIAutomation gurus may wander along with a suggestion on the web login, though.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
3 minutes ago, JLogan3o13 said:

So you're trying to log into the client as a \vSphere.local account? My personal experience trying to automate the login page has never gone well; I finally gave up and just script anything I want to do through PowerCLI rather than trying to do it through the GUI. One of our IUIAutomation gurus may wander along with a suggestion on the web login, though.

My code is not failing, that's the problem.

The webpage comes up, all well, like any other webpage that I configured in the past, but for this specific one, it doesn't inject the user/password I use.

I tried to drop the _iedocinserttext, no luck.

4 minutes ago, Danp2 said:

I would drop the call to _IEDocInsertText as I don't believe you are using it in the intended way.

You didn't state where your code was failing, but I'm guessing it's on the calls to _IEGetObjById. Again, I believe you are trying to use it improperly. Try this --

$email_field = _IEGetObjById($ie, "username")
$pass_field = _IEGetObjById($ie, "password")

_IEFormElementSetValue($email_field, $email)
_IEFormElementSetValue($pass_field, $password)

 

Thank you... if anyone have any suggestions, let me know.

Share this post


Link to post
Share on other sites
7 minutes ago, Danp2 said:

I would have expected to see errors in the Scite output window for the last two called to _IEGetObjById because the first parameter is invalid.

Can you please explain  why is it invalid?

the only thing I can see in Scite is IE_v1.au3 the requested action with this object has failed:

WEnd

WEnd^ ERROR

 

 

Share this post


Link to post
Share on other sites
Quote

_IEGetObjById

Returns an object variable by id

#include <IE.au3>
_IEGetObjById ( ByRef $oObject, $sID )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window or Frame object
$sID Specifies id of the object you wish to match

You were passing an DIV element as the first parameter, which isn't valid based upon my reading of the help file entry for _IEGetObjById.

Share this post


Link to post
Share on other sites
1 minute ago, Danp2 said:

You were passing an DIV element as the first parameter, which isn't valid based upon my reading of the help file entry for _IEGetObjById.

Thanks, here's the example tho:

 

; Open a browser to the basic example, get an object reference
; to the DIV element with the ID "line1". Display the innerText
; of this element to the console.

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oDiv = _IEGetObjById($oIE, "line1")

MsgBox($MB_SYSTEMMODAL, "Line1", $oDiv.innertext)
Edited by kelso

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...