Underscore issue in html element value

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

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.

Underscore issue in html element value

by rsacchi on Wed Jan 08, 2014 6:25 am

Hello,
I've a issue with HTML elements which start with underscore char "_".

For example:

TAG POS=1 TYPE=SELECT FORM=NAME:MY_FORM ATTR=ID:_1120-24438130 CONTENT=%2

My macro cannot find the id = _1120-24438130 returning an error.
Any solutions?

Thanks

Rob
rsacchi
 
Posts: 5
Joined: Wed Jan 08, 2014 5:57 am

Re: Underscore issue in html element value

by chivracq on Wed Jan 08, 2014 9:15 am

Easy Workaround I think is simply to replace that Underscore with a Wildcard:
TAG POS=1 TYPE=SELECT FORM=NAME:MY_FORM ATTR=ID:*1120-24438130 CONTENT=%2

Or just to put a Wildcard in front of the Underscore:
TAG POS=1 TYPE=SELECT FORM=NAME:MY_FORM ATTR=ID:*_1120-24438130 CONTENT=%2

Or to use a Variable":
SET My_Form_ID "_1120-24438130" // (Not sure about the need of Double Quotes or not...)
TAG POS=1 TYPE=SELECT FORM=NAME:MY_FORM ATTR=ID:{{My_Form_ID}} CONTENT=%2

You should have mentioned the exact Error Msg... (to see how the Underscore is transformed or if it is ignored...)
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by rsacchi on Wed Jan 08, 2014 10:02 am

Thanks for your reply.
It still doesn't work.
The first two attempts give this error:

RuntimeError: element SELECT specified by ID:*1120-24438130 was not found, line: 51 (Error code: -921)

Using var:

RuntimeError: element SELECT specified by ID:{{My_Form_ID}} was not found, line: 51 (Error code: -921)
rsacchi
 
Posts: 5
Joined: Wed Jan 08, 2014 5:57 am

Re: Underscore issue in html element value

by chivracq on Wed Jan 08, 2014 12:42 pm

Ah OK, I would have thought it would have worked... But maybe you cannot use Wildcards for Element ID's...

Next thing I can think of, is that because it's the Element ID that is causing you trouble, you can try to change a few Options in your Recording Options:
- In Automatic Mode, unselect the "Favor element ID's in Selector".
- Then try Conventional Mode with Full HTML. (And then it can work straight away, or you identify other Attributes, NAME for example, and then you can remove ID...)
- If you are on Firefox, you could try EVENT Mode as well...

If the Site is publicly accessible, give the URL, then I can try a few things directly...
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by chivracq on Wed Jan 08, 2014 12:46 pm

Oh!, and one other obvious! thing...:
If you record the same Macro several times (after a Refresh of the Page, or a completely new Session), you are sure that that DDLB each time has the same ID...? Some Sites like to have the ID generated each time randomly-dynamically...
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by chivracq on Wed Jan 08, 2014 1:20 pm

chivracq wrote:You should have mentioned the exact Error Msg... (to see how the Underscore is transformed or if it is ignored...)

Again, I would still like to see the exact Error Msg...
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by rsacchi on Thu Jan 09, 2014 3:43 am

chivracq wrote:Oh!, and one other obvious! thing...:
If you record the same Macro several times (after a Refresh of the Page, or a completely new Session), you are sure that that DDLB each time has the same ID...? Some Sites like to have the ID generated each time randomly-dynamically...


You are right, the id/name of the element is random everytime I load that page!
Now I've to find a workaround to get it work.

I think I could use javascript to get the n element of the form (or the n SELECT of the form), but I don't know how to do in iMacros.

Rob
rsacchi
 
Posts: 5
Joined: Wed Jan 08, 2014 5:57 am

Re: Underscore issue in html element value

by rsacchi on Thu Jan 09, 2014 4:33 am

chivracq wrote:
chivracq wrote:You should have mentioned the exact Error Msg... (to see how the Underscore is transformed or if it is ignored...)

Again, I would still like to see the exact Error Msg...


I'm a newbie, how to do that?
rsacchi
 
Posts: 5
Joined: Wed Jan 08, 2014 5:57 am

Re: Underscore issue in html element value

by chivracq on Thu Jan 09, 2014 1:27 pm

rsacchi wrote:
chivracq wrote:
chivracq wrote:You should have mentioned the exact Error Msg... (to see how the Underscore is transformed or if it is ignored...)

Again, I would still like to see the exact Error Msg...


I'm a newbie, how to do that?


Don't worry, we don't need it anymore, now that we know that the ID is changing... As you mentioned that the pb was related to the starting Underscore in the ID, I was curious to see how it was treated in the Error Msg...

Usually those ID's are not completely random, a part of the ID remains the same, then you need to identlify the part that remains constant and remove the part that changes and replace it with {an Underscore} EDIT: replace it with a WILDCARD!!, and eventually play with TAG POS=2/3/4/5/6 etc, if it then doesn't identify uniquely anymore the Element you want to tag...

(It would be 20 times quicker if I had access to that Page, but you never answered if the Page was publicly available and what the URL is...)

And with Conventional Mode and Full HTML, you couldn't identify some other Attribute that doesn't change...?
Idem in EVENT MODE, but you didn't answer either about your Configuration...

EDIT: There was mistake about "replace it with an Underscore", should read "replace it with a Wildcard"...
Last edited by chivracq on Tue Jan 14, 2014 8:11 am, edited 1 time in total.
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by rsacchi on Tue Jan 14, 2014 7:09 am

You were right, the ID is dynamic, but it always starts with "_1120-", so I use a simple:

TAG POS=1 TYPE=SELECT FORM=NAME:RGI_FORM_DATIBENEDINAMICO ATTR=NAME:_1120-* CONTENT=%1

and now it works.
The site I'm macroing is not public, it's a web application owned by my company, so I cannot share the code.

I've few other questions about iMacros:

1) my macro opens one tab and during the process it opens and closes a second one. If another tab is open previuosly, my macro will not work because it doesn't recognize the right tab. So I've to close all tabs except the first. Is there a way to call a tab by his window name/title?

2) Can I start my macro from a specified line instead of the first?

3) I would like to PROMPT about 5-6 inputs at the beginning of the macro. Is that possibile in just one command?

Thanks for your time and your help

Rob
rsacchi
 
Posts: 5
Joined: Wed Jan 08, 2014 5:57 am

Re: Underscore issue in html element value

by chivracq on Tue Jan 14, 2014 9:03 am

rsacchi wrote:You were right, the ID is dynamic, but it always starts with "_1120-", so I use a simple:

TAG POS=1 TYPE=SELECT FORM=NAME:RGI_FORM_DATIBENEDINAMICO ATTR=NAME:_1120-* CONTENT=%1

and now it works.

I'm always right, you should know by now...! :shock: (Just kidding of course..., you noticed the slip of the fingers I did about Underscore and Wildcard, my head was obsessed by your "Underscore" Story...)

rsacchi wrote:The site I'm macroing is not public, it's a web application owned by my company, so I cannot share the code.

Ah OK, that's why I was asking...

rsacchi wrote:I've few other questions about iMacros:

1) my macro opens one tab and during the process it opens and closes a second one. If another tab is open previuosly, my macro will not work because it doesn't recognize the right tab. So I've to close all tabs except the first. Is there a way to call a tab by his window name/title?

Pfff, yes there is a way, or even 2, well not to call a Tab (at least I think) but to check its Window Name, but it's quite complicated, I remember once reading an old Thread on the Forum, where some Javascript DOM/GUI Command was used to check that..., hum..., and I thought that something like "TAG POS=1 TYPE=TITLE EXTRACT=TXT" would spit out the Window Title... but it only spits out a Runtime Error about "Wrong Format for TAG...", well then something using "SEARCH SOURCE:TXT="<title>SEARCH - iMacros</title>" for example for the iMacros SEARCH Wiki-Page should work, I think... (not tested...), to use in combination after that with EVAL to spit out a "0" (correct Tab) or a "1" (need to try next Tab) to use in !VAR1 and !VAR2 to loop through the Tabs using "TAB T=!VAR1"... But that remains a bit cumbersome...!

rsacchi wrote:2) Can I start my macro from a specified line instead of the first?

No (or only in the Professional Edition, I understood from Tom...), but there is an Enhancement Request about that (by myself, I think, or I contributed to it...) somewhere on the Forum...

rsacchi wrote:3) I would like to PROMPT about 5-6 inputs at the beginning of the macro. Is that possibile in just one command?

Yes, no problem, that's for me the main use of PROMPT, check the Wiki-Page or this Thread where I will soon give some "interesting" examples of PROMPT...:
viewtopic.php?f=2&t=22278

rsacchi wrote:Thanks for your time and your help

Rob

You're welcome...
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by chivracq on Tue Jan 14, 2014 3:56 pm

OK, about the PROMPT examples, I've posted in the other Thread like I promised:
viewtopic.php?f=2&t=22278&p=56287#p56287

If you want, here are just 2 examples without context:
Code: Select all
PROMPT myNewIP:<SP>{{myNewIP}}<br>myIP:<SP{{myIP}}<br>myRealIP:<SP>{{myRealIP}}
PROMPT VAR1:<SP>{{!VAR1}}<br>VAR2:<SP>{{!VAR2}}
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Underscore issue in html element value

by chivracq on Tue Jun 30, 2015 8:13 am

hum..., and I thought that something like "TAG POS=1 TYPE=TITLE EXTRACT=TXT" would spit out the Window Title... but it only spits out a Runtime Error about "Wrong Format for TAG..."

Hum, reading this old Thread again as some stupid Spammer bumped it with the previous Post (until it hopefully gets deleted by TechSupport...), but I think I had made a mistake in my Statement, the 'ATTR' Parameter is missing, like I found out a few weeks ago when I made the same mistake for some other Thread, so this should work, I think:
Code: Select all
TAG POS=1 TYPE=TITLE ATTR=* EXTRACT=TXT
(Not tested...)
- (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: 7203
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

-->