Extracting "value" from SELECT object in v8.9.7

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Extracting "value" from SELECT object in v8.9.7

by msposito on Mon Oct 16, 2017 9:18 am

In order to use the upload function I started to use
iMacro v8.9.7
FF 55.0.3 (or even FF56 that also works!)
so: windows7

For having developed the whole project so far in version 9.3, I'm having to make some adaptations.

I was faced with a very important difference from the EXTRACT of the SELECT object.

Code: Select all
TAG POS=1 TYPE=SELECT FORM=NAME:test ATTR=NAME:objSelect EXTRACT=TXT


This command, in v9.3, extracts the "value", as I expected.
However in v8.9.7 the "description" is extracted.

I think the extraction of value became possible only in v9.3.
Even then, do you have any suggestions on how to get "value" from SELECT instead of "description" in v8.9.7?

Thanks
ps: I did not find anything in this respect in the forum. Is it possible that only I have this problem? ...Or I do not know to look for in the forum? :roll:
Last edited by msposito on Sat Oct 21, 2017 6:54 am, edited 1 time in total.
msposito
 
Posts: 7
Joined: Sat Mar 18, 2017 11:08 pm

Re: Extracting "value" from SELCT object in v8.9.7

by chivracq on Mon Oct 16, 2017 10:05 am

msposito wrote:In order to use the upload function I started to use
Code: Select all
iMacro v8.9.7
FF 55.0.3 (or even FF56 that also works!)
so: windows7


For having developed the whole project so far in version 9.3, I'm having to make some adaptations.

I was faced with a very important difference from the EXTRACT of the SELECT object.

Code: Select all
TAG POS=1 TYPE=SELECT FORM=NAME:test ATTR=NAME:objSelect EXTRACT=TXT


This command, in v9.3, extracts the "value", as I expected.
However in v8.9.7 the "description" is extracted.

I think the extraction of value became possible only in v9.3.
Even then, do you have any suggestions on how to get "value" from SELECT instead of "description" in v8.9.7?

Thanks
ps: I did not find anything in this respect in the forum. Is it possible that only I have this problem? ...Or I do not know to look for in the forum? :roll:

Hum..., you have a Typo in your Thread Title ("SELCT" instead of "SELECT"), nobody is going to search the Forum using this Term... And Runtime Engines are usually very "stupid", one Typo and your Script won't compile... :idea:

But, OK, eh-eh...!, good to hear about v8.9.7 still working on FF56, I still didn't try updating FF from v55.0.3 to v56...

And OK, I didn't know about this Change in Behaviour between v8.9.7 and v9.0.3 about 'Value'/'Description' for a DDLB for 'EXTRACT=TXT'... (Well, I never used v9.0.3...)

Ouf..., then it's going to be a little bit "High Level" to extract the corresponding 'Value' to the 'Description' you can extract already...

The "Principle" would be to first extract the currently selected Item in the DDLB to get its 'Description' like you already do, and store this 'Description' in some Var.
Then you'll need to fire an 'EXTRACT=HTM' on the same 'SELECT' Element or at some higher Level (containing 'DIV') to get the complete HTML Source of the DDLB which will contain all the possible Items with their Value + Description, and reusing the 'Description' you already extracted to locate and isolate the corresponding 'Value' using 'EVAL()' + 'REGEXP' or 'split()' that I find easier to use than 'REGEXP'.
I "demonstrated" a similar Technique in the following Thread, even if I used it in that Thread to dynamically find and select the last Option in a DDLB, but the Principle is the same... That's my Technique as well to deal with Dynamic ID's...:
- Re: Number of Options in a Select tag

And hum..., maybe if you explain why you want the 'Value' of the current Selection in the DDLB and what you (want to) do with it afterwards, maybe I can find some easier Way... :idea:

If you go for "my" Method (there are probably other Ways as well...), post the URL of your Site if you don't come out by yourself..., or the exact and full Content of both the 'EXTRACT=TXT' and 'EXTRACT=HTM' + what you want exactly, and I can help you further...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Extracting "value" from SELECT object in v8.9.7

by msposito on Mon Oct 16, 2017 9:51 pm

Hi Chivracq,

Thank you for trying to help me.

[I hope the google translator does not change the understanding of this my long post...]

I did an implementation exactly as you suggested, obtaining the description and then extracting the value of the EXTRACT=HTM corresponding to the description.

It works in most cases.
On the website that I work, you can see descriptions with special characters that are extracted by HTM with content different from that extracted by TXT.

Example:
EXTRACT=TXT : "Xpto & others"
EXTRACT=HTM: "Xpto & others"


