Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 19th, 2009, 08:49 PM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chap 2 forums, testing the pagination section

Chap 2, pagination section, pages 55-56.
I am testing the pagination on the forums.

You have to type in a lot of messages to test it.
One way to get around this would be to just set the $display
variable from 25 down to something low, like 4.

Another way to do this is to automatically enter the data.
That's the way I did it. I've posted my scripts here if anyone
wants to try testing it this way. You will have to change the
paths to your own.

I used the Selenium IDE open source web testing tool to automatically
populate the forum with messages. You can download Selenium tool
and use it for free.

I used the data driven capability of Selenium.
I generated an xml file and then the Selenium script loads
that xml file, and loops through the data to automatically write messages.

I have included the Selenium code, the xml data file,
and a small easy Perl program used to generate the xml data file.

I made the message subjects similar and used numbers.
my subject 1
my subject 2
...
my subject 30

This way it's easy to see that you got them in the right sequence.
In the script I also had it reply to each message.


Here is the Selenium code. You can copy it to an .html file and look at it in a browser.

HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://www.mydomain.com/myapp/mymain.php" />
<title>forum_pagination_test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">forum_pagination_test</td></tr>
</thead><tbody>
<!--//load the test data-->
<tr>
    <td>loadTestData</td>
    <td>file:///C:/Documents and Settings/myname/My Documents/selenium/testsken/forum_testdata.xml</td>
    <td></td>
</tr>
<!--// Start on main page which has link named forums-->
<tr>
    <td>open</td>
    <td>/myapp/mymain.php</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=forums</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=exact:Create new forum</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>name=forum_name</td>
    <td>myforum1</td>
</tr>
<tr>
    <td>type</td>
    <td>forum_desc</td>
    <td>My first forum</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>//input[@value='Create']</td>
    <td></td>
</tr>
<!--// done creating forum-->
<!--//Now click on first forum-->
<tr>
    <td>clickAndWait</td>
    <td>link=exact:myforum1: My first forum</td>
    <td></td>
</tr>
<!--each iteration through loop creates new message and reply-->
<!--the data for the message comes from 1 line in the data file-->
<tr>
    <td>while</td>
    <td>!testdata.EOF()</td>
    <td></td>
</tr>
<tr>
    <td>nextTestData</td>
    <td></td>
    <td></td>
</tr>
<!--//post a message-->
<tr>
    <td>clickAndWait</td>
    <td>link=Post new message.</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>msg_subject</td>
    <td>${msg_subject}</td>
</tr>
<tr>
    <td>type</td>
    <td>msg_text</td>
    <td>${msg_text}</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>//input[@value='Create']</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=10/19/2009: ${msg_subject}</td>
    <td></td>
</tr>
<!--//post a reply-->
<tr>
    <td>clickAndWait</td>
    <td>link=Reply</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>msg_subject</td>
    <td>${msg_reply_subject}</td>
</tr>
<tr>
    <td>type</td>
    <td>msg_text</td>
    <td>${msg_reply_text}</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>//input[@value='Create']</td>
    <td></td>
</tr>
<tr>
    <td>endWhile</td>
    <td></td>
    <td></td>
</tr>

</tbody></table>
</body>
</html>
Here is the xml data file that it loads.

