Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thanks for the tips! I finally figured it all out except for the class path stuff (I have no idea how to create a java classpath to the .jar file) but I eventually experimented until I figured out that I can run one terminal running selenium rc and open another terminal and run my perl code from that.

Low and behold my perl code comes to life and firefox loads up... only to die time and time again with a popup box that loads when you click 'login' on the website I'm trying to automate access to. After spending a whole day learning about how you need to select the popup box and close it, then select 'null' to get back to the original browser window I just can't seem to get my perl/selenium code to do what I want. The main issue is that upon clicking the 'logon' link at the website I'm trying to automate access, it is random event where by:

  1. No popup box pops up, or
  2. A popup box named 'stealth' pops up, or
  3. A popup box named 'entry' pops up.

I found that selenium is very fragile when it comes to coding the next step for it to preform... if I run my code without any mention to a popbox then everything is fine, but when I run the code and a popup box happens then it dies with a "255" exit message. Looking around the options in the IDE I couldn't see any program flow commands for selenium IDE so after going to the selenium website it seemed to me that program flow must come from the coding language you are using.

So I thought, ok, Perl has program flow commands, why not use the "if" statement and "elseif" and "else" for all three possibilities:

  1. no popup
  2. popup "stealth"
  3. popup "entry".

I coded it up as best as I could in Perl but then I got syntax errors where my blocks where. I was under the impression that something like $sel->title_is("Entry") would give perl a 'true' or 'false' and operate the program flow accordingly. Please help, I'm quite confused, a sample of the code is below:

my $sel = Test::WWW::Selenium->new( host => "localhost", port => 4444, browser => "*chrome", browser_url => "http://www.example +.com/" ); $sel->start(); $sel->set_timeout("60000"); $sel->open("/home/index.jsp"); $sel->click("link=Log in"); $sel->wait_for_page_to_load("60000"); if ($sel->title_is("Entry")) { $sel->select_window("entry"); $sel->close(); $sel->select_window("null"); } else ($sel->title_is("Stealth")) { $sel->select_window("stealth"); $sel->close(); $sel->select_window("null"); } $sel->click("emailAddress"); $sel->type("emailAddress", "anon@anywhere.com"); $sel->click("password"); $sel->type("password", "password"); $sel->click("remember"); $sel->click("subButton"); $sel->wait_for_page_to_load("60000");

In reply to Re^5: Using WWW::Selenium To Test Or Automate An Ajax Website by icleave
in thread Using WWW::Selenium To Test Or Automate An Ajax Website by Limbic~Region

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-16 19:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found