CubicleJockey Posted October 2, 2008 Share Posted October 2, 2008 Hello, I am new to Autoit (today) and I am having trouble figuring out how to jump to the ListItem's in multiple ItemList. I want to use the IE methods just need to know which ones to use. I think my problem might extend from the listitem box's are nested inside of a form element. I do not have a current script because the one I was playing with is all over from trying so many different things. Below is the HTML section that has the multiple ItemList boxes in it and a screen shot is attached to make it easier to see what I mean. <form id="publish-new-package-form" enctype="multipart/form-data" action="publishNewPackage" method="post"> <div style="padding: 30px;"> <input id="package-application-id" type="hidden" value="1" name="applicationID"/> <table class="clear" border="1"> <tbody> <tr> <td> <div style="margin-bottom: 10px;">Subscriber Group:</div> <select id="package-select-subscriber-group" class="fixed" onchange="validatePackageMapComboCount('package')" style="width: 150px;" size="5" multiple="1" name="group"> <option value="default">(default)</option> <option value="51">Blacklisted</option> <option value="103">Emulated devices</option> <option value="1">Opt Out</option> <option value="102">SahiGroup</option> <option value="104">tgroup722400832</option> </select> </td> <td> <div style="margin-bottom: 10px;">Network:</div> <select id="package-select-network" class="fixed" size="5" onchange="validatePackageMapComboCount('package')" style="width: 150px;" multiple="1" name="network"> <option value="3">All</option> <option value="2">Network367549980</option> <option value="1">Network879545144</option> **OPTIONS CUT FOR WORK REASONS** </select> </td> <td style="display: none;"> </td> <td> <div style="margin-bottom: 10px;">Device Type:</div> <select id="package-select-device-type" class="fixed" size="5" onchange="validatePackageMapComboCount('package')" style="width: 150px;" multiple="1" name="deviceType"> <option value="4">6680</option> <option value="10">All</option> <option value="11">TestThingy</option> <option value="5">OhNoesNStuff</option> **OPTIONS CUT FOR WORK REASONS </select> </td> <td> <div style="margin-bottom: 10px;">Locale:</div> <select id="package-select-locale" class="fixed" size="5" onchange="validatePackageMapComboCount('package')" style="width: 150px;" multiple="1" name="locale"> <option value="4">All</option> <option value="2">Locale775167</option> <option value="1">Locale999392</option> <option value="5">UK English</option> <option value="3">US</option> <option value="6">US English</option> </select> </td> </tr> <tr> <td colspan="2"> <textarea id="package-notes-package-hidden" style="display: none;" name="packageNotes"/> <input id="package-path-hidden" type="hidden" value="" name="pathFull"/> <div class="manage-packages-publish-file-div"> <div style="margin-bottom: 10px;">Package:</div> <div> <input id="package-path" type="file" name="package"/> </div> </div> </td> <td colspan="2"> <div> <div class="notes">Package Notes:</div> <div> <textarea id="package-notes-package" class="notes" maxlength="1000" name="displayNotes"/> </div> </div> </td> </tr> </tbody> </table> </div> </form> If anyone can direct me to the write methods to use or a know way of getting to this I would much appreciate it Note: Some values from the HTML are removed for work related reasons. Any help would be much appropriated, Thanks thanks thanks CubicleJockey (Autoit newbie) Link to comment Share on other sites More sharing options...
DaleHohm Posted October 3, 2008 Share Posted October 3, 2008 Start by looking at _IEFormGetObjByName, _IEFormElementGetObjectByName and _IEFormElementOptionselect Dale 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 More sharing options...
CubicleJockey Posted October 3, 2008 Author Share Posted October 3, 2008 Start by looking at _IEFormGetObjByName, _IEFormElementGetObjectByName and _IEFormElementOptionselectDaleThanks for a starting point I will start there. Link to comment Share on other sites More sharing options...
CubicleJockey Posted October 3, 2008 Author Share Posted October 3, 2008 (edited) Hello again,This was my first attempt at these functions.I tried using the methods you gave me in These sets of functions. You can ignore the Logging methods those are in house things. selectFromFormElementOption and it doesn't seem to do anything, not even error have tried all scenerios like byValue, byText and byIndex.Below are the two functions that I am using in and they don't seem to be doing anything. I know the AssertFormByName works because we have other in-house stuff using that one just find that is just for reference for the selectFromFormElementOption function. The html that I am getting the tags form are in the orignal post above: The Values I am trying to pass to selectFromFormElementOption are:selectFromFormElementOption("publish-new-package-form", "group", "Emulated device", 1, "ByText") (group is the name of the element also tried the id)expandcollapse popupFunc assertFormByName($form, $lAssertWaitTime = $assertWaitTime, $o_object = $oGlobalBrowserInstance, $logging = 0, $index = 0) $functionName = "assertFormByName()" checkPerformanceMonitoring($functionName) _IELoadWait($o_object) ;Varible for how many times user has passed through the loop $loopNumber = 0 ;Check value to end the loop if a success is found $checkValue = 0 ;Perform loop while value is not found, and the loop count is less or equal to the wait time set. While($checkValue = 0 and $loopNumber <= $lAssertWaitTime) ;Get Element Object $oForm = _IEFormGetObjByName($o_object, $form, $index) ;See if Element Object has rendered on the screen $ocheckValue = _IELoadWait($oForm) ;If Success If($ocheckValue = 1) Then ;log success If $logging = 0 Then writeLog("success", "Form: <B>" & $form & "</B> rendered successfully.", $functionName) EndIf Return $oForm ;No Success: wait for 1 second or log a failure Elseif($ocheckValue = 0) Then ;If it hasn't exhausted the amount of times to go through the loop, then wait a second, and increase the loop number If($loopNumber < $lAssertWaitTime) Then ;Wait for 1 second Sleep(1000) ;Increase Loop Number $loopNumber = $loopNumber + 1 ;If it has exhausted how many times to go through the loop, log a failure and increase the loop number to kick out of the loop Else ;Log Failure If $logging = 0 Then writeLog("failure", "Form: <B>" & $form & "</B> did not rendered in <B>" & $loopNumber & "</B> seconds.", $functionName) EndIf Return 0 EndIf EndIf WEnd EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Function: selectFromFormElementOption() ;;Written by: André Davis ;;Date: 10/03/2008 ;; ;;Description: ;; This function lets the user select a value from a ElementOptionselect ;; ;;Variables: ;; $form - Form that the ElementOptionselect is found in ;; $elemenet - The element (Optionselect) to select items from ;; $selectValueOrIndex - Item to be selected either by the name or the index value ;; $selectMode - Specifies if the selection should be selected (1), deselected (0) or just return the state(-1), defaults to select (1) ;; $selectMatch - Specifies how the $selectValueOrIndex is match, Value("byValue"), Text("byText") or Index("byIndex"), defaults to Value ;; $lAssertWaitTime - Amount of time to wait ;; $o_object - The object that the element is found within ;; $logging - Whether to log or not, should be replaced by the global logging variable. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func selectFromFormElementOption($form, $element, $selectValueOrIndex, $selectMode = 1, $selectMatch = "byValue", $lAssertWaitTime = $assertWaitTime, $o_object = $oGlobalBrowserInstance, $logging = True) Local $functionName = "selectFromFormElementOptionByValue" checkPerformanceMonitoring($functionName) Local $oForm = assertFormByName($form, $lAssertWaitTime, $o_object, $logging) If Not IsObj($oForm) Then If $logging == 0 Then writeLog("failure", "Function could not continue becuase <B>" & $form & "</B> form could not be found on screen.", $functionName) EndIf Return 0 EndIf $formElement = _IEFormElementGetObjByName($oForm, $element) If $formElement == 0 Then If $logging == True Then If @error == 3 Then writeLog("failure", "Failed while searching for <B>'" & $element & "'</B> becasue there was Invalid Data Type", $functionName) ElseIf @error == 4 Then writeLog("failure", "Failed while searching for <B>'" & $element & "'</B> becasue there was Invalid Object Type", $functionName) ElseIf @error == 7 Then writeLog("failure", "Failed while searching for <B>'" & $element & "'</B> becasue there was No Match", $functionName) Else writeLog("failure", "Element serach failed for unknown reason while seraching for element '" & $element & "'", $functionName) EndIF EndIf Else If $logging == True Then writeLog("success", "Element <B>'" & $element & "' </B> was found", $functionName) EndIf EndIf $select = _IEFormElementOptionselect($formElement, $selectValueOrIndex, $selectMode, $selectMatch) If $select == "0" Then If $logging == True Then If $selectMode == 1 Then writeLog("failure", "Select <B>" & $selectValueOrIndex & "</B> failed in selection mode.", $functionName) ElseIf $selectMode == 0 Then writeLog("failure", "Select <B>" & $selectValueOrIndex & "</B> failed in deselection mode.", $functionName) Else writeLog("failure", "Select <B>" & $selectValueOrIndex & "</B> failed in return value mode.", $functionName) EndIf EndIF ElseIf $select == "1" Then If $logging = True Then If $selectMode == 1 Then writeLog("success", "Select <B>" & $selectValueOrIndex & "</B> failed in selection mode.", $functionName) ElseIf $selectMode == 0 Then writeLog("success", "Select <B>" & $selectValueOrIndex & "</B> failed in deselection mode.", $functionName) Else writeLog("success", "Select <B>" & $selectValueOrIndex & "</B> failed in return value mode.", $functionName) EndIf EndIf EndIf Return $select EndFuncIf anyone can point out any obvious mistakes or no no's I pulled that would be wonderful.I am also open to have a simple example of html and a small select writting for me to have a prototype using _IEFormGetObjByName, _IEFormElementGetObjectByName and _IEFormElementOptionselectAll help is appreciated very much and thank you ahead for your time and teachings.CubicleJockey Edited October 3, 2008 by CubicleJockey Link to comment Share on other sites More sharing options...
DaleHohm Posted October 4, 2008 Share Posted October 4, 2008 Can you describe a specific example of what you want to accomplish? Also, did you try running the examples in the helpfile? They are all stand-alone, complete code examples... run them and play with them. Dale 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 More sharing options...
CubicleJockey Posted October 6, 2008 Author Share Posted October 6, 2008 I think I found the problem the form that I am working with is only listed this way <form id="publish-new-package-form" enctype="multipart/form-data" action="publishNewPackage" method="post"> The method I need to get the form obj with is called _IEFormGetObjByName and all I have is the ID. Is there a work around for this I tried passing it the ID and doesn't seem to be working with the ID over the name? Thanks Link to comment Share on other sites More sharing options...
CubicleJockey Posted October 6, 2008 Author Share Posted October 6, 2008 I think I found the problem the form that I am working with is only listed this way <form id="publish-new-package-form" enctype="multipart/form-data" action="publishNewPackage" method="post">The method I need to get the form obj with is called _IEFormGetObjByName and all I have is the ID.Is there a work around for this I tried passing it the ID and doesn't seem to be working with the ID over the name?ThanksNevermind I got it to work so to answer the question I just posted about the being able to get the Form by ID the answer is yes!ThanksDale 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