Page 1 of 1

Relative to text

Posted: Mon Oct 20, 2008 7:17 am
by yoav
Hi,

I'm trying to check a checkbox in a page that looks like this:

<div>
<input class='site_list' type='checkbox' name='sitebox[]' value='436947' >test11.site1<br>
<input class='site_list' type='checkbox' name='sitebox[]' value='436950' checked='true'>test111.site1 (test2.test)<br>
<input class='site_list' type='checkbox' name='sitebox[]' value='437690' >test111111.site1<br>
</div>

I have no inforamtion about the id (placed in the value attribute) and I need to find it by the name, which is just text in the div
i.e, I need to check the box with value 436947 by using "test11.site1"

Is there any way to accomplish this ?

Thanks

Yoav.

Re: Relative to text

Posted: Mon Oct 20, 2008 11:36 am
by Tech Support
Hello, you have the same setup as shown in this screenshot.
=> Please see the paragraph about Backwards relative positions, this will solve this task!

Based on the HTML snippet above, I assume these two lines are correct:
TAG POS=1 TYPE=TD ATTR=TXT:test11.site1
TAG POS=R-1 TYPE=INPUT:CHECKBOX FORM=NAME:* ATTR=NAME:* CONTENT=YES

Re: Relative to text

Posted: Mon Oct 20, 2008 2:32 pm
by yoav
Hi,

Thanks for your reply.

the code you posted would work if the text was indeed within a <td> tag, however if you look again at the html sniplet, you'll see it's just free text within a div so that code doesn't work.

any other ideas ?

Re: Relative to text

Posted: Tue Oct 21, 2008 8:41 am
by Tech Support
Ah, I see the problem now, too: For iMacros all three texts are part of ONE div element, so you can not select them individually ( = you can not get a blue frame around the text only).
checkbox div.png
checkbox div.png (17.69 KIB) Viewed 9534 times

Solutions:
1. Do you know the order of the texts? Then you can select the boxes by their position (POS=1,2 etc)
URL GOTO=file:///D:/1tmp/a.htm
TAG POS=2 TYPE=INPUT:CHECKBOX FORM=NAME:NoFormName ATTR=NAME:sitebox[]&&VALUE:* CONTENT=YES

2. If you do not know the order, you need to add steps to find out the order:

a. Extract the complete text with TAG POS=1 TYPE=DIV ATTR=TXT:* EXTRACT=HTM

b. Parse this text to get the order that corresponds to a certain text. This can be done easily with VBS or any other scripting language. In VBS you can use for example the instr command, in VB.NET/C#/Perl you can also use Regex. If you are a Gold Support customer, our customer support can write this script for you, too.
(b1. Alternatively you can get the value that corresponds to a text with this method, too.)

c. Now you can use Solution #1