HTML Code:
<testdata>
<test
msg_subject="my subject 1"
msg_text="This is my text for subject 1"
msg_reply_subject="Reply to subject 1"
msg_reply_text="This is the text of my reply for subject 1"
/>
<test
msg_subject="my subject 2"
msg_text="This is my text for subject 2"
msg_reply_subject="Reply to subject 2"
msg_reply_text="This is the text of my reply for subject 2"
/>
<test
msg_subject="my subject 3"
msg_text="This is my text for subject 3"
msg_reply_subject="Reply to subject 3"
msg_reply_text="This is the text of my reply for subject 3"
/>
<test
msg_subject="my subject 4"
msg_text="This is my text for subject 4"
msg_reply_subject="Reply to subject 4"
msg_reply_text="This is the text of my reply for subject 4"
/>
<test
msg_subject="my subject 5"
msg_text="This is my text for subject 5"
msg_reply_subject="Reply to subject 5"
msg_reply_text="This is the text of my reply for subject 5"
/>
<test
msg_subject="my subject 6"
msg_text="This is my text for subject 6"
msg_reply_subject="Reply to subject 6"
msg_reply_text="This is the text of my reply for subject 6"
/>
<test
msg_subject="my subject 7"
msg_text="This is my text for subject 7"
msg_reply_subject="Reply to subject 7"
msg_reply_text="This is the text of my reply for subject 7"
/>
<test
msg_subject="my subject 8"
msg_text="This is my text for subject 8"
msg_reply_subject="Reply to subject 8"
msg_reply_text="This is the text of my reply for subject 8"
/>
<test
msg_subject="my subject 9"
msg_text="This is my text for subject 9"
msg_reply_subject="Reply to subject 9"
msg_reply_text="This is the text of my reply for subject 9"
/>
<test
msg_subject="my subject 10"
msg_text="This is my text for subject 10"
msg_reply_subject="Reply to subject 10"
msg_reply_text="This is the text of my reply for subject 10"
/>
<test
msg_subject="my subject 11"
msg_text="This is my text for subject 11"
msg_reply_subject="Reply to subject 11"
msg_reply_text="This is the text of my reply for subject 11"
/>
<test
msg_subject="my subject 12"
msg_text="This is my text for subject 12"
msg_reply_subject="Reply to subject 12"
msg_reply_text="This is the text of my reply for subject 12"
/>
<test
msg_subject="my subject 13"
msg_text="This is my text for subject 13"
msg_reply_subject="Reply to subject 13"
msg_reply_text="This is the text of my reply for subject 13"
/>
<test
msg_subject="my subject 14"
msg_text="This is my text for subject 14"
msg_reply_subject="Reply to subject 14"
msg_reply_text="This is the text of my reply for subject 14"
/>
<test
msg_subject="my subject 15"
msg_text="This is my text for subject 15"
msg_reply_subject="Reply to subject 15"
msg_reply_text="This is the text of my reply for subject 15"
/>
<test
msg_subject="my subject 16"
msg_text="This is my text for subject 16"
msg_reply_subject="Reply to subject 16"
msg_reply_text="This is the text of my reply for subject 16"
/>
<test
msg_subject="my subject 17"
msg_text="This is my text for subject 17"
msg_reply_subject="Reply to subject 17"
msg_reply_text="This is the text of my reply for subject 17"
/>
<test
msg_subject="my subject 18"
msg_text="This is my text for subject 18"
msg_reply_subject="Reply to subject 18"
msg_reply_text="This is the text of my reply for subject 18"
/>
<test
msg_subject="my subject 19"
msg_text="This is my text for subject 19"
msg_reply_subject="Reply to subject 19"
msg_reply_text="This is the text of my reply for subject 19"
/>
<test
msg_subject="my subject 20"
msg_text="This is my text for subject 20"
msg_reply_subject="Reply to subject 20"
msg_reply_text="This is the text of my reply for subject 20"
/>
<test
msg_subject="my subject 21"
msg_text="This is my text for subject 21"
msg_reply_subject="Reply to subject 21"
msg_reply_text="This is the text of my reply for subject 21"
/>
<test
msg_subject="my subject 22"
msg_text="This is my text for subject 22"
msg_reply_subject="Reply to subject 22"
msg_reply_text="This is the text of my reply for subject 22"
/>
<test
msg_subject="my subject 23"
msg_text="This is my text for subject 23"
msg_reply_subject="Reply to subject 23"
msg_reply_text="This is the text of my reply for subject 23"
/>
<test
msg_subject="my subject 24"
msg_text="This is my text for subject 24"
msg_reply_subject="Reply to subject 24"
msg_reply_text="This is the text of my reply for subject 24"
/>
<test
msg_subject="my subject 25"
msg_text="This is my text for subject 25"
msg_reply_subject="Reply to subject 25"
msg_reply_text="This is the text of my reply for subject 25"
/>
<test
msg_subject="my subject 26"
msg_text="This is my text for subject 26"
msg_reply_subject="Reply to subject 26"
msg_reply_text="This is the text of my reply for subject 26"
/>
<test
msg_subject="my subject 27"
msg_text="This is my text for subject 27"
msg_reply_subject="Reply to subject 27"
msg_reply_text="This is the text of my reply for subject 27"
/>
<test
msg_subject="my subject 28"
msg_text="This is my text for subject 28"
msg_reply_subject="Reply to subject 28"
msg_reply_text="This is the text of my reply for subject 28"
/>
<test
msg_subject="my subject 29"
msg_text="This is my text for subject 29"
msg_reply_subject="Reply to subject 29"
msg_reply_text="This is the text of my reply for subject 29"
/>
<test
msg_subject="my subject 30"
msg_text="This is my text for subject 30"
msg_reply_subject="Reply to subject 30"
msg_reply_text="This is the text of my reply for subject 30"
/>
</testdata>
Here is the Perl code used to generate the xml file.

Code:
#!/usr/bin/perl -w
#
# This program writes an xml test data file for
# Selenium script. It will be used in testing
# the forum section of the website.
#

# edit this line to put in the number of message you want
$total_number_of_messages = 30;

open(OUTFILE, ">$ARGV[0]") || die "open output file failed\n";

$counter=0;

# start writing file
print OUTFILE "<testdata>\n";

while ($counter++ < $total_number_of_messages) {
   print OUTFILE "<test\n";
  
   print OUTFILE "msg_subject=\"my subject $counter\"\n";
   print OUTFILE "msg_text=\"This is my text for subject $counter\"\n";
   print OUTFILE "msg_reply_subject=\"Reply to subject $counter\"\n";
   print OUTFILE "msg_reply_text=\"This is the text of my reply for subject $counter\"\n";
  
   print OUTFILE "/>\n";
}

print OUTFILE "</testdata>\n";
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 2 - Avatars and uploading files, (would apply to Chap 6 too) kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 October 18th, 2009 03:14 PM
Testing a p2p.wrox.com forums whitespace fix jminatel Forum and Wrox.com Feedback 6 July 15th, 2009 09:33 AM
pagination Regornil Pro JSP 2 May 31st, 2005 06:10 AM
Please.....Pagination junemo PHP Databases 2 September 25th, 2004 01:14 PM
pagination junemo Oracle 0 July 1st, 2004 04:07 AM



All times are GMT -4. The time now is 02:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.