skyinthesea Posted May 31, 2018 Share Posted May 31, 2018 Hello! I have been on and off toying around with autoit for a few years. Usually I can solve my problems through google searches / copy&pasting existing codes and editing them until I understand how and why they work. However, I have tried for several hours now and I'm unable to interact with a drop down list and an 'X' to remove the choice. Any advice would be welcome! <div style="display:none" id="select-template"> <div class="row offer"> <div class="large-1 column"> </div> <div class="large-3 column"> <select name="food_type" data-customforms="disabled" class=" chosen-tpl"> <option value="" ></option> <option value="Mars Bar" >Mars Bar</option> <option value="Snickers" >Snickers</option> <option value="Skittles" >Skittles</option> I have tried: ;~ $oObj = _IEGetObjById($oIE, "search"); ;~ _IEAction($oObj, "search"); ;~ Local $oIE = _IE_Example("basic") ;~ Local $oLinks = _IELinkGetCollection($oIE) ;~ Local $iNumLinks = @extended ;~ Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF ;~ For $oLink In $oLinks ;~ $sTxt &= $oLink.href & @CRLF ;~ Next ;~ MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt) Local $oForms = _IEFormGetCollection($oIE, 0) ;~ MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & @extended & " form(s) on this page") ;~ For $oForm In $oForms ;~ MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) ;~ Next Local $oForm = $oForms Local $oQuery = _IEFormElementGetCollection($oForm) ;For $oaQuery In $oQuery ; MsgBox($MB_SYSTEMMODAL, "Form Info", $oaQuery.name) ;Next Local $ChooseDropDown = _IEFormElementGetCollection($oForm, 2) _IEFormElementSetValue($ChooseDropDown, "Snickers") That's just some of the things I've tried as well as using _IEAction with focus and clicking. Ideally, I'd like to select the dropdown list by number because more than one dropdown list is on the page, all of which have no name and no distinguishing features. As well as this, I can't interact with a small cross to cancel the selection from the dropdown list. Here is the code from the page: </select> </div> <div class="large-1 column"> <a class="button secondary expand" href="#" onclick="choice_remove(this);return false;"><i class="foundicon-remove"></i></a> </div> </div> </div> I have tried a variety of ways of interacting with it, all to no avail. Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
Danp2 Posted May 31, 2018 Share Posted May 31, 2018 19 minutes ago, skyinthesea said: _IEFormElementSetValue($ChooseDropDown, "Snickers") Normally, you would want to use _IEFormElementOptionSelect here. If you still can get it working, repost your code along with the results from running it in Scite. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
skyinthesea Posted May 31, 2018 Author Share Posted May 31, 2018 (edited) Edit: Following your advice I got it to work, thanks! (It doesn't appear immediately but when you submit the form the correct entries are actually there.. odd but it will do) My next question is how do I interact with the X. </select> </div> <div class="large-1 column"> <a class="button secondary expand" href="#" onclick="choice_remove(this);return false;"><i class="foundicon-remove"></i></a> </div> </div> </div> All I need to do is 'click' the button. Any tips appreciated Edited May 31, 2018 by skyinthesea solved the previous problem Link to comment Share on other sites More sharing options...
Danp2 Posted May 31, 2018 Share Posted May 31, 2018 There are lots of examples on the forum for locating / clicking an item by it's class name. Have you tried any of those? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
skyinthesea Posted May 31, 2018 Author Share Posted May 31, 2018 Hey, I've tried doing all types of things but it doesn't have a 'name' to the class. I don't understand how to use Xpath that I've seen others recommend from google, is it not possible to do it without? Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "button") For $oBtn In $oBtns If String($oBtn.classname) = "foundicon-remove" Then ;If String($oBtn.classname) = "button secondary expand" Then $oFound = $oBtn EndIf Next If IsObj($oFound) Then _IEAction ($oFound, "click") MsgBox(16, "Success", "Button was found") Else MsgBox(16, "Failed", "Not found.") EndIf ;Also tried the following: _IELinkClickByText($oIE, "foundicon-remove") _IELinkClickByText($oIE, "button secondary expand") ;Also tried the following: Local $oInputs = _IETagNameGetCollection($oIE, "div") For $oInput In $oInputs ;If $oInput.classname == "foundicon-remove" Then _IEAction($oInput, "click") If $oInput.classname == "button secondary expand" Then _IEAction($oInput, "click") Next Above are some of the attempts I've made at interacting with the button, all with no luck. Link to comment Share on other sites More sharing options...
Danp2 Posted May 31, 2018 Share Posted May 31, 2018 @skyinthesea You will need to modify that code to retrieve links ("a") instead of buttons ("button"). Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
skyinthesea Posted June 1, 2018 Author Share Posted June 1, 2018 I finally got it to work! Thanks! is <a> and <i> the name of the frame they are located in then? I'm really not an expert on HTML Link to comment Share on other sites More sharing options...
Danp2 Posted June 1, 2018 Share Posted June 1, 2018 Glad you were able to get it working. To answer your question -- No, neither of those have anything to do with frames. Google is your friend when it comes to learning about this stuff. Latest Webdriver UDF Release Webdriver Wiki FAQs 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