Rational Functional Tester offers you a choice of scripting language and development environment -- Java in the Eclipse framework or Microsoft Visual Basic .NET in the Microsoft Visual Studio .NET Development Environment. That means that regardless of the language or platform your development staff has chosen, you should be able to integrate with them and leverage some of their expertise as you develop your automated tests.
In this article, we'll take a look at testing HTML applications in Mozilla Firefox version 2.0 with Rational Functional Tester v7.0 as it's implemented in the Java environment. Don’t worry. If you use .NET, it’s basically the same.
Note: The author used Version 7.0.0 of the IBM Rational Functional Tester automation tool, the Microsoft® Windows® XP Professional operating system (SP2), and Mozilla Firefox V2.0 while writing this article, although Rational software works with other operating systems and browsers, as well.
Testing HTML applications in Mozilla Firefox version 2.0
In this article you will work through an example. This serves the dual purpose of looking at testing in Mozilla Firefox 2.0, as well as demonstrating the basic features of Rational Functional Tester. For this example, you'll place an order at www.BookPool.com for a book about Java™.
- Start Rational Functional Tester, and open an existing project.
- Click Record a Functional Test Script, and
enter a namefor the script. (See Figure 1.)
Figure 1. Record a Functional Test Script screen display
- Click Finish to begin recording. The Recording window that you see in Figure 2 will open.
Figure 2. Recording window
- Click Start Application, which opens the Start Application window that Figure 3 shows.
Figure 3. Start Application window
- To add the BookPool.com URL to the list of application names, click the Edit Applications List... button.
- In the Application Configuration Tool window that Figure 4 shows, click the Add... button.
Figure 4. Application Configuration Tool window
- In the Add Application window (Figure 5), go to Select kind of application and select HTML Application. Then click Next.
Figure 5. Add Application window
- From Select HTML application (Figure 6), still within the Add Application window, enter
www.BookPool.comas the URL Then click Finish.
Figure 6. Add the URL in the Select HTML application view
- In the Edit Application Information window of the Application Configuration Tool (Figure 7), you should now see the BookPool URL listed under Applications.
- Be sure to select Mozilla Firefox in the Browser field.
Figure 7. Edit Application Information window
- Click Finish,
- Return to the Start Application window and select the URL in the Application Name field, and then click OK. The BookPool.com Web site will open in your browser.
- Type
Javainto the Search window on the site to search for a book about Java (Figure 8).
Figure 8. Search the Web site for a book about Java
- On the search results page, add the first book listed to your shopping cart by clicking Add to Basket (Figure 9).
Figure 9. Add the first book from the search results to your shopping basket
- You should see the book in your shopping cart, but to ensure that it is listed there, enter a verification point. First, click the Insert Verification Point or the Action Command button. This will open the Verification Point and Action Wizard that you see in Figure 10.
Figure 10. Verification Point and Action Wizard screen
- Using the Object Finder, select the data listed in the table for the book that you want to order. You should see a red border around the entire browser, as Figure 11 shows. (Accept defaults, otherwise.)
Figure 11. Use the Object Finder to select the book that you want to order
- In the Verification Point and Action Wizard, select Perform Properties Verification Point (Figure 12), and then click Next.
Figure 12. Verification Point and Action Wizard
- In the Insert Properties Verification Point Command window (Figure 13), make sure that Include Children is set to All, and then click Next.
Figure 13. Insert Properties Verification Point Command window
- The next screen (Figure 14) prompts you to select the properties to include in the verification point. Navigate through the Test Objects tree to the table that contains the HTML for the book that you selected, and check that box.
- Then check the box in the Property list.
Figure 14. Verification Point Data window
- Click Finish, close the browser, and stop the recording.
Rational Functional Tester should now generate a script that looks similar to what the screen output in Listing 1 shows.
Listing 1. Script generated by Rational Functional Tester
import resources.AddToCartHelper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
/**
* Description : Functional Test Script
* @author Michael
*/
public class AddToCart extends AddToCartHelper
{
/**
* Script Name : AddToCart
* Generated : Nov 5, 2006 2:53:22 PM
* Description : Functional Test Script
* Original Host : WinNT Version 5.1 Build 2600 (S)
*
* @since 2006/11/05
* @author Michael
*/
public void testMain(Object[] args)
{
startApp("www.BookPool.com");
// Window: firefox.exe: Bookpool Discount Computer Books. Welcome!
texttext().click(atPoint(78,10));
bookpoolDiscountComputerBooksW().inputChars("Java");
httpGBookpoolComHpSearch_btnGi().click(atPoint(24,11));
// Window: firefox.exe: Bookpool: Books Found - Mozilla Firefox
cellwin().click(atPoint(0,0));
// Window: firefox.exe: Bookpool: Shopping Basket - Mozilla Firefox
cellwin2().performTest(Cell_standardVP());
bookpoolShoppingBasketMozillaF(ANY,MAY_EXIT).click(CLOSE_BUTTON);
}
}
|
Now, run the script that you recorded.
- With the script open, click the Run Functional Test Script button in the toolbar. This opens the Select Log window that Figure 15 shows.
Figure 15. Select Log window
- Click Finish to start running the script.
You should see the Playback window (Figure 16) while the script is running. This window can give you an idea of what's happening if the script appears to be stalled for some reason.
Figure 16. Playback window
When your script finishes executing, a browser opens on your desktop and displays the results of the test run. (See Figure 17.)
Figure 17. Results of the test run
If you want a more detailed walkthrough of recording and playing back a script, read the Getting Started with Functional Tester Cheat Sheet under Help > Cheat Sheets. And don’t forget: You can always get help in the Functional and GUI Testing forum on developerWorks (also listed in Resources).
Learn
-
"Run and Analyze Software Tests with Rational ClearQuest Test Management" (developerWorks tutorial, October 2006).
- In the Rational Functional Tester resource area you'll find technical documentation, how-to articles, education, downloads, product information, and more.
-
Browse the
technology bookstore for books on these and other technical topics.
Get products and technologies
- Visit the Rational products'
trial downloads area.
Discuss
-
Check out the Functional and GUI Testing Rational discussion forum.
-
Check out developerWorks
blogs and get involved in the
developerWorks community.
Michael Kelly is currently an independent consultant and provides custom training in the IBM Rational testing tools. He consults, writes, and speaks on topics in software testing. He is currently serving as the Program Director for the Indianapolis Quality Assurance Association and is a Director at Large for the Association for Software Testing. He can be reached by email at Mike@MichaelDKelly.com.
Comments (Undergoing maintenance)





