Automatic UI test of Silverlight/aspx/ajax/MVC

Source: Internet
Author: User
Tags delete cache

Automated Testing of the Web Front-end generally requires simulating mouse clicks, keyboard input, automatic browser page navigation, and other functions. The key is to automatically record and play back the entire test process.

Vs2010 SP2 has integrated built-in functions, but it has not yet been officially released, so this article will not introduce it. If you are interested, refer to the followingArticle:

Http://msdn.microsoft.com/zh-cn/library/gg413374

Http://www.cnblogs.com/scottxu/archive/2011/02/28/1967112.html

In addition to Microsoft's upcoming vs2010 SP2, many third-party manufacturers have also launched the corresponding solutions, such as ranorex (garden brother wrote entry article: http://www.cnblogs.com/chenkai/archive/2010/09/28/1837457.html)

And I want to introduce is telerik test studio, http://www.telerik.com/automated-testing-tools.aspx choose it, the reason is very simple: it is too easy to get started, no matter the novice veteran, ensure that you can get started in 5 minutes, it also supports almost all front-end technologies, including Ajax, aspx MVC, Silverlight, and WPF.

First try it out. Test the common website: (use Baidu to open the knife)

After downloading test studio of telerik, there are two ways to run it: one is to run it separately, and the other is to integrate it in vs2010 as a plug-in. For convenience, the second method is used below

1. Open vs2010 to create a test project

2. Start the recording test process.

By default, a new project already has a web test item, which is automatically enabled as follows:

Click the record button (Red circled in the figure), the browser will be started by default, and then enter the http://www.baidu.com/in the address bar of the browser, pay attention to the changes in vs2010

The current action is automatically recorded: navigate to: 'http: // www.baidu.com /'. Then, in the browser input box, enter "Yang Guo under the bodhi tree" and click "Baidu"

We can see that the entire keyboard input process and the mouse clicking "Baidu" action have been recorded. Close the browser and the recording process ends. (Do you think of the advertisement: Where can't you click? So easy !)

3. Test playback

Click "green" to play back the test process.

The UI automation test of Silverlight is almost the same as that of a common website. You only need to configure the Silverlight running mode and start page in advance. Because Sl has two running modes: browser mode and OOB mode, you need to tell test studio what you want to do.

Right-click the project and choose create item> Web test.

Type "silverlighttest. tstest" in the file name (you can change it as needed) and open the file, for example:

Click the button circled by the red line in the toolbar for configuration. This time, we will use the Silverlight official website to open the configuration.

The web URL is a webpage address embedded with Silverlight. Click OK to close the window. The rest is exactly the same as the test of Baidu.

I can click a few on the showcase animation on the page. The recorded results are as follows:

It's easy enough. The OOB test is almost the same as this one. You just need to specify the SL application's shortcut path during configuration.

Note:

In the Silverlight test, I found that occasionallyTest studio cannot connect to silverlihgtThe following are the debugging suggestions provided by telerik engineers:

Known issues:
-Automation only supports xap Silverlight app deployment (the. NET method). xbap or Javascript Silverlight deployment is not supported.
-Connecting to the Silverlight app via HTTPS in Firefox or Safari is currently not supported.
Diagnostic steps:
1) if the web and Silverlight app is deployed locally, try adding a period ('.') after localhost, as in http: // localhost. :
2) Delete the entire cache for the test playback Browser
-In ie select: Tools-> Internet Options-> (under General Tab) delete-> choose to delete Temporary Internet Files
-In Firefox select: Tools-> clear recent history-> select everything in 'time range to clear' drop down menu-> choose to delete Cache
-In safari select: main toolbar drop down menu-> Reset safari... -> Choose to 'emptythe cache'
3) try increasing the (settings.) silverlightconnecttimeout if the Silverlight app has a longer load time
4) Try Setting externalaccessfromcrosdomaincallers to script only in your application's appmanifest. XAML file by doing the following in your HTML page and Silverlight manifest:
A) Example for HTML page:


Example for SL manifest:

<Deployment xmlns = "http://schemas.microsoft.com/client/2007/deployment"
2: xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
3:Externalcallersfromcrosdomain = "scriptableonly"
4:>
5: <deployment. Parts>
6: </deployment. Parts>
7: </deployment>

(See this Microsoft Forum Thread for more information: http://forums.silverlight.net/forums/p/101955/340407.aspx)

4

) Try setting the "windowless" Property for your Silverlight app as "false"
Example (similar to Step 3 HTML example ):
<Object ID = "xamlhost0" width = "900" Height = "412" type = "application/X-Silverlight">
<Param value = "Transparent" name = "background"/>
<Param value = "true" name = "windowless"/>
<! -- A bunch of other Params go here -->
</Object>

5) Check the headers your server is sending for the Silverlight page:
-Install/run fiddler and load your Silverlight page.
-Click the response for the. xap file.
-Click inspectors-> headers.
There shoshould be an entry: Content-Type: Application/X-Silverlight-app
This must be in the response in order for the webaii framework, design canvas, or webui test studio to detect the Silverlight app.

Although it is in English, it is not complicated. It can be solved only when marked in red.

finally, I provide a tip to solve this problem. When testing Silverlight recording, if the browser cannot automatically jump to the specified web URL after recording is started, you can manually enter the URL in the browser. Generally, test studio can identify that the current page has Silverlight.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.