# FireWatir in class, link doesn't work

**URL:** <https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923>\
**Category:** Ruby\
**Created:** [January 23, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923 "2008-01-23T14:00:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 23, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/1 "2008-01-23T14:00:19Z")

</div>

Hi All,  
In the code below I’m making a first try to make a class with  
FireWatir/firefox.  
Now, the problem is, the clicklink doesn’t work, I do get the puts’s but  
with the self.link there is no action(and the link does exist)… The  
startup() does work.

Can anyone help me?

class CLBrowserFF\<FireWatir::Firefox

def startup()  
puts “startup”  
self.goto(‘[http://website.com](http://website.com)’)  
puts “end startup”  
end

def clicklink(gui,window,link)  
#gui, window, link come later…  
puts “clicklink”  
self.link(:url, /\_groupid\_ITEM/)  
puts “end clicklink”  
end

end

browser = CLBrowserFF.new  
browser.startup()  
#gui, window, link come later…  
browser.clicklink(‘gui’,‘window’,‘link’)

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 24, 2008, 6:00am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/2 "2008-01-24T06:00:39Z")

</div>

Hi,

Can you provide with the error message that you are using? Also you  
are passing URL as a string, but while using in the code you are using  
it as regexp. Not sure but that could be a problem. Can you please  
post some values/exact code that you are using?

Regards,  
Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 24, 2008, 8:09am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/3 "2008-01-24T08:09:04Z")

</div>

Hi, thanks for replying.

There is no error message, the self.link(…) code is ignored totally.  
I also tried to enter the complete url and not the regexp. but there is  
no difference.  
The string passed to the def isn’t used (at this moment).  
The posted code is the code I use (except for the [http://website.com](http://website.com)).  
(and there is a " require ‘firewatir’" on top of the code)

cheers.

Angrez wrote:

> Hi,
> 
> Can you provide with the error message that you are using? Also you  
> are passing URL as a string, but while using in the code you are using  
> it as regexp. Not sure but that could be a problem. Can you please  
> post some values/exact code that you are using?
> 
> Regards,  
> Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 24, 2008, 10:16am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/4 "2008-01-24T10:16:08Z")

</div>

Hi,

Your code for function is like this:

> def clicklink(gui,window,link)  
> #gui, window, link come later…  
> puts “clicklink”  
> self.link(:url, /\_groupid\_ITEM/)  
> puts “end clicklink”  
> end

But you are not using variable link anywhere? what is use of /  
\_groupid\_ITEM/? I think I am missing something obvious over here.

- Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 24, 2008, 10:23am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/5 "2008-01-24T10:23:52Z")

</div>

The links on the website are very big. I use the regexp. /\_groupid\_ITEM/  
to get to the link without having to type the whole link in the code  
(groupid\_ITEM only appears in one link). And, in the link there are some  
items (countrycodes for example) that change with the settings of the  
website.

When debugging the code, I did use the whole link, something like this:  
self.link(:url,  
‘http://veryverybiglink\_nl\_nl\_website\_groupid\_ITEM.html’)  
But this also didn’t work…

\_groupid\_ITEM will eventually change into a variable, but first it has  
to work at all 🙂

thanks for thinking along…

Angrez wrote:

> Hi,
> 
> Your code for function is like this:
> 
> > def clicklink(gui,window,link)  
> > #gui, window, link come later…  
> > puts “clicklink”  
> > self.link(:url, /\_groupid\_ITEM/)  
> > puts “end clicklink”  
> > end
> 
> But you are not using variable link anywhere? what is use of /  
> \_groupid\_ITEM/? I think I am missing something obvious over here.
> 
> - Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 29, 2008, 6:36am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/6 "2008-01-29T06:36:03Z")

</div>

Hi,

Can you try getting the latest code from SVN and see it that works?  
Because as far as I know link does work using URL and regular  
expression. See unit tests for more detail.

- Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 29, 2008, 9:19am UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/7 "2008-01-29T09:19:59Z")

</div>

Thanks for all the help Angrez, much app.  
I will check it if this will help.

Cheers,  
FF

Angrez wrote:

> Hi,
> 
> Can you try getting the latest code from SVN and see it that works?  
> Because as far as I know link does work using URL and regular  
> expression. See unit tests for more detail.
> 
> - Angrez

---

<div class="post-metadata">

**Author:** ![flamingflamingo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f14d63/32.png) [@flamingflamingo](https://www.ruby-forum.com/u/flamingflamingo)\
**Post date:** [January 29, 2008, 3:33pm UTC](https://www.ruby-forum.com/t/firewatir-in-class-link-doesnt-work/126923/8 "2008-01-29T15:33:47Z")

</div>

I tried it…no change.

When I do $ff = FireWatir::Firefox.new() and use @ff in all the classes  
(I know, not very nice programming…this is for debug reasons) it  
works…  
I think it is an inherit problem.

class CLBrowserFF\<FireWatir::Firefox isn’t correct (but get no message  
of it).

The strange thing is:

with inherit:  
self.link(:url, /\_groupid\_ITEM/)

without inherit:  
$ff.link(:url, /\_groupid\_ITEM/).click

notice the .click on the end  
The regexpp isn’t the problem…

With inherit it says that it doesn’t know .click. and without it has to  
have a .click. This is weird…

cheers,  
FF

Angrez wrote:

> Hi,
> 
> Can you try getting the latest code from SVN and see it that works?  
> Because as far as I know link does work using URL and regular  
> expression. See unit tests for more detail.
> 
> - Angrez
