Sign in to follow this  
Followers 0
sun

How to script Checkbox in IE

6 posts in this topic

Hi,

I want to check a checkbox of table in IE.

I don't come accorss my mind how to script check the checkbox.

The related html is as following.

<tbody class="yui-dt-data" tabindex="0" style="">

<tr id="yui-rec0" class="yui-dt-first yui-dt-even" style="">

<td class="yui-dt0-col-check yui-dt-col-check yui-dt-first" headers="yui-dt0-th-check">

<div class="yui-dt-liner">

<input class="yui-dt-checkbox" "type="checkbox"> <===Plz help how to script this checkbox

</div>

Share this post


Link to post
Share on other sites



AutoIT has an UDF (User Defined Functions) for IE (see the help file).

Maybe function _IEFormElementCheckBoxSelect does what you need?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I had to use the following to get it to work for me.

$oForm = _IEFormGetCollection($oIE, 0)
_IEFormElementCheckBoxSelect($oForm, 0, "", 1, "byIndex")

Share this post


Link to post
Share on other sites

Thank you for ur reply.

I tried to some functions.

And $oForm is returned to null in the following msgbox.

$oForm = _IEFormGetCollection($oIE, 0)

MsgBox(0, "Form return value", "There are " & $oForm )

Sleep(20000)

_IEFormElementCheckBoxSelect ($oForm,0,"",1,"byIndex")

I changed it. However, $_IEStatus_InvalidObjectType is occured from function _IEFormElementCheckboxSelect.

$oTable = _IETableGetCollection ($oIE, 0)

$iNumtables = @extended

MsgBox(0, "Table Info", "There are " & $iNumtables )

Sleep(2000)

$oCheckbox=_IEFormElementCheckBoxSelect($oTable,0,"",1,"byIndex")

MsgBox(0, "Table Info", "There are " & $oCheckbox )

Share this post


Link to post
Share on other sites

Thank you for ur reply.

I tried to some functions.

And $oForm is returned to null in the following msgbox.

$oForm = _IEFormGetCollection($oIE, 0)

MsgBox(0, "Form return value", "There are " & $oForm )

Sleep(20000)

_IEFormElementCheckBoxSelect ($oForm,0,"",1,"byIndex")

I changed it. However, $_IEStatus_InvalidObjectType is occured from function _IEFormElementCheckboxSelect.

$oTable = _IETableGetCollection ($oIE, 0)

or

$a1 = _IEGetObjById($oIE, "instances-panel_datatable")

$oCheckbox=_IEFormElementCheckBoxSelect($oTable,0,"",1,"byIndex")

MsgBox(0, "Table Info", "There are " & $oCheckbox )

or

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What do you get when you change the script to output @error as well?

$oForm = _IEFormGetCollection($oIE, 0)
MsgBox(0, "Form return value", "There are " & $oForm & " Error: " & @error )

According to the help file _IEFormGetCollection "Returns a collection object variable representing the Forms in the document or a single form by index."

I suspect there are no forms (<Form> and </FORM>) in your html code.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  
Followers 0