Jump to content

How to click the button (onclick of javascript) without name/class?


Recommended Posts

Hi, all

I need to click the Login button after filling the Username/password. Now I could successfully set UserName/Password but how to use _IEActions to click the Login button which has a onclick behind (<INPUT onclick="return validate();" value="Log In" type="submit"> of the HTML code below). Thanks for your help!

I tried to get it via below code but cannot work. Is it because it's not a Object or something else? I'm not familiar with HTML so could you please help me out? Thanks.

$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
  MsgBox(0, "Form Input Type", "Form: " & $oInput.form.name & " Type: " & $oInput.type)
  If $oInput.type = "submit" Then
   MsgBox(0, "!!!!!!!!!!!!", "submit")
   _IEAction($oInput, "click")
   If @error Then
    MsgBox(0, "Error", @error)

Below is part of HTML code.

<DIV align="center">
<FORM method="POST" name="loginForm" action="/LoginServlet">
<TABLE border="1" cellSpacing="0" cellPadding="0">
      <TABLE cellSpacing="0" cellPadding="2" width="200">
        <TR bgColor="#336699">
          <TD colSpan="2"><FONT color="#ffffff"
        <TR bgColor="#cccccc">
          <TD>          Username:         </TD>
          <TD><INPUT name="username" size="20" type="textbox"></TD></TR>
        <TR bgColor="#cccccc">
          <TD>          Password:         </TD>
          <TD><INPUT name="password" size="20" type="password"></TD></TR>
        <TR bgColor="#cccccc">
          <TD colSpan="2" align="center"><INPUT onclick="return validate();" value="Log In" type="submit">
        <INPUT value="Reset" type="reset"></TD></TR></TBODY></TABLE></TD></TR>
  <table border="1">
  <TR><TD>User Name</TD><TD><input name="username" type="text" value=""/></TD></TR>
  <TR><TD>Password</TD><TD><input name="password" type="password" value=""/></TD></TR>
  <TR><TD colspan="2" align="center"><input value="Login" type="submit"/></TD></TR>
--><INPUT name="requestURL" value="/BuildSta.jsp?type=Test&amp;version=1.21"

[More Information]

I tried _IELinkClickByText or something else, it doe NOT work.

Edited by Archer
Link to comment
Share on other sites


I checked some topics in Autoit forum and found it may be caused that I debugged this code at IE9. I just now compiled and run against a IE 8 env. and everything's OK.

But still, why IE9 cannot work? Does Autoit need to fix it or a MS bug?

Link to comment
Share on other sites

Most likely addressd in latest AutoIt beta - try it out.


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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

  • Recently Browsing   0 members

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