Custom Search

Friday, October 3, 2008

Questions and answers related to web pages-Is there any way to test browser-based programs? Can I test HTML pages...

Q.: Is there any way to test browser-based programs? Can I test HTML pages?
A.: If you use TestComplete Standard, you can test web pages via their GUI. Run TestComplete and try to record your actions over a web page. The resultant script will look very similar to the one recorded on any other ordinary, non-Open application. As web testing depends on the connection speed, you should place delays in your script where ever they are needed. It can be calls to BuiltIn.Delay(…) and different loops for waiting on changes in the window of your Internet browser. Another aspect of web testing is that web pages intensively use graphics. You can use Regions.Find() to locate the necessary areas on a page and then click, double-click, drag them or perform other operations.
TestComplete Enterprise provides more web testing possibilities than TestComplete Standard. In addition to mouse click and keystroke simulation, the Enterprise edition can access the page’s HTML objects from scripts. You can actually refer to HTML elements from scripts using the same names that are used on your page. TestComplete 4 provides you with access to elements of web pages displayed in Internet Explorer ver. 4 - 7 or in WebBrowser controls that reside in any application (that is, TestComplete supports any browser created on the base of the WebBrowser control). TestComplete 5 and later lets you also work with web pages displayed in Firefox ver. 1.5.0.1 - 2.0.
TestComplete contains specific program objects to test combo boxes, list boxes and check boxes displayed on the page. Also, it provides two events that let you perform specific actions before navigating to a new page or upon downloading a page. For more information about web testing, see the “Web Testing” help topic.
The Enterprise edition of TestComplete 6 provides web checkpoints that let you easily perform various verifications over web pages. TestComplete Enterprise also includes the HTTP Load Testing project item that allows you to perform load, stress and scalability testing of web servers.


Q.: Which browsers does TestComplete support for testing web pages?
A.: With TestComplete, you can get access to web page elements and emulate mouse and keyboard actions over web pages displayed in the following browsers:
• Internet Explorer ver. 4 - 7
• Firefox ver. 1.5.0.1 - 2.0 (TestComplete 5 and later only)
• TestComplete provides access to web pages and their elements displayed in WebBrowser controls that reside in any application. In other words, TestComplete supports any browser created on the base of the WebBrowser control.
• TestComplete 5 and later provides limited support for Netscape Navigator ver. 8.1.2 (access to web page elements is only available if Navigator uses the Internet Explorer rendering engine. For more information, see Testing Web Pages Shown in Netscape Navigator in the TestComplete help).


Q.: Does TestComplete support testing of applications that use ASP, ASP.NET, CGI, ISAPI or PHP on the server side?
A.: Yes. The fact is that TestComplete Enterprise tests the client side of web applications and does not depend on the technology used on the server side.
We would like to note that TestComplete 6 provides a special Tree model that simplifies the testing of web pages produced by ASP.NET, PHP and other servers. This model reflects the actual parent-child relationship between HTML elements on the web page and addresses an object via its parent objects rather than via the document.all collection or the tag collection. This enables TestComplete to locate the desired element faster than it would when using the DOM or Tag models. That is why we recommend that you use the Tree model for testing dynamically created web pages.


Q.: Does TestComplete support testing of AJAX applications?
A.: Yes. TestComplete Enterprise tests the client side of web applications and does not depend on the technology used on the server side, so, you can use TestComplete to test web pages produced by AJAX servers.
Q.: Does TestComplete support testing of Flash elements on web pages?
A.: Yes. Flash elements can be exposed via TestComplete’s MSAA Open Applications plug-in. To make the Flash elements be treated as MSAA objects, do the following:
1. Open your project in TestComplete.
2. Right-click the project’s node in the Project Explorer panel and select Edit | Properties from the context menu. This will open the Project editor in the Workspace panel and activate the editor’s Properties page.
3. Choose Open Applications | MSAA from the list on the left of the page. This will activate the MSAA section of the project properties.
4. Click Add to append a new entry to the List of accepted windows and enter MacromediaFlashPlayerActiveX into the editor.
5. Choose File | Save from TestComplete’s main menu to save the changes.
However, this approach only lets you test Flash elements residing on web pages that are shown in Microsoft Internet Explorer or the Microsoft WebBrowser control. Testing Flash elements in Mozilla Firefox is currently not supported because the Firefox component that is responsible for displaying Flash elements does not support Microsoft Active Accessibility.
Besides, elements of certain Flash-movies may not be available in TestComplete because those movies are displayed in a windowless mode. This behavior is controlled by the movie’s WMode parameter. To test your movie you should set it to default value: window (wmode="window"). The parameter value can be set in Macromedia Flash IDE while publishing a movie (the Window Mode option on the HTML tab of the Publish Settings dialog) or right in the HTML code of the corresponding page (in the Object and Embed tags). Here is a snippet of HTML source code:
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
width="200" height="200">



