Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hi,

Q: Are you using Selenium IDE FireFox plug-in to record?

A: Yes. I have it record what I want to do, then I use the export function to put the Selenium commands into perl, then copy and paste into a text editor and remove the "_ok"s and place "sel->start();" in the code.

RE: Test::WWW::Selenium - Thanks I changed that, but my code doesn't seem to run how I want it to.

RE: Real website and login - The real website and my login is real in the code below.

RE: Else, elsif, \@ - Thanks, I changed that too but my code doesn't seem to run how I want it to.

Desired outcome:

  1. Go to www.cokezone.co.uk
  2. Login (and handle any pops if they happen
  3. Check the number of points in the account and put into a scalar variable $points
  4. Open a file handle <CODES> and read the codes into an array @codes
  5. Enter the codes into the website and check against the $points scalar variable to see if they were entered correctly - printing if the code was successful or not
  6. Carry on for each of codes in the array @codes
  7. Logout when done

Progress: I've only gotten as far as no. 2 in the Selenium IDE, and I can only get to no. 1 using the Selenium RC and Perl.

I'm pretty confident I can write a file handle and read it into an array and for each of the codes get Selenium to input them into the CokeZone website, however it's no use if I can't even automate a login that handles the popups!

Code I've written to try to login and handle the popups:

#! /usr/bin/perl use strict; use warnings; use WWW::Selenium; my $sel = WWW::Selenium->new( host => "localhost", port => 4444, browser => "*chrome", browser_url => "http://www.cokezon +e.co.uk" ); $sel->start(); $sel->open("/home/index.jsp"); $sel->click("link=Log in"); $sel->wait_for_page_to_load("30000"); if ( $sel->is_text_present("Thanks for visiting!\n\nNow here's your ch +ance to tell us what you think. This quick and easy survey will only +take you a few minutes to fill out, and it'll help us to get more of +the stuff you want to see into 'Coke Zone'.\n\nThanks for your help,\ +nThe 'Coke Zone' Team") == 1 ) { $sel->select_window("entry"); $sel->close(); $sel->select_window("null"); } if ( $sel->is_text_present("At the end of your visit on this website p +lease take the time to complete an on-line survey, which will provide + us with feedback on the website. Please do not close this window.\n\ +nEnjoy your visit") == 1 ) { $sel->select_window("stealth"); $sel->close(); $sel->select_window("null"); } $sel->click("emailAddress"); $sel->type("emailAddress", "bogus\@fake.com"); $sel->type("password", "password"); $sel->click("remember"); $sel->click("subButton"); $sel->wait_for_page_to_load("30000"); my $points = $sel->get_text("//div[\@id='header_links']/div[1]/div[1]/ +h3"); print $points $sel->click("link=Log out"); exit 0;

In reply to Re^7: 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (4)
    As of 2015-07-05 03:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (60 votes), past polls