Jump to content
Sign in to follow this  
vaibhavs

Finding first form button & Click ?

Recommended Posts

vaibhavs

Hi,

I have a web page as below:

<html>
<head>
<title>TTTTTT</title>
</head>
<body>
<form name="myform" method="post" action="myaction.php">
<input type="button" value="Press Me" onclick="java script:alert('1111111111')"/><br>
<input type="button" value="Press Me" onclick="java script:alert('2222222222')"/><br>
<input type="button" value="Press Me" onclick="java script:alert('3333333333')"/><br>
<input type="button" value="Press Me" onclick="java script:alert('4444444444')"/><br>
<input type="button" value="Press Me" onclick="java script:alert('5555555555')"/><br>
</form>
</body>
</html>

I want to "Click" the first button.

How can I do this ? Tried some options but could not get thru.

I tried this:

#include <IE.au3>
#Include <Constants.au3>

$oIE = _IEAttach ("TTTTTT", "Title")
_IELoadWait ($oIE)
        
$oForm = _IEFormGetObjByName ($oIE, "myform")
$oQuery = _IEFormElementGetCollection ($oForm, 1)

_IEAction ($oQuery, "click")

But it did not work.

I am sure I am not calling the correct function.

Please help!

Thx

Vai

Share this post


Link to post
Share on other sites
ProgAndy

this works :) java script: is written as one word.

CODE
#include <IE.au3>

#Include <Constants.au3>

$oIE = _IECreate()

;~ $oIE = _IEAttach ("TTTTTT", "Title")

_IEDocWriteHTML($oIE,"<html><head><title>TTTTTT</title></head><body>"& _

"<form name=""myform"" method=""post"" " & _

"action=""myaction.php""><input type=""button"" " & _

"value=""Press Me"" onclick=""java script:alert('1111111111')""/>" & _

"<br><input type=""button"" value=""Press Me"" onclick=""java script:" & _

"alert('2222222222')""/><br><input type=""button"" "& _

"value=""Press Me"" onclick=""java script:alert('3333333333')""/><br><input " & _

"type=""button"" value=""Press Me"" onclick=""java script:alert('4444444444')""/>" & _

"<br><input type=""button"" value=""Press Me"" onclick=""java script:alert('555555" & _

"5555')""/><br></form></body></html>")

_IELoadWait ($oIE)

$oForm = _IEFormGetObjByName ($oIE, "myform")

$oQuery = _IEFormElementGetCollection ($oForm, 0)

_IEAction ($oQuery, "click")


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
vaibhavs

Hi ProgAndy,

Thx for the script, but I guess I did not explain the problem well.

I have an online webpage with a row of buttons.

Buttons do not have any unique tag.

I need to click certain buttons based on certain evaluations.

I am trying to create a script / function which will click a particular button.

I have pasted a more detailed example here.

<html>
<head>
<title>TTTTTT</title>
</head>
<body>
<form name="myform" method="post" action="myaction.php">
<table border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td width="50%">1111</td>
    <td width="50%">
<input type="button" value="Press Me" onclick="java script:alert('1111111111')"/></td>
  </tr>
  <tr>
    <td width="50%">2222</td>
    <td width="50%">
<input type="button" value="Press Me" onclick="java script:alert('2222222222')"/></td>
  </tr>
  <tr>
    <td width="50%">3333</td>
    <td width="50%">
<input type="button" value="Press Me" onclick="java script:alert('3333333333')"/></td>
  </tr>
  <tr>
    <td width="50%">4444</td>
    <td width="50%">
<input type="button" value="Press Me" onclick="java script:alert('4444444444')"/></td>
  </tr>
  <tr>
    <td width="50%">5555</td>
    <td width="50%">
<input type="button" value="Press Me" onclick="java script:alert('5555555555')"/></td>
  </tr>
</table>
</form>
</body>
</html>

When I am evaluating the first row, I have to "click" the button in the first row.

Likewise, when I working on the 3rd row, I need to "click" the button in the 3rd row.

Is there anyway I can reference the button of a particular row and "click" it.

I was thinking of the following 2 functions:

$row = _IETableWriteToArray($oTable2)

_IEAction ($ref, "click")

Any ideas are appreciated

I am really stuck with this one and its very imp part of my script!!

Looking for some help.

Vai

Share this post


Link to post
Share on other sites
vaibhavs

Anyone with any solution for this??

I am in realy need for a solution to this problem.

Please help!!

Vai

Share this post


Link to post
Share on other sites
ProgAndy

If the Buttons are always the same, you can youse the Example I Posted:

In the last post, I just added your HTML to Code :)

$oForm = _IEFormGetObjByName ($oIE, "myform")

$oQuery = _IEFormElementGetCollection ($oForm, 0) ; Get The first Button on Page

_IEAction ($oQuery, "click") ; Click It

$oQuery = _IEFormElementGetCollection ($oForm, 1) ; Get The second Button on Page

_IEAction ($oQuery, "click") ; Click It


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.