type="application/x-shockwave-flash" wmode="window" width="200" height="200">

Q.: The script recorded over the tested web page is not played back correctly. What is wrong?
A.: Most likely the script addresses web page elements by their index. TestComplete uses indexes if the element does not contain the Id or Name attribute (if any of these attributes are specified, TestComplete uses the attribute value to address the element).
Using Id or Name is more reliable than using the indexes since the indexes can change from one test run to another.
To work around the problem, use any of the following approaches:
• In the source code of the tested web page, specify the Name or Id attribute for all controls that you need to work with from scripts. Upon doing this, you will be able to address the controls using the specified identifiers.
• Use the Page(…).NativeWebObject.Find method to search for the desired control by values of its properties and attributes (innerText, innerHTML, href, src and so on).


.: I would like to add an HTML document to the Tested Applications collection. How can I do this?
A.: Add the IEXPLORE.EXE application and specify the name and path of the desired HTML page as a command-line argument


.: The web page I am testing displays the Login dialog. How can I access this dialog?
When opening some pages, you may see a Login dialog where you should enter the user name and password in order to access the page or the browser may display the Information bar asking for your permission to perform certain actions requested by the page. If you test these type of pages, you need to write code that will:
• Open the page.
• Close the the Login dialog or the Information bar by simulating user actions over them.
• Wait until the page is loaded.
Note that the Page.ToUrl method, which is used to open pages, does not return the execution control to the script until the specified page is loaded. In other words, it does not return the execution control until the Login dialog or Information bar is closed.
To close the dialog and informative message you should simulate user actions that will close the dialog and the bar. However, you cannot do this since the ToUrl method does not return the control until the dialog and the bar are closed. To work around the problem, you can use any of the following approaches:
• Enter the page’s URL into the Address bar or into the File | Open dialog of your web browser (for example, using the Keys method).
• Use the Navigate or Navigate2 methods of the page object (this is only valid for pages displayed in Internet Explorer or a WebBrowser control).
• Call the Page.ToUrl method using the Runner.CallObjectMethodAsync method. It will execute the ToUrl method asynchronously, so that the latter will not pause your script and you can simulate user actions over the Login dialog or Information bar.
For more information and code examples, see the “Opening Web Pages That Display the Login Dialog or Informative Messages” help topic.


Q.: How can I find a web page element that contains specific text?
A.: TestComplete provides you with access to methods and properties of web page elements, so you can search all web page elements and find the desired text in the element properties. To perform the search, you can use the Page object’s Find method. This method uses three parameters:
Page.NativeWebObject.Find(PropertyName, KeyValue, TagName)
• PropertyName - Name of the property, whose value is checked by the method. Typically, the element’s text is accessible through the innerHTML or innerText property.
• KeyValue - The sought-for text (you can use the * and ? wildcards to specify the search masks).
• TagName - This parameter is optional. You can use it to specify tag names that you would like to search in.
Note that since the name of the Find method coincides with the name of the Find method added to all tested objects by TestComplete, the Page object’s method resides in the NativeWebObject namespace, that is, in your script you should call Page.NativeWebObject.Find rather than Page.Find.
.: How do I work with HTML tables from scripts?
A.: A table is a TABLE element with special sub-elements for the table’s header, footer and body. These sub-elements contain rows and cells. TestComplete provides scripting access to web page elements as well as to their attributes, methods and events. You can use this functionality to obtain data from tables displayed on the web page under test.
To retrieve data from a table, you can use the rows and cells properties of the table object (this is an object defined by the Document Object Model). The cells property belongs to the table and to the row objects. The table’s property provides access to all cells of the table. The row’s property provides access to values displayed in the row’s cells.
Note, however, that the rows property of the table object provides access to all rows of the table, including the rows of the table’s header and footer. To only process the table’s cells located in the body, you need to obtain the objects corresponding to the TBODY elements (note that a table can contain several TBODY elements) and then go through the rows and cells of each TBODY.
In TestComplete 6, you can also parse HTML tables using the features provided by the web Tree model. If this model is active, TestComplete represents an HTML table as the Table object with child Cell objects corresponding to table cells. You can access individual cells by their zero-based row and column indexes. For example, Cell(2, 0) addresses the first cell in the third row. TestComplete also extends the “native” functionality of the DOM table object with the RowCount and ColumnCount properties, which you can use to iterate through the table cells.

No comments: