Jump to content

_IEFormElementCheckboxSelect gives $_IEStatus_InvalidObjectType error


bhumis
 Share

Recommended Posts

Hi,

I searched teh help file and also thsi forum before posting this question. I am new to AutoIT.

I tried passing different parameters in _IEFormElementCheckboxSelect but none of them works. Here is the viewsource of the checkbox.

This specific html file does not have any "form" name or no "iframes" so i am directly using __IEGetObjByName and then then trying to select the checkbox.

<tr>

<td>Criticality Filter <span style='color:red'>*</td>

<td><input name='Filter1' type='checkbox' value='High'>High

<input name='Filter2' type='checkbox' value='Medium'>Medium

<input name='Filter3' type='checkbox' value='Low'>Low</td>

<td>The filter for criticality.</td>

</td>

</tr>

AutoIt code:

$Filter1 = "High"

Local $oFilter1 = _IEGetObjByName($oIE, "Filter1") --- This one does not give any error

Local $oCheckBox = _IEFormElementCheckBoxSelect($oFilter1, $Filter1, "Filter1", 1, "byValue") -- This gives $_IEStatus_InvalidObjectType error

_IEAction($oCheckBox, "click")

I even tried with index that one gives error as well.

Any help is greately appreciated.

Thanks,

bhumis

Link to comment
Share on other sites

Get the Form object instead, and pass that in...the help file example should be all you need

; *******************************************************
; Example 1 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byValue. Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckBoxSelect($oForm, "gameBasketball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameFootball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameTennis", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameBaseball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameBasketball", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameFootball", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameTennis", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, "gameBaseball", "", 0, "byValue")
Sleep(1000)
Next

; *******************************************************
; Example 2 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex. Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckBoxSelect($oForm, 3, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 2, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 1, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 0, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 3, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 2, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 1, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 0, "", 0, "byIndex")
Sleep(1000)
Next

; *******************************************************
; Example 3 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex in the group that shares the name checkboxG2Example
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************

#include <IE.au3>

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckBoxSelect($oForm, 0, "checkboxG2Example", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 1, "checkboxG2Example", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 0, "checkboxG2Example", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckBoxSelect($oForm, 1, "checkboxG2Example", 0, "byIndex")
Sleep(1000)
Next

edit: since you already have the object, you can just change the .checked = true, or .checked = false

$oFilter1.checked = true

This is straight from the _IEFormElementCheckBoxSelect function:

Switch $f_select
  Case -1
   Return SetError($_IEStatus_Success, 0, $oItem.checked)
  Case 0
   If $oItem.checked Then
    $oItem.checked = False
    If $f_fireEvent Then
     $oItem.fireEvent("onChange")
     $oItem.fireEvent("OnClick")
    EndIf
   EndIf
   Return SetError($_IEStatus_Success, 0, 1)
  Case 1
   If Not $oItem.checked Then
    $oItem.checked = True
    If $f_fireEvent Then
     $oItem.fireEvent("onChange")
     $oItem.fireEvent("OnClick")
    EndIf
   EndIf
   Return SetError($_IEStatus_Success, 0, 1)
  Case Else
   __IEErrorNotify("Error", "_IEFormElementCheckboxSelect", "$_IEStatus_InvalidValue", "Invalid $f_select value")
   Return SetError($_IEStatus_InvalidValue, 3, 0)
 EndSwitch
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thank you So much! I couldn't get "form" object or "frame" object as there are no forms or frames. I got the object by using "_IEGetObjByName". In mycase "_IEFormElementCheckBoxSelect" didn't work.

But "$oFilter1.checked = True" worked well.

-bhumis

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
 Share

  • Recently Browsing   0 members

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