Hello Monks,

I am trying to do some automation where my perl script will open a webpage and click on some link, push a button and then click on another link and push a button.

Layout: All services are placed on the left side of the page. Each service has its own set of buttons. The services links is visible on every page. When the service is clicked, the right portion of the page changes to reflect stuff of the service clicked

Here is my perl script:

#!/usr/bin/perl use strict; use warnings; use Selenium::Remote::Driver; my $url = 'http://my_internal_url.com'; my $driver = Selenium::Remote::Driver->new( 'browser_name' => 'phantomjs', 'port' => '8089' ); $driver->get( $url ); $driver->find_element("//a[contains(.,'serviceone')]")->click(1); $driver->find_element("//input[\@value='Stop Service']")->click(1); $driver->find_element("//a[contains(.,'servicetwo')]")->click(1); $driver->find_element("//input[\@value='Get Status']")->click(1);

I can see from the logs that the script does work. It worked fine when I was testing it by having the driver click on just one service. Since that was not going to be the only purpose of this script (it will do several other things for a particular service, then select another service, do stuff for it and then another service...etc) I started testing with two services.

This led to the issue I am having. During some runs both buttons gets pushed for serviceone and during some runs both buttons gets pushed for servicetwo. Sometimes just one button gets pushed for any one service.

I can't seem to figure out why is it happening. I have added sleep, set_implicit_wait_timeout, pause but the issue prevails.

The webpage doesn't have url but javascript onclick events.

Looking forward to your wisdom.

Regards
Jaypal


In reply to Selenium with PhantomJS not able to click links correctly by jaypal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.