title: How to click on Javascript using Selenium under perl $sel->click
body: <p>I've been using Selenium IDE and Selenium Remote Driver to test a website.  When I export the file to perl and try running it I get error trying to open a link which is a Javascript.  Here's the code I've been trying:</p>
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use Time::HiRes qw(sleep);
  use Test::WWW::Selenium;
  use Test::More &quot;no_plan&quot;;
  use Test::Exception;
  use Env;
  
  my $sel = Test::WWW::Selenium-&gt;new( host =&gt; &quot;localhost&quot;, 
                                  port =&gt; 4444, 
                                  browser =&gt; &quot;*firefox&quot;, 
                                  browser_url =&gt; &quot;http://cpc.cs.qub.ac.uk/&quot; );
  
  
  $sel-&gt;open_ok(&quot;http://cpc.cs.qub.ac.uk/&quot; , undef, &quot;Getting Webpage CPC&quot;);
  $sel-&gt;set_speed(&quot;1000&quot;);            
  $sel-&gt;wait_for_page_to_load_ok(&quot;10000&quot;);    
  $sel-&gt;select_frame_ok(&quot;toolbar&quot;);
  
  $sel-&gt;click_ok(&quot; //a[contains(\@href,'javascript:goTo(overview.html');)] &quot;);
  #and tried this format as well
  $sel-&gt;click_ok(&quot;//a[\@href='javascript:goTo('overview.html');']&quot;);
  $sel-&gt;wait_for_page_to_load_ok(&quot;10000&quot;);    
  </code></pre>
  <p>It says can can't find the element, I've been trying the use the Xpath as a locator, but just can't seem to locate.  Below is the html of the link I'm trying to click:</p>
  <pre><code>&lt;title&gt;CPC Toolbar&lt;/title&gt;
          &lt;script language=&quot;javascript&quot; src=&quot;./toolbar.js&quot;&gt;&lt;/script&gt;
  
  &lt;tr&gt;
      &lt;td align=&quot;center&quot; &gt;
      &lt;a href=&quot;javascript:goTo('overview.html');&quot; onMouseover=&quot;libserv.src='icons/redlibserv.gif'&quot; onMouseout=&quot;libserv.src='icons/bluelibserv.gif'&quot;&gt;&lt;IMG SRC=&quot;icons/bluelibserv.gif&quot; name=&quot;libserv&quot; width=&quot;100&quot; height=&quot;20&quot; border=&quot;0&quot;&gt;
      &lt;/a&gt;
      &lt;/td&gt;   
  &lt;/tr&gt;
  </code></pre>
  <p>Any help with how implement this would be much appreciated.  As well in the WWW::Selenium module, it gives these xpath formats to use as locators:</p>
  <pre><code>xpath=//img[@alt='The image alt text']
  xpath=//table[@id='table1']//tr[4]/td[2]
  xpath=//a[contains(@href,'#id1')]
  xpath=//a[contains(@href,'#id1')]/@class
  xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
  xpath=//input[@name='name2' and @value='yes']
  xpath=//*[text()=&quot;right&quot;]
  </code></pre>