I Can't Select an Option from a Drop-down List

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
viking
Posts: 243
Joined: Sun Mar 16, 2008 7:22 am

I Can't Select an Option from a Drop-down List

Post by viking » Sat Jul 25, 2020 2:56 am

I am trying to select an option from a drop-down list. Here is what was recorded using the regular recording mode:

Code: Select all

TAG POS=1 TYPE=LI ATTR=TXT:Vert<SP>Div<SP>Chk<SP>WR1<SP>xxx*
(I replaced some of the text with xxx). Note that the CONTENT tag is missing....
When playing this, iMacros can't find the option - it times out:

Code: Select all

RuntimeError: element LI specified by TXT:Vert<SP>Div<SP>Chk<SP>WR1<SP>xxx* was not found, line 8 (Error code: -921)

Here is what was recorded using the experimental mode:

Code: Select all

EVENT TYPE=MOUSEDOWN SELECTOR="#mui-component-select-source" BUTTON=0
EVENT TYPE=MOUSEUP POINT="(352,223)"
EVENT TYPE=CLICK SELECTOR="#menu-source>DIV:nth-of-type(3)>UL>LI:nth-of-type(6)" BUTTON=0
In this case, iMacros still cannot find the option:

Code: Select all

RuntimeError: Element HTML is not visible, line 7 (Error code: -921)
where line 7 is

Code: Select all

EVENT TYPE=MOUSEUP POINT="(352,223)"

Note that I need to be able to select the option based on text as the position changes. I read somewhere that I should try to replace TYPE=LI with TYPE=SELECT, but that didn't work either.

UPDATE: The "solution" was embarrassingly simple; just deleting "EVENT TYPE=MOUSEUP POINT="(352,223)"" solved it:

Code: Select all

EVENT TYPE=MOUSEDOWN SELECTOR="#mui-component-select-source" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#menu-source>DIV:nth-of-type(3)>UL>LI:nth-of-type(6)" BUTTON=0
It does however, not solve the issue that I cannot select the option by text. I have to select it by position, e.g. nth-of-type(6), nth-of-type(7) etc. This will be problematic as the position may change. I guess there is no solution to this issue?

Firefox Developer Edition (Portable) v. 55.0b2 (64-bit)
iMacros v. 8.9.7
WIN7 (64 bit)


Update: I now also tried with the latest version of iMacro, but the result was the same (for the regular recording mode):
Firefox 78.0.2 (64-bit)
iMacros 10.0.2.1450
Win7 (64-bit)
Last edited by viking on Tue Jul 28, 2020 9:06 am, edited 1 time in total.
access2vivek
Posts: 63
Joined: Wed Dec 20, 2017 10:00 am
Location: New Delhi, India
Contact:

Re: I Can't Select an Option from a Drop-down List

Post by access2vivek » Tue Jul 28, 2020 8:02 am

Selecting from a Dropdown is very simple. All you have to do is use the "value" attribute of the <option> element under the <select> element. Note that you will need to prepend the "%" symbol before the value attribute.

For example, if the HTML is: -

Code: Select all

<select name="cars" id="cars">
  <option value="apple">Volvo</option>
  <option value="ball">Saab</option>
  <option value="cat">Mercedes</option>
  <option value="dog">Audi</option>
</select>
First, we need to target the select element and then set its content to the required value. For example:-

Code: Select all

TAG POS=1 TYPE=SELECT ATTR=id:cars CONTENT=%dog
will select the "Audi" option.
Robust iMacros development with quick turnaround time. Drop an email at "access2content@gmail.com" with your project details.
viking
Posts: 243
Joined: Sun Mar 16, 2008 7:22 am

Re: I Can't Select an Option from a Drop-down List

Post by viking » Tue Jul 28, 2020 8:36 am

access2vivek ,
Your answer is not relevant to problem. As you can see, I don't even have a content tag. Looking at the html source code doesn't show the options in the drop-down list.
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I Can't Select an Option from a Drop-down List

Post by chivracq » Tue Jul 28, 2020 1:23 pm

Hum..., I didn't want to answer/intervene in this Thread as it was opened in the "wrong" Sub-Forum and has nothing specific to the 'iMacros for FF' Sub-Forum..., too bad, ah-ah...!, but yep indeed @access2vivek, the "Explanation" you give only applies to "Standard" DDLB's encoded as a 'SELECT' HTML Element, and the different Items in the DDLB as 'OPTION' Elements.

But this doesn't apply to Dynamically (from JS) generated DDLB's where the DDLB is then encoded/presented usually as a 'DIV', containing then the DDLB Items as 'SPAN' Elements, or with some kind of 'TABLE' Element and the Items are then presented as 'LI' Elements, which seems to be the Case for this Thread/Site, and for which "usually" the 'TAG' Mode doesn't work in Replay Mode because the 'LI' Elements only become "visible" (to iMacros) when the DDLB gets "activated" and opened, and you usually have to use the 'EVENT' Mode for that kind of DDLB's like @viking was trying to do..., which I think is the "correct" Way to go...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
viking
Posts: 243
Joined: Sun Mar 16, 2008 7:22 am

Re: I Can't Select an Option from a Drop-down List

Post by viking » Tue Jul 28, 2020 5:47 pm

chivracq wrote:
Tue Jul 28, 2020 1:23 pm
Hum..., I didn't want to answer/intervene in this Thread as it was opened in the "wrong" Sub-Forum and has nothing specific to the 'iMacros for FF' Sub-Forum..., too bad, ah-ah...!,
Which would be the correct Sub-Forum for this question? Note that I am using iMacros for Firefox (and the EVENT mode).
Also, what would the correct sub-forum be for my recent javascript/RegEx question? Note that it is not possible to post in the javascript sub-forum.
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I Can't Select an Option from a Drop-down List

Post by chivracq » Tue Jul 28, 2020 7:42 pm

viking wrote:
Tue Jul 28, 2020 5:47 pm
chivracq wrote:
Tue Jul 28, 2020 1:23 pm
Hum..., I didn't want to answer/intervene in this Thread as it was opened in the "wrong" Sub-Forum and has nothing specific to the 'iMacros for FF' Sub-Forum..., too bad, ah-ah...!,
Which would be the correct Sub-Forum for this question? Note that I am using iMacros for Firefox (and the EVENT mode).
Also, what would the correct sub-forum be for my recent javascript/RegEx question? Note that it is not possible to post in the javascript sub-forum.

This current one "definitely" belongs to the 'General' Sub-Forum...
The 'EVENT' Mode was specific to iMacros for FF for several years, until that Mode also got implemented in iMB v11.5, a few years ago already..., then v10.0.1 for CR and v12.0 for IE, "now" that Mode is not even supported in v10.0.2 for FF anymore...

>>>

Your Thread about RegEx would also rather belong to the 'General' Sub-Forum was my first Thought, but is OK in the FF Sub-Forum, as I "hesitated" a bit myself, as the Script/Syntax you had posted in pure JS could be seen as being used in a '.js' Script, even if your "elsewhere" probably rather means the Browser(s) Console, and I suspected indeed you might be hitting the Lookback Limitation from FF (documented somewhere in the Wiki, for the 'SEARCH' Command maybe...), which is then a Limitation that only affects (iMacros for) FF...
(But I don't/never use RegEx myself, (I prefer 'split()'), so I'm not very knowledgeable about that, Reason i didn't post in that Thread, even if I wanted to mention the Lookback Limitation yesterday but I had very bad Internet, and you found out by yourself...)

>>>

Alright, and concerning this current one, try replacing the two 'MOUSEDOWN' + 'MOUSEUP' Statements by one 'CLICK' Statement (still using the 'EVENT' Mode, not the 'CLICK' Mode, even if hum..., the 'CLICK' Mode might also be able to open the DDLB, but it looks a bit "ugly" and "strange" because it often doesn't close it afterwards...), then try keeping only the 'MOUSEDOWN' Statement, then try using the Keyboard Navigation with 'Tab' and the Arrows... :idea:
For that kind of Pb's, I usually need to "play" with the Site myself and try a whole "Panoply" of "Tricks" and Techniques until I find stg that works, it's difficult to help "virtually" and do some Testing "mentally"... :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
viking
Posts: 243
Joined: Sun Mar 16, 2008 7:22 am

Re: I Can't Select an Option from a Drop-down List

Post by viking » Wed Jul 29, 2020 8:37 pm

chivracq wrote:
Tue Jul 28, 2020 7:42 pm
Alright, and concerning this current one, try replacing the two 'MOUSEDOWN' + 'MOUSEUP' Statements by one 'CLICK' Statement (still using the 'EVENT' Mode, not the 'CLICK' Mode, even if hum..., the 'CLICK' Mode might also be able to open the DDLB, but it looks a bit "ugly" and "strange" because it often doesn't close it afterwards...), then try keeping only the 'MOUSEDOWN' Statement, then try using the Keyboard Navigation with 'Tab' and the Arrows... :idea:
For that kind of Pb's, I usually need to "play" with the Site myself and try a whole "Panoply" of "Tricks" and Techniques until I find stg that works, it's difficult to help "virtually" and do some Testing "mentally"... :|
Thanks, but I don't follow your suggestions. In any case, the following code works as is

Code: Select all

EVENT TYPE=MOUSEDOWN SELECTOR="#mui-component-select-source" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#menu-source>DIV:nth-of-type(3)>UL>LI:nth-of-type(6)" BUTTON=0
I can select the option I need by changing "nth-of-type(6)"; e.g. to "nth-of-type(7)"
The main issue is that I can not select the option by name, and the position may change...

BTW, which type of posts should go to "iMacros on Firefox" rather than the "general" sub-forum?
Post Reply