ASP.net UI tool test

Source: Internet
Author: User
Tags assert goto

ASP.net UI tool test

When you test the user interface, you are testing human activity. Because of this, you should let the computer perform the task

Is good, you should perform the type of task, you are easy to be trifled with. When developers and testers first pair the available

Learning from the UI tools for testing, they tend to think that everything can be automated, which is far from reality. 7th chapter of the

Book test asp.net Web Application [, by Jeff McWherter and the Department (ISBN: 978-0-470-49664-0

, Wrox Press, 2009, Copyright Wiley Publishing Co., Ltd. about in-depth talks, manual tests but now it's important

We understand that manual testing remains a very important test discipline for a test cycle.

Professor Frederick Brucks in the "No silver bullet-nature and software engineering accident," 1987-year program to open

Sender of the file, no silver bullet in software development, which means that there is no tool that can solve the whole work you

Want to finish. Interface testing should not be considered final for all upcoming tests. When the user interface is properly

Testing is a very powerful test tool.

In your realization of the importance of user interface Automation testing, the next most important decision to put forward is that your tool will make

With the created test. There are three schools of thought how to test the user interface.

Analog browsers

This is a headless set of scripts sent by the request to simulate the same type of browser, but the response time of the measure, without

Content expression, was sent back. This type of UI test is great for discovering bottlenecks in Web applications. This type of test

The disadvantage is that you are not studying and verifying the reaction of the test. This type of test can only be used for quantity, pressure and negative

Load test scenarios.

The Network Capacity Analysis tool (cold atomic trapping) is a lightweight HTTP load generation tool designed to simulate and

Number of users to send the request to a site. Cold atoms capture with simple scripts to simulate browsers and fully exercise a

Web site:

A new deal.

The CLASSID = 1

HTTP for new request

verb = "get"

url = "http://www.google.com"
Using Nunit.framework;

Using System.Net;

Using System.IO;

Namespace Parsehttp

{

[Testfixture]

public class Parsehttp

{

[Test]

public void Should_navigate_to_google_and_return_results_for_aspnet ()

{

String urltotest =

"Http://www.google.com/search?"

Hl=en&rlz=1g1gglq_enus295&q=asp.net&btng=search ";

string result = GetPage (urltotest);

Assert.istrue (result. IndexOf ("the official") >0, "ASP.net Page

");

}

private string GetPage (String urltotest)

{

Create a Web client object to load the page from local server

WebClient client = new WebClient ();

string result = String. Empty;

Dump the contents of the page we navigated to into a stream

using (StreamReader reader = new

StreamReader (client. OpenRead (Urltotest))

{

result = reader. ReadToEnd ();

}

return result;

}

}

}

Browser

In this interface test method (such as in the future listing), the test will open a physical browser, execute the behavior,

The test then validates the HTML based on the criteria you entered in the test. This type of automatic interface test is manually measured

Try the closest you'll get. Because the test needs to open the browser, execute the test, and report that the results support this type of

Testing is very fragile. These types of tests are often complex if your plan is only to stress test your application

The sequencing of this type of test would be overkill:


Using Nunit.framework;

Using Watin.core;

Using WatiN.Core.Interfaces;

Namespace Simplewatintest

{

[Testfixture]

public class Simplewatintests

{

[Test]

public void

Should_click_search_on_google_and_return_results_for_aspnet ()

{

using (Ibrowser ie =

Browserfactory.create (Browsertype.internetexplorer))

{

Ie. GoTo ("http://www.google.com");

Ie. TextField (Find.byname ("Q")). Value = "asp.net";

Ie. Button (Find.byname ("btng")). Click ();

Assert.istrue (ie. ContainsText

("The official Microsoft asp.net Site");

}

}

}

}

Using Nunit.framework;

Using Watin.core;

Using WatiN.Core.Interfaces;

Namespace Simplewatintest

{

[Testfixture]

public class Simplewatintests

{

[Test]

public void

Should_click_search_on_google_and_return_results_for_aspnet ()

{

using (Ibrowser ie =

Browserfactory.create (Browsertype.internetexplorer))

{

Ie. GoTo ("http://www.google.com");

Ie. TextField (Find.byname ("Q")). Value = "asp.net";

Ie. Button (Find.byname ("btng")). Click ();

Assert.istrue (ie. ContainsText

("The official Microsoft asp.net Site");

}

}

}

}

Below is a table an how-HTML elements can be obtained using the Watin

Framework. Watin HTML Mapping:

HTML ELEMENT watin Class Example
<a/> Link Ie.link (LinkId)
<button/> Button Ie.button (buttonid)
<div/> Div ie.div (divid)

<form/> Form Ie.form (formid)
<frame/> Frame
Ie.frame (Frameid)
<iframe/> Frame ie.frame (Iframeid)
Image ie.image (imageID)
<input type=button/> button Ie.button (ButtonID)
<input type=checkbox/> checkbox Ie.checkbox (CHECKBOXID)
<input type=file/> fileupload ie.fileupload (Fileuploadid)
<input type=image/> Image Ie.image (imageID)
<input type=password/> TextField Ie.textfield (Passwordid)
<input type=radio/> RadioButton Ie.radiobutton (radioid)
<input type=submit/> Button Ie.button (Submitid)
<input type=text/> TextField Ie.textfield (Textid)
<label/> Label
Ie.label (ElementID)
<option/> Option Ie.select (Selectid). Options
<p/> Para Ie.para (pId)
<select/> Select Ie.select (selectid)
<span/>
<table/> Table ie.table (tableId)
<tbody/> tablebody ie.tablebody (Tablebodyid)
Ie.table (TableID). Tablebodies
<td/> TableCell Ie.tablecell (tablecellid)
Ie.table (TableId). Tablerows[0]. Tablecells[0]
<textarea/> TextField Ie.textfield (textareaid)
<tr/> TableRow ie.tablerow (tablerowid)
Ie.table (TableId). Tablerows[0]
All elements, also the ones is not mentioned in this list Element and
Elementscontainer ie.element (ElementID)
Ie.element (tagname, ElementID)

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.