Jump to content

Recommended Posts

Posted (edited)

Hey Guys, I am trying to automate a user sign in, and I am able to populate the username and password, but I am not able to click the Sign In button. I am about to get the correct information from the button because I tested it with a msgbox. Here is the code I currently have:

Local $o_form = _IEFormGetObjByName ($oIE, "loginform")
    
    Local $o_user = _IEFormElementGetObjByName ($o_form, "id")
    Local $o_password = _IEFormElementGetObjByName ($o_form, "passwd")
    Local $o_signin = _IEFormElementGetObjByName ($o_form, "SUBMIT_BUTTON")

    _IELoadWait($oIE)
    MsgBox(4096,"test", _IEFormElementGetValue($o_signin))
    Sleep(100)
    
    _IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(100)
    _IEFormElementSetValue ($o_password, $TargetPassword)
    Sleep(100)
    _IEAction($o_signin, "click")
    Sleep(100)

And here is the information from the site:

<!--  Sign in button -->
<img width="5" height="10" alt="X" src="/xmlpserver/xdo/images/spacer.gif">
<input name="SUBMIT_BUTTON" title="Please enter username and password" class="submitButtonEnable button" style="width: 120px;" onclick="normalLogin(event);" type="submit" value="Sign In">

Any ideas guys? I have search the forums and I could not find the answer to my problem. Anything would be help, thanks!

Edited by Chance1
Posted

tested it a couple times with no luck, I will keep trying. Just to be sure, the code you provided would just be in place of the "_IEAction($0_signin, "click") in my original post? Like so:

Local $o_form = _IEFormGetObjByName ($oIE, "loginform")
    
    Local $o_user = _IEFormElementGetObjByName ($o_form, "id")
    Local $o_password = _IEFormElementGetObjByName ($o_form, "passwd")
    Local $o_signin = _IEFormElementGetObjByName ($o_form, "SUBMIT_BUTTON")

    _IELoadWait($oIE)
    MsgBox(4096,"test", _IEFormElementGetValue($o_signin))
    Sleep(100)
    
    _IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(100)
    _IEFormElementSetValue ($o_password, $TargetPassword)
    Sleep(100)
    
    Local $oInputs = _IETagNameGetCollection($oIE, "input")

    For $oInput in $oInputs
        If StringStripWS($oInput.value, 7) = "Sign In" Then _IEAction($oInput, "click")
    Next
    sleep(100)

 

Posted

I have tried a couple different variations of the code you provide, changing the if statement and such, still not luck.I  was testing it and saw that it does go into the Then clause but still no click occurred. Any idea why?

Why would I want to check the input without white space?

Posted (edited)

It strips white space from the beginning and end of a string and also remove double spaces. I asked the same question. Ha-ha as subz told me you probably don't even need it. 

 

Can you post the full html code of the site or give the url?

Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Posted

think it could be something with the way it is clicking? I have seen on a couple different forums that you have to fire the onmouseodwn and onmouseup events. I tried it but with no luck, this is what I tried:

Local $oInputs = _IETagNameGetCollection($oIE, "input")
    For $oInput in $oInputs
        If StringStripWS($oInput.value, 7) = "Sign In" Then 
            $oInput.fireEvent("onmousedown")
            $oInput.fireEvent("onmouseup")
            _IEAction($oInput, "click")
        EndIf
    Next

Keep in mind I have never tried to trigger events so I could be trying to do this complete wrong. Any thoughts on this or know how I could clean up my syntax? Thanks. 

Posted

 

function normalLogin(event){
     if(event && event.preventDefault)
     {
       event.preventDefault(); 
     }
     else
     {
       event.returnValue = false;
     }
     var errMsg = "Please enter username and password";
     if(document.loginform.id.value == null || '' == document.loginform.id.value)
     {
       alert(errMsg);
       return false;
     }
     else
     {
       document.loginform.submit();  
     }
   };

 

Posted
26 minutes ago, Danp2 said:

Have you tried using _IEFormSubmit instead of clicking the button?

I tired using 

sleep(2000)
_IEFormSubmit($o_form)
sleep(100)

with no luck

Posted (edited)
38 minutes ago, boy233 said:

I think that works!

Sleep(2000)
_IEImgClick ($oIE, "/xmlpserver/xdo/images/spacer.gif", "src")
_IELoadWait($oIE)

 

I tired it and also had no luck. I also tried 

sleep(2000)
_IEFormImageClick ($oIE, "/xmlpserver/xdo/images/spacer.gif", "src")
_IELoadWait($oIE)

but I ended up getting an error in the IE.au3 script. I also tried this, where $o_signin is the "Sign On" button, also no luck.

sleep(2000)
    _IEImgClick ($o_signin, "/xmlpserver/xdo/images/spacer.gif", "src")
    _IELoadWait($oIE)

 

Edited by Chance1
Posted

@boy233 Sorry, but your reply makes no sense to me. The code you posted is pointing at

<img width="5" height="10" alt="X" src="/xmlpserver/xdo/images/spacer.gif">

when the goal is to click this

<input name="SUBMIT_BUTTON" title="Please enter username and password" class="submitButtonEnable button" style="width: 120px;" onclick="normalLogin(event);" type="submit" value="Sign In">

 

Posted

@Danp2 Sorry you're correct ... If the button was image it would work!

I think that's how it works !

$oForm = _IEFormGetObjByName ($oIE, "Form Name")
_IEFormSubmit($oForm, 0)

 

Posted

@Danp2 That is a very clever idea. I cannot seem to get it working but maybe I am getting the handle wrong. I am trying this, 

local $hWnd = _IEAction($oIE, "hwnd")
sleep(200)  
_IEAction($o_signin, "focus")
sleep(200)
ControlSend($hWnd, '', "[CLASS:Internet Exploerer_server; INSTANCE:1]", "{ENTER}")
sleep(200)

But it was not working

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...