IE_ClickTag with ID and INDEX parameters? If NO, HOW?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

IE_ClickTag with ID and INDEX parameters? If NO, HOW?

Post by mightycpa » Mon Nov 17, 2008 5:58 am

Hi,

I'm trying to click a spot on a webpage, and I can't get webrecorder to record it exactly the way I need it...

Unfortunately, I can't show you the exact website, but I did make a simple facsimile of the problem I'm facing:

Here is a url: http://www.managemyjobs.com/mjtnet/mjt.htm

On it, there is a bit of clickable text; I cannot record a click, but I can manually click it without a problem.

Here is the html of my page:

Code: Select all

<DOCTYPE>
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META>
  <META>
  <META>
  <META>
  <script>
function click_it(a,b){
alert("Hello MJTNET!  You clicked " + b);
}
</script>
 </HEAD>

 <BODY>
  <SPAN>Click_Me_1</SPAN>    
  <SPAN>Click_Me_3</SPAN> 

 </BODY>
</HTML>


Now, you can't really see it above, but those SPANs really looks like this:

SPAN id=sportTab style="CURSOR: pointer" onclick="click_it(this,'4')"

You're welcome to download the page and try it locally.

I can get the FIRST link to click by using the following:

Code: Select all

Let>FrameName={""}
Let>FormName={""}
Let>idValue={"sportTab"}

IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,SPAN,ID,str:idValue,r


But I want to click the SECOND link... and I keep failing when I try to add the INDEX parameter...

Code: Select all

...
Let>idxValue={1}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,SPAN,ID,str:idValue,INDEX,idxValue,r
This question has been asked in the forums at least twice, but has never been answered as far as I can see.

Reading carefully, the documentation says:

attrib takes one of the following values:

Can INDEX work with the ID attribute? If not, exactly do I get this to work?



Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Nov 17, 2008 9:23 am

This works for me:

Code: Select all

IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.managemyjobs.com/mjtnet/mjt.htm,r
IE_Wait>%IE[0]%,r

IE_ClickTag>%IE[0]%,,,SPAN,TEXT,Click_Me_1,r

Wait>2

IE_ClickTag>%IE[0]%,,,SPAN,TEXT,Click_Me_3,r
Since the text is different for each one I just use the Text to identify them.

If you want to use Index, this also works:

Code: Select all

IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.managemyjobs.com/mjtnet/mjt.htm,r
IE_Wait>%IE[0]%,r

IE_ClickTag>%IE[0]%,,,SPAN,INDEX,str:{"0"},r

Wait>2

IE_ClickTag>%IE[0]%,,,SPAN,INDEX,str:{"1"},r
INDEX just takes the numerical zero-based index of each element, so span 0 is the first span element in the page and span 1 is the second.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts