Jump to content

Interacting with drop down lists and a button


Recommended Posts

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">&nbsp;</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

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 by skyinthesea
solved the previous problem
Link to comment
Share on other sites

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

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...