How to get font color in a loop for 10 link names

55 views
Skip to first unread message

surabhi

unread,
Oct 31, 2013, 3:13:05 PM10/31/13
to mercu...@googlegroups.com
Can anyone give me the sample code?

I have 10 links names. I want to check the link font color for each link and if link color = red, then click on that.

Thanks,
surabhi

Parke

unread,
Oct 31, 2013, 3:29:57 PM10/31/13
to mercu...@googlegroups.com
Surabhi:
 
Put your links into an array.  Loop through the array until you find the color, and then click on the link.
 
hth,
 
Parke

Vish

unread,
Nov 2, 2013, 12:13:02 AM11/2/13
to mercu...@googlegroups.com
Hi Surabhi,
Can I have your web page So I can give you exact code?

then, you just need to run from yourend.

Best Regards,
Vishal Shah

Shantanu Joshi

unread,
Nov 2, 2013, 9:52:39 AM11/2/13
to mercu...@googlegroups.com
Hi Surabhi,

U can follow both approaches. Either using OR/DP

Let me show you both methods:
Method 1: Using OR

I here assume that all the links are present on the same page.

msgbox  = Browser("").Page("").link("").getroproperty("color")

repeat the same for all 10 links .This will return you a value in hexadecimal value.


Compare the value and get the color of link.

for example 0000ff is the value for blue link.

Method 2:Using Descriptive Programming

Function ClickLink(LinkName)

Set oLink = Description.Create()
oLink("micclass").Value = "Link"
oLink("name").Value = LinkName

Set collection = browser("").page("").Childobjects(oLink)

For i = 0 to collection.count -1
       ColorValue = collection(i).GetROProperty("color")
       if StrComp(ColorValue,"ff0000") = 0 then
          collection(i).Click
          exit For
       End If
next

End Function           


I hope this helps.

Enjoy Automation
Shantanu



On Friday, 1 November 2013 00:43:05 UTC+5:30, surabhi wrote:

surabhi

unread,
Nov 4, 2013, 4:15:18 PM11/4/13
to mercu...@googlegroups.com
Thanks Shantanu - the code worked!
Reply all
Reply to author
Forward
0 new messages