mkhan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys, After quite some research, I'm back with another question.

I am using PSGI/Plack to for developing a web app.

I want to achieve the following:
1. Send a simple record and play selenium script to a cloud instance (In other words, a simple server machine)
2. Once the script is sent, this script should be executed using selenium on the instance (assuming selenium is installed on the cloud instance)
3. The status of execution is sent back to the client after execution.

All this should be achieved automatically. My question is, once the script is uploaded to the cloud instance, how do I get it to run in Selenium using Perl? (Step 2).
I am confused. Could someone clarify this? I will be really grateful. Thanks Monks.
  • Comment on Executing selenium scripts automatically on cloud server using Perl

Replies are listed 'Best First'.
Re: Executing selenium scripts automatically on cloud server using Perl
by Corion (Patriarch) on Jun 27, 2011 at 09:22 UTC

    Have you looked at what CPAN has to offer for Selenium?

    Also, I believe that Selenium wants mostly to run in a browser, so you will likely need to fire up a web browser on the "cloud machine" which then interprets the Javascript and HTML.

    Also, a likely approach to get Selenium to run the script would be to take the same approach you use to launch Selenium on a machine not in "the cloud". "The Cloud" is not magic, it is just a marketing buzzword with little meaning.

      After a sleepless night I finally got bits of it working.

      Apparently, once I transfer the files to the server using CGI, what I have to do is just:
      1. Export the selenium test cases as Perl scripts.
      2. Install the necessary modules. (Could just bundle it up on server one time.)
      3. Execute these scripts in the background on the server (cloud instance) directly using Perl
      4. Test::More will tell me if tests have passed or failed
      5. I could simply retrieve the status and carry on with life =)

      Thanks!!! Any further contributions to this discussion are welcome
        I think you do not need the cgi step, you can connect directly to the selenium server.

        So on the server machine you start your selenium server: java -jar selenium-server.jar

        On the client, you run a perl script like this:

        use Test::WWW::Selenium my $sel = Test::WWW::Selenium->new( host => "your server's ip", port => 4444, browser => "*firefox", browser_url => "http://www.google.com", ); # your test script goes here

        Maybe you have to tweak the firewall settings on the server to make this work.

        Couple of more things ..

        1. WWW::Selenium offers most of the things I need.

        2. My back is hurting, I'm sleepless and in a terrible state but the awesomeness of Perl solutions bring tears of joy.
        Don't eat the yellow cloud, its not candy :)