Besides this example I have other more common cases of accented characters in Portuguese, which are also extracted (HTM) as "HTML Characters" ("&___) or UNICODE (ãÃáÁàÀçÇ, among others). The "old charset problem" that does not exist in the English language... (sometimes I wonder why I was not born in an English-speaking country... :( Well, Portuguese is even better than the Chinese characters... :lol: )

I would like to find a solution that does not have to depend on the treatment of these exceptionalities. I'm worried about how to generalize so that there are no surprises as new specific content comes to appear ...

I'll try to give you an idea of my use.

The purpose of my project is to transfer data between the system I develop (SOURCE) and a governmental system (TARGET) that insists not to implements information exchange, for example, by xml.
Then my iMacro project receives data exported in CSV format by the SOURCE system and "types" it in the various interfaces of the system TARGET.

In the initial stage of execution, it extracts the lists (DDLB) of general use of the TARGET, relating them to the equivalent lists of the system SOURCE. The relation of identifiers (values) is kept in memory and saved in a file, to be used in the various interfaces that must be filled from the TARGET.

Because they are several interfaces and many data, the user can execute all the "data transfer" in one go, in executions by modules or resuming the execution of where it stopped due to the interruption of the user himself or by some unexpected occurrence (drop of internet connection, some attribution error etc.). In these cases the saved file is initially read for reuse of the previously determined relationship.

The idea of using the "values", not "descriptions", was precisely to "avoid these difficulties" that special characters, accented etc. can cause...

I could work on this relationship with the "description" by simply replacing the current content assignments by value (CONTENT=%<value>) by description (CONTENT=$"<description>") when they are assigned on the target interfaces. But the problem of special characters makes assignments risky and uncertain...

To tell you the truth, when I implemented in v9.3 I found it strange that the option EXTRACT=TXT would return the "value" and nor "text description". Expect a option like EXTRACT=VALUE or EXTRACT=VAL. How was what i wanted, I did not attach much importance. Now it occurs to me that it may even be a bug in v9.3 and not an evolution as I believed...

I have another solution to get the descriptions as they would be extracted from the selected element:
. get all values from the EXTRACT=HTM
. implement a loop simulating the assignment of each of the values
. extracting its description, generating the list of values and descriptions.

In this way the descriptions would be "clean" and could be attributed as content and eventually searched.

Of course there would be an impact on performance. I have some lists that can have more than 200 items.

But if this is the "price" for a reliable procedure, so it will have to be...

I appreciate any comments or ideas that help me find the best solution.

ps1: I apologize for not having a test environment I can publish. Features in iMacro are still in development and when deployed, they will be used by a third-party system password (TARGET) that only my users have. (I'm working on static copies of forms in html, until I can test in production with the permission of some of my users...very bad practice...)

ps2: I have corrected the title of the post. Unforgivable distraction. I have no forums experiences, it did not occur to me that it would make it difficult to search for other users. I'm going to have more attention with the title! :oops:
msposito
 
Posts: 7
Joined: Sat Mar 18, 2017 11:08 pm

Re: Extracting "value" from SELECT object in v8.9.7

by chivracq on Wed Oct 18, 2017 3:33 pm

msposito wrote:Hi Chivracq,

Thank you for trying to help me.

[I hope the google translator does not change the understanding of this my long post...]

I did an implementation exactly as you suggested, obtaining the description and then extracting the value of the EXTRACT=HTM corresponding to the description.

It works in most cases.
On the website that I work, you can see descriptions with special characters that are extracted by HTM with content different from that extracted by TXT.

Example:
Code: Select all
EXTRACT=TXT : "Xpto & others"
EXTRACT=HTM: "Xpto &amp; others"


Besides this example I have other more common cases of accented characters in Portuguese, which are also extracted (HTM) as "HTML Characters" ("&___) or UNICODE (ãÃáÁàÀçÇ, among others). The "old charset problem" that does not exist in the English language... (sometimes I wonder why I was not born in an English-speaking country... :( Well, Portuguese is even better than the Chinese characters... :lol: )

I would like to find a solution that does not have to depend on the treatment of these exceptionalities. I'm worried about how to generalize so that there are no surprises as new specific content comes to appear ...

I'll try to give you an idea of my use.

The purpose of my project is to transfer data between the system I develop (SOURCE) and a governmental system (TARGET) that insists not to implements information exchange, for example, by xml.
Then my iMacro project receives data exported in CSV format by the SOURCE system and "types" it in the various interfaces of the system TARGET.

In the initial stage of execution, it extracts the lists (DDLB) of general use of the TARGET, relating them to the equivalent lists of the system SOURCE. The relation of identifiers (values) is kept in memory and saved in a file, to be used in the various interfaces that must be filled from the TARGET.

Because they are several interfaces and many data, the user can execute all the "data transfer" in one go, in executions by modules or resuming the execution of where it stopped due to the interruption of the user himself or by some unexpected occurrence (drop of internet connection, some attribution error etc.). In these cases the saved file is initially read for reuse of the previously determined relationship.

The idea of using the "values", not "descriptions", was precisely to "avoid these difficulties" that special characters, accented etc. can cause...

I could work on this relationship with the "description" by simply replacing the current content assignments by value (CONTENT=%<value>) by description (CONTENT=$"<description>") when they are assigned on the target interfaces. But the problem of special characters makes assignments risky and uncertain...

To tell you the truth, when I implemented in v9.3 I found it strange that the option EXTRACT=TXT would return the "value" and nor "text description". Expect a option like EXTRACT=VALUE or EXTRACT=VAL. How was what i wanted, I did not attach much importance. Now it occurs to me that it may even be a bug in v9.3 and not an evolution as I believed...

I have another solution to get the descriptions as they would be extracted from the selected element:
. get all values from the EXTRACT=HTM
. implement a loop simulating the assignment of each of the values
. extracting its description, generating the list of values and descriptions.

In this way the descriptions would be "clean" and could be attributed as content and eventually searched.

Of course there would be an impact on performance. I have some lists that can have more than 200 items.

But if this is the "price" for a reliable procedure, so it will have to be...

I appreciate any comments or ideas that help me find the best solution.

ps1: I apologize for not having a test environment I can publish. Features in iMacro are still in development and when deployed, they will be used by a third-party system password (TARGET) that only my users have. (I'm working on static copies of forms in html, until I can test in production with the permission of some of my users...very bad practice...)

ps2: I have corrected the title of the post. Unforgivable distraction. I have no forums experiences, it did not occur to me that it would make it difficult to search for other users. I'm going to have more attention with the title! :oops:

Hum..., about the "Thread Title", like you say, you've corrected the/a "Post Title" but the "Thread Title" is the Title of the 1st Post in a Thread and that's this one which is visible from the Sub-Forum View..., as that one still contains "SELCT"... (You can still edit all your previous Posts...)

But OK, long Post, with a lot of Info, good-good...!, and nice to see that you are quite clever and analytic, that's a bit more motivating as well to try to help you than the 2 Users in this Thread or this Thread for example... (Hum, be ready for a big Laugh, those 2 whole Threads are a complete "Joke", like all previous Threads by the same Users btw... :roll: )

>>>

OK, I'm a bit surprised by the "&amp;" and "accented Characters" stuff to be honest... :o
Several of my Scripts are for some complete Automation on some French Site(s) (some kind of Tamagochi Games) where I do a lot of Conditional Coding based on quite a lot of 'EXTRACT=HTM' (+ '=TXT' as well of course), and many Words and Keywords I need/use are/contain French Words with Accents but all Accents are already neatly in the Source (= 'EXTRACT=HTM'), so I would expect the same on some Site with some Content in Portuguese or German... Hum, had a Case once, maybe 1 or 2 years ago about German Chars indeed... Got solved...

=> ... Which makes me think that the Char Encoding Set could play a Role, either on the Server Side or on the Browser (= Client) Side.
I use 2 a bit different Browsers (Pale Moon v26.3.3 + FF v55.0.3 at the moment for their respective Versions, but I never noticed any Change for maybe their last 20 or 30 previous different Versions either) + 2 different Versions of iMacros for FF (v8.8.2 on PM and v8.9.7 on FF) where the same Scripts run regularly (= several times daily) and correctly and "my" 'Char Encoding' Setting is "Unicode -UTF-8" on PM and "Western" on FF, so you may want to pay attention to what your Setting currently is for your FF v55.0.3. :idea:

OK, took me more than 1 hour but I finally managed to find some Public Site in Portuguese containing a DDLB with Portuguese Words with Accents:
https://geneall.net/pt/home/?b=P
And I ran a few Tests on this Site, with "<meta charset="UTF-8" />" for the Page on the Server Side, and all my "Tests" are "successful", with each time Accents neatly present and extracted from the 'EXTRACT' with '=HTM' / '=TXT' / '='TXTALL'.
Maybe you can check the Content of the 3 Extracts on this Page", hum, + the one on the 'DIV' as well...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
TAB T=1

URL GOTO=https://geneall.net/pt/home/?b=P

TAG POS=1 TYPE=SELECT FORM=ID:nav-search ATTR=NAME:t CONTENT=%c
WAIT SECONDS=1

TAG POS=1 TYPE=SELECT FORM=ID:nav-search ATTR=NAME:t EXTRACT=TXT
TAG POS=1 TYPE=SELECT FORM=ID:nav-search ATTR=NAME:t EXTRACT=TXTALL
TAG POS=1 TYPE=SELECT FORM=ID:nav-search ATTR=NAME:t EXTRACT=HTM

TAG POS=3 TYPE=DIV ATTR=TXT:Outubro<SP>/<SP>17<SP>André<SP>Villas<SP>Boas<SP>nasceu<SP>e* EXTRACT=HTM

Result for me for the 3 'EXTRACT' on the DDLB are:
Code: Select all
EXTRACT=TXT
Cargos e Profissões

EXTRACT=TXTALL
Pessoas[OPTION]Famílias[OPTION]Títulos[OPTION]Cargos e Profissões[OPTION]Mapas

EXTRACT=HTM
<select style="outline: 1px solid blue;" name="t">       <option value="p">Pessoas</option>       <option value="f">Famílias</option>       <option value="t">Títulos</option>       <option value="c">Cargos e Profissões</option>       <option value="m">Mapas</option>      </select>
(Tested on iMacros for FF v8.8.2, PM v26.3.3, Win10_x64.)

If you can manage to reproduce and get the same Results like me, before and/or after changing your Char Encoding in your Browser, that could be some Solution for your own Site/Script as well, or you can try "investigating" the Char Encoding on your Site if you control the "SOURCE" in your "SOURCE"/"TARGET" Scenario...

Try to find some Public Portuguese or Brazilian Site with some DDLB where you can reproduce your Pb otherwise and where I could do a bit of Testing...

Check as well what Content you get on your Site with 'EXTRACT=TXTALL', and that could be as well the "beginning" of a "new" Workaround, where you could extract all Values from the DDLB from the 'EXTRACT=HTM' and the Index of your currently selected Item in the Array for 'EXTRACT=TXTALL' would be the same Index for its corresponding 'Value' in the Array for all Values...! => Easy way to find the 'Value'...!

Hum..., and about your "Concern" about Performance with 200 Items if you still had to go using your own Approach with looping through all DDLB Options, have a look at the following Thread where I demonstrated/explained a Method in pure '.iim' to search through 1000 "Records" in less than 0.5 Sec (while the "best" Implementation in some JS Loop would need 2 or 3 Min to achieve the same Result...):
- Re: Get number of lines from CSV and use as variable?
It's actually a "Variation" of the Method I used in the 'Number of Options in a Select tag' Thread I already referred to, or more or less based on the same Principle..., with a few other "Tricks" that I mentioned...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Extracting "value" from SELECT object in v8.9.7

by msposito on Sat Oct 21, 2017 7:12 am

Hi Chivracq,

Sorry for the delay in responding. Only now I'll post your post. I was waiting for a reply in the post titled "corrected" ... I was very stupid ... :(

I gave a good laugh at the beginning of your post ... :lol:

Your solution with EXTRACT=TXTALL worked perfectly!

Extraction is exactly the assignable content. Unlike the HTM it brings &amp; double spaces etc.

The issue of accentuation also presented no problems. It worked okay even with the original website charset I have to use!

I'm really (was!) Using loop in javaScript to manipulate these lists.
Your solution is great! Simple and efficient!
Thanks for sharing!

Seeing your code, I confess that until now I was using iMacro in what would be obligatory (we tend to bring all processing into the environment we know best ...).

I'll be more aware of my "misuse of iMacro".

I'm going to review my project and see the size of the impact to improve my implementations ...

Anything I can yell for help!

Just one or two things (for now... :D )

1) As I implemented the entire project in v9.3, I would like to not lose some scripts so I might someday use a later version.
How do I get the number of the version being executed in order to condition the call of the methods writes to v8.9.7 and in v9.3?
2) I have how to obtain, in time of executed, the ways of the configuration? (Folder Macros, Folder Datasources etc.)
3) macro timeout is always 6 seconds? SET !TIMEOUT_MACRO <time> does not really work or am I doing something wrong?

*Should I open a new post for these questions, or should I do it, but look for documentation? ... If this is the case, can you at least tell me where to look?

Thank you for your patience and commitment.

ps: I correct the title of all posts. I hope I did the right thing this time... :oops:
msposito
 
Posts: 7
Joined: Sat Mar 18, 2017 11:08 pm


Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests

-->