Change ATTR TXT to data CSV

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.

Change ATTR TXT to data CSV

by vistavision on Sun Nov 17, 2013 12:58 pm

Hi all,

I want to change some text in a loop script, like below:

Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:texthere


To something like this:
Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:{{!COL1}}


So I can change the ATTR=TXT from a .csv file in every loop. I know import from csv is possible with the CONTENT-tag, but is this also possible? I need to click on a LI tag to select a category so I want to change this every time.

Thanks so much for helping me out!

Kind regards,
Mark
vistavision
 
Posts: 7
Joined: Sat Nov 16, 2013 2:40 pm

Re: Change ATTR TXT to data CSV

by ReWagner on Sat Dec 07, 2013 3:43 pm

I want to do the same thing.

I see nobody has replied giving you a suggestion. Did you figure this out?

If so, are you willing to share how you managed to do it?

Or did you give up?
ReWagner
 
Posts: 4
Joined: Sat Dec 07, 2013 11:52 am

Re: Change ATTR TXT to data CSV

by chivracq on Sun Dec 08, 2013 8:12 pm

I think the answer was already in the question.

Have a look at the 'Loop-CSV-2-Web.iim' Demo-Macro...
- (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: 6484
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Change ATTR TXT to data CSV

by ReWagner on Sun Dec 08, 2013 8:35 pm

I do not see how the 'Loop-CSV-2-Web' demo code answers this question.

Every instance there where there is a sub-parameter of ATTR=TXT in that demo code, the text value is supplied directly in the code, not from a variable, like such: ATTR=TXT:Submit

The only expressions were a text value is supplied from a variable are using the sub-parameter ATTR=NAME where the syntax is considerably different. In that case there is a label and blank space and then the reference to CONTENT, like such: ATTR=Name:address CONTENT={{!COL3}}

Nothing of that sort is shown in the demo code for the ATTR=TXT sub-parameter.

Please clarify the meaning of your reply that the answer is found in the question.
ReWagner
 
Posts: 4
Joined: Sat Dec 07, 2013 11:52 am

Re: Change ATTR TXT to data CSV

by peppe1 on Tue Jun 21, 2016 6:47 am

Good day.

Do you have a solution for this matter?

Like the previous users said, I wish to loop with the values from a csv in the content of an text attribute.

IMacros version 10022823
peppe1
 
Posts: 11
Joined: Fri Mar 04, 2016 12:32 pm

Re: Change ATTR TXT to data CSV

by chivracq on Tue Jun 21, 2016 7:44 am

peppe1 wrote:Good day.

Do you have a solution for this matter?

Like the previous users said, I wish to loop with the values from a csv in the content of an text attribute.

Code: Select all
IMacros version 10022823

Hum..., I don't understand the Pb/Difficulty, this is a basic Use of looping through a DataSource and using '{{!COL1}}' and like I said previously, the OP provided the Solution:
vistavision wrote:I want to change some text in a loop script, like below:
Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:texthere

To something like this:
Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:{{!COL1}}

That's the Solution...!

@peppe1, provide more Info about your specific Case with Script and URL to be able to be more specific...

@ReWagner, sorry I never noticed nor replied anymore to your last Post, I guess you must have figured the Answer by now (2.5 years later, oops...!), you should have bumped the Thread and/or share the Solution once you got a working Script...

EDIT [2017-08-03]: Typo corrected: "looping though..." => "looping through..."
Last edited by chivracq on Thu Aug 03, 2017 5:51 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: 6484
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Change ATTR TXT to data CSV

by peppe1 on Tue Jun 21, 2016 10:38 pm

thank you for the fast reply, chivracq

What I have tried looks like this:

Code: Select all
IMacros version 10022823


Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=www.mouser.de

SET !ERRORIGNORE YES
SET !DATASOURCE datasource.csv
SET !DATASOURCE_COLUMNS 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}

TAG POS=1 TYPE=A FORM=ACTION:/mvc/header/search ATTR=TXT:{{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/mvc/header/search ATTR=NAME:keyword

TAG POS=1 TYPE=DIV ATTR=ID:divPN EXTRACT=TXT
TAG POS=1 TYPE=H1 ATTR=* EXTRACT=TXT



although, it is not functioning. It does not enter the value from the csv ( namely record from COL1 ) in the form.

What could it be?

btw, the form where I wish to enter the values from the csv has an auto-fill option, like it tries to guess what you are supposed to enter based on the characters you entered.

Thank you very much.
peppe1
 
Posts: 11
Joined: Fri Mar 04, 2016 12:32 pm

Re: Change ATTR TXT to data CSV

by chivracq on Wed Jun 22, 2016 5:52 am

peppe1 wrote:thank you for the fast reply, chivracq

What I have tried looks like this:

Code: Select all
IMacros version 10022823


Code: Select all
VERSION BUILD=10022823
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=www.mouser.de

SET !ERRORIGNORE YES
SET !DATASOURCE datasource.csv
SET !DATASOURCE_COLUMNS 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}

TAG POS=1 TYPE=A FORM=ACTION:/mvc/header/search ATTR=TXT:{{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:/mvc/header/search ATTR=NAME:keyword

TAG POS=1 TYPE=DIV ATTR=ID:divPN EXTRACT=TXT
TAG POS=1 TYPE=H1 ATTR=* EXTRACT=TXT


although, it is not functioning. It does not enter the value from the csv ( namely record from COL1 ) in the form.

What could it be?

btw, the form where I wish to enter the values from the csv has an auto-fill option, like it tries to guess what you are supposed to enter based on the characters you entered.

Thank you very much.

OK, can you provide as well a few valid Values from your '.CSV' to use for '{{!COL1}}'...? And for "keyword" as well, I guess...?

But hum, from what you describe about the Auto-Fill Functionality on this Site, the Standard 'TAG' Mode indeed often has difficulties with it. The Solution is then on FF to use the EVENT Mode, which is not available for iMB10, only from iMB11, but on iMB10, you could then try using the DS Mode which is very close to the EVENT Mode...
- (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: 6484
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Change ATTR TXT to data CSV

by peppe1 on Wed Jun 22, 2016 6:34 am

try these values for the search

Code: Select all
31387-4018
31387-2034
31386-2002


peppe1
 
Posts: 11
Joined: Fri Mar 04, 2016 12:32 pm

Re: Change ATTR TXT to data CSV

by Louise17 on Thu Aug 03, 2017 1:36 am

Hi

im having the same issue. how can we set a variable to TAG POS=1 TYPE=LI ATTR=TXT:texthere?

where texthere = a value on a given cell.


Thanks'
Louise17
 
Posts: 6
Joined: Thu Aug 03, 2017 1:25 am

Re: Change ATTR TXT to data CSV

by chivracq on Thu Aug 03, 2017 6:05 am

Louise17 wrote:Hi

im having the same issue. how can we set a variable to
Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:texthere
?

where texthere = a value on a given cell.

Thanks'

Louise17 on 03 Aug 2017, 10:48 wrote:Hi,

Are not able to assign variable to this?
Code: Select all
TAG POS=1 TYPE=LI ATTR=TXT:texthere


where texthere could be a {{variable}} from an excel sheet.

THanks

No need to post Duplicates, I deleted your 2nd Post (but kept it in a Quote)...

But hum, "CIM" for me to have a look, read my Sig...

And you should give more Details I think..., especially for a "longer" and older Thread like this one, with several Posters, I don't remember the Content as this Thread is from 4 years ago and have to read it all over from the beginning...
- (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: 6484
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Change ATTR TXT to data CSV

by Louise17 on Thu Aug 03, 2017 6:21 pm

windows 10 pro
iMacros Browser (x86) Version 11.5.499.3066

I have a website i need to populate a field on. The field is a dropdown list. I tried to record the macro on the website and it gave me the following tags when i click on the button and choose an option

TAG POS=1 TYPE=BUTTON FORM=NAME:frmAppForm ATTR=ID:q9718-button
TAG POS=2 TYPE=LI ATTR=TXT:Singapore

i want to assign a variable in place of the hardcoded country singapore.
The variable will come from an excel cell.

THanks
Louise17
 
Posts: 6
Joined: Thu Aug 03, 2017 1:25 am

Re: Change ATTR TXT to data CSV

by chivracq on Thu Aug 03, 2017 7:17 pm

Louise17 wrote:
Code: Select all
windows 10 pro
iMacros Browser (x86) Version 11.5.499.3066


I have a website i need to populate a field on. The field is a dropdown list. I tried to record the macro on the website and it gave me the following tags when i click on the button and choose an option

Code: Select all
TAG POS=1 TYPE=BUTTON FORM=NAME:frmAppForm ATTR=ID:q9718-button
TAG POS=2 TYPE=LI ATTR=TXT:Singapore


i want to assign a variable in place of the hardcoded country singapore.
The variable will come from an excel cell.

THanks

OK, that's much better, ah-ah...!

Well, if you want to assign a Var to your DDLB-Item, this is the generic Syntax:
Code: Select all
SET DDLB_Option "Singapore"
TAG POS=1 TYPE=BUTTON FORM=NAME:frmAppForm ATTR=ID:q9718-button
TAG POS=2 TYPE=LI ATTR=TXT:{{DDLB_Option}}

(You could use '!VAR1' if you prefer instead of the 'DDLB_Option' Name I gave to your Var, but good Practice is to give Descriptive Names to your Vars, instead of calling them all '!VARn'...)

Now if your Var needs to come from some '.CSV' ("Excel" doesn't mean much, only that you associated the '.CSV' Extension for such Files to be opened with Excel, you can open them with Notepad as well...), then you need to use the ['!DATASOURCE' + 'DATASOURCE_LINE' + '!COLn'] Mechanism, for example:
Code: Select all
SET !DATASOURCE Your_Input_File.csv
SET !DATASOURCE_LINE {{!LOOP}}
TAG POS=1 TYPE=BUTTON FORM=NAME:frmAppForm ATTR=ID:q9718-button
TAG POS=2 TYPE=LI ATTR=TXT:{{!COL1}}

"Your_Input_File.csv" is the Name of your "Excel" DataSource, located in the Default iMacros 'Datasources' Folder, you need to specify the full Path if it's located somewhere else...
And '!COL1' will grab your "Singapore" Value in Col_1 at Row_n depending on '!LOOP' as I guess you'll be looping your Macro/DataSource...

A bit surprised btw by the 'POS=2' for your Entry in the DDLB..., it is not Standard to have 2 Entries in a DDLB with the same Name, I guess they will have different "Values", but Users only see the "Names" in the DDLB, so how can they choose between the 1st and the 2nd "Singapore", 2 Entries with the same Name...!? Unless this is part of a psychological Test, I don't get the Purpose...!? :?
- (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: 6484
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Change ATTR TXT to data CSV

by Louise17 on Mon Aug 07, 2017 12:32 am

i am just recording the macros using imacros and would be converting it to VBscripting. I have my VB code on the excel file itself where the variable for country (Singapore) is located.

btw, i have recorded a new set of imacros while changing the selecting on the drop down field of the website. it looks like this

TAG POS=2 TYPE=LI ATTR=TXT:American<SP>Samoa
TAG POS=1 TYPE=UL ATTR=ID:q9427-list
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:q9427-edit CONTENT=Åland<SP>Islands
TAG POS=2 TYPE=LI ATTR=TXT:Select
TAG POS=1 TYPE=LI ATTR=TXT:Afghanistan

I have coded my vbs like this:

macro = macro + "TAG POS=1 TYPE=UL ATTR=ID:q9427-list CONTENT={{cob}}" + vbNewLine
macro = macro + "TAG POS=2 TYPE=LI ATTR=TXT:{{cob}}" + vbNewLine

the value {{cob}} is taken from the condition below (still on the excel file).

iret = iim1.iimSet("COUNTRY_OF_BIRTH", Cells(row, 8).Value)
Sheetname = "Map_Country"
FromValue = Cells(row, 8).Value
cob = Mapping(Sheetname, FromValue)
iret = iim1.iimSet("C_O_B", cob)
MsgBox cob


while mapping is:

Public Function Mapping(Sheetname, FromValue) As String
Dim ToValue As String

'MsgBox "Sheet name is " + Sheetname
'MsgBox "FromValue is " + FromValue
Sheets(Sheetname).Select
Columns("A:A").Select
Selection.Find(What:=FromValue, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Range("B2").Select
ToValue = ActiveCell.Offset(, 1).Value
'MsgBox ActiveCell.Offset(, 1).Value
Mapping = ToValue

End Function
Louise17
 
Posts: 6
Joined: Thu Aug 03, 2017 1:25 am

Re: Change ATTR TXT to data CSV

by Louise17 on Mon Aug 07, 2017 12:33 am

my bad the {{cob}} is actually a {{C_O_B}}
Louise17
 
Posts: 6
Joined: Thu Aug 03, 2017 1:25 am

Next

Return to General Support & Discussions

Who is online

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

-->