Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Using WWW::Selenium To Test Or Automate An Ajax Website

by icleave (Initiate)
on Nov 24, 2009 at 16:44 UTC ( #809121=note: print w/replies, xml ) Need Help??

in reply to Using WWW::Selenium To Test Or Automate An Ajax Website

I think I may have the same port 4444 problem with some code I tried to write to learn how to use Selenium. Basically I tried to write a perl program on Ubuntu to automate the entry of cokezone codes on the website. From my terminal I got the following results:

icleave@icleave:~/Desktop/CokeZone$ perl Error requesting http://localhost:4444/selenium-server/driver/?cmd=get +NewBrowserSession&1=*chrome& 500 Can't connect to localhost:4444 (connect: Connection refused) # Looks like your test exited with 111 before it could output anything +.
What advice do you have for sorting this out on Ubuntu? Many thanks, Icleave

Replies are listed 'Best First'.
Re^2: Using WWW::Selenium To Test Or Automate An Ajax Website
by Limbic~Region (Chancellor) on Nov 24, 2009 at 17:21 UTC
    Are you running the Selenium core? You need to have Selenium running before you can use the Selenium Remote-Control (driven by WWW::Selenium. It should be along the lines of (from memory and likely off a bit):
    java --jar selenium-core.jar

    You can verify that you have something listening on port 4444 by doing a netstat -an | grep LISTEN | grep 4444. If you don't see anything then you haven't properly started Selenium.

    Cheers - L~R

      Ty Limbic~Region for the post. I wasn't aware I needed to run the Selenium core. I did try running $netstat -an | grep LISTEN | grep 4444 and it didn't do anything so I figured I really didn't have the Selenium core.

      I tried running the $java --jar selenium-core.jar suggestion from my terminal but I got the following error:

      Unrecognized option: --jar Could not create the Java virtual machine.
      I guessed you meant "-jar" rather than "--jar" so I retyped the command at the terminal but I got the following:

      The program 'java' can be found in the following packages: * gij-4.3 * java-gcj-compat-headless * openjdk-6-jre-headless * cacao * gij-4.2 * jamvm * kaffe Try: sudo apt-get install <selected package> bash: java: command not found

      So I tired "sudo apt-get selenium-core" hoping this would work but it didn't. So the next thing I did was try searching the Synaptic Package Manager with no luck. I then googled and found I downloaded it and extracted but I couldn't make heads or tails of what to do next after reading the 'install-readme.txt.'

      Any advice on how I actually install Selenium core on Ubuntu? All my other searches for information on this didn't result in anything I could use.

      Also assuming that I get Selenium core running, is there any code I need to know about to "start" the Selenium core? I can't remember where I read it, but I read that you need the following code in your perl program:


      If so, where do I put it? I put it in my program here:

      my $sel = Test::WWW::Selenium->new( host => "localhost", port => 4444, browser => "*chrome", browser_url => "http://www.example" ); $sel->start(); $sel->open("/home/index.jsp");

      Did I get this code position correct?

      Many thanks for the help!

        Any advice on how I actually install Selenium core on Ubuntu?

        There really isn't anything to install. You just download the jar files and run them. Looking at the error message you got, I would guess you don't have Java installed. You need to install Java to run Selenium. WWW::Selenium is a perl interface to Selenium Remote Control only.

        Did I get this code position correct?

        Yes. You should always check the SYNOPSIS in TFM which shows you the typical usage.

        Cheers - L~R

      Nowadays, it is (apparently) recommended to use Selenium RC server instead — Selenium Core is no longer maintained. You can download it from

      To run it, do

      java -jar selenium-server.jar

      Make sure to use a recent enough version of Java, it fails here with java 1.4.2 but it works with 1.6.0.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://809121]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2017-01-19 01:00 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (166 votes). Check out past polls.