rootx Posted January 12, 2017 Share Posted January 12, 2017 (edited) <input id="cb-select-all-1" type="checkbox"> $chk= _IEGetObjById($oIE,"cb-select-all-1") _IEFormElementCheckBoxSelect($chk, "", "", 1) How can I set it to CHECKED? Thx Edited January 13, 2017 by rootx Link to comment Share on other sites More sharing options...
anthonyjr2 Posted January 12, 2017 Share Posted January 12, 2017 (edited) Does what you're doing not work? The 1 as the 4th parameter of _IEFormElementCheckBoxSelect should be checking the box. EDIT: You may need to specify a string in the second parameter. You do need to specify, since your checkbox has no value you might want to change $sMode to 0 so it goes by index. Then you could do: _IEFormElementCheckBoxSelect($chk, 0, "", 1, 0) if it was the first checkbox on the page. EDIT2: Danp2 is right, I missed that. You need to have <input id="cb-select-all-1" type="checkbox" name="cb1"> $chk= _IEFormGetObjByName($oIE,"cb1") _IEFormElementCheckBoxSelect($chk, "", "", 1) I may be wrong, since my IE automation is a little rusty. Edited January 12, 2017 by anthonyjr2 UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
Danp2 Posted January 12, 2017 Share Posted January 12, 2017 _IEFormElementCheckBoxSelect is expecting the form object as the first parameter, not the checkbox element. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rootx Posted January 13, 2017 Author Share Posted January 13, 2017 (edited) I 19 hours ago, Danp2 said: _IEFormElementCheckBoxSelect is expecting the form object as the first parameter, not the checkbox element. True, I find it, $chk= _IEGetObjById($oIE,"bulk-action-form") ;form name _IEFormElementCheckBoxSelect($chk,0,"", 1, "byIndex") ; checkbox Now How can I get all checkbox index numb? They randomly change, and write my (for next loop) I nned to get the totals checks on the page. I try but return empty values. My target $chk= _IEGetObjById($oIE,"bulk-action-form") For $1 = 0 to 30 <-------------- The exactly tot num in the page _IEFormElementCheckBoxSelect($chk,$1,"", 1, "byIndex") Next $chk= _IEGetObjById($oIE,"bulk-action-form") _IEFormElementCheckBoxSelect($chk,0,"", 1, "byIndex");work _IEFormElementCheckBoxSelect($chk,1,"", 1, "byIndex");work ;try get all index values Local $oForms = _IEFormGetCollection($chk) Local $iNumForms = @extended Local $oForm For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($chk, $i) ConsoleWrite($oForm.name&@CRLF) Next Edited January 13, 2017 by rootx Link to comment Share on other sites More sharing options...
Danp2 Posted January 13, 2017 Share Posted January 13, 2017 Sorry, but I don't understand your question. Please restate and show the associated HTML if you think that will help. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rootx Posted January 13, 2017 Author Share Posted January 13, 2017 (edited) 1 hour ago, Danp2 said: Sorry, but I don't understand your question. Please restate and show the associated HTML if you think that will help. THX, 1. I want to know how many checkbox contains a web page 2. Is not a static page, then every time the number of check box changed 3. After finding the number of check boxes on the page, I will use this number to set the limit of my FOR loop. Ex. The php page contains 30 checkbox now, after 10 minutes 20, 10..... how can I get (READ) this number? $totchk = 30 $chk= _IEGetObjById($oIE,"bulk-action-form") For $1 = 0 to $totchk <-------------- The exactly tot num in the page _IEFormElementCheckBoxSelect($chk,$1,"", 1, "byIndex") Next I have tried before to grab this number without success. ;try get all index values $chk= _IEGetObjById($oIE,"bulk-action-form") Local $oForms = _IEFormGetCollection($chk) Local $iNumForms = @extended Local $oForm For $i = 0 To $iNumForms - 1 $oForm = _IEFormGetCollection($chk, $i) ConsoleWrite($oForm.name&@CRLF) Next Edited January 13, 2017 by rootx Link to comment Share on other sites More sharing options...
Danp2 Posted January 13, 2017 Share Posted January 13, 2017 Ok... Looks like you are using the wrong commands. Try this piece of untested code: $cnt = 0 $oForm = _IEGetObjById($oIE,"bulk-action-form") $oElements = _IEFormElementGetCollection($oForm, -1) For $oElement In $oElements If $oElement.type = "checkbox" Then $cnt += 1 EndIf Next MsgBox(64, $cnt, "Checkbox count") rootx 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted January 13, 2017 Share Posted January 13, 2017 Another option would be to just loop until the command fails: $i = 0 $oForm = _IEGetObjById($oIE,"bulk-action-form") While 1 _IEFormElementCheckBoxSelect($oForm,$i,"", 1, "byIndex") If @error Then ExitLoop $i += 1 WEnd rootx 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rootx Posted January 13, 2017 Author Share Posted January 13, 2017 1 hour ago, Danp2 said: Another option would be to just loop until the command fails: $i = 0 $oForm = _IEGetObjById($oIE,"bulk-action-form") While 1 _IEFormElementCheckBoxSelect($oForm,$i,"", 1, "byIndex") If @error Then ExitLoop $i += 1 WEnd Thx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now