当前位置: 澳门新濠3559 > 编程 > 正文

好多网站中,  本篇是一个内容索引

时间:2019-12-27 17:08来源:编程
背景:每个网页的基本框架结构类似: 浏览网站的时候会发现,好多网站中,每个网页的基本框架都是一样的,比如,最上面都是网站的标题,中间是内容,最下面是网站的版权、开发

图片 1

背景:每个网页的基本框架结构类似:

浏览网站的时候会发现,好多网站中,每个网页的基本框架都是一样的,比如,最上面都是网站的标题,中间是内容,最下面是网站的版权、开发提供商等信息:

 

在这些网页中,表头、底部的样式和内容都是一样的,不同的只是中间的内容。

因此在制作网站时,可以将这些共同的东西分离出来,放到“窗体母版页”中,在需要的时候嵌套就可以。

 

  本篇是一个内容索引,对测试不感兴趣的可以马上飘过:)前几篇IronRuby的文章都是围绕着自动化测试来写的,这个测试框架使用了微软的CodedUI Test的几个dll功能来写的。学习任何新的技术和事务,网上查找资料是最容易想到,也是最方便快捷的方式,在Mathew Aniyan的blog中列了一些更全的参考内容列表,摘录在此以备忘之,也给对CodedUI测试感兴趣的朋友一个学习参考索引,通过查看这些内容可以更快的了解它。

我使用VisualStudio2013开发ASP.NET网站,连接MySQL数据库,在网站项目中添加引用“MySql.Data.dll",在VisualStudio2013开发环境中运行浏览网页Test1.aspx一切正常,可以显示数据库信息。但我将整个网站文件复制到IISWeb服务器上再浏览网页Test1.aspx时,系统报错,错误信息见下图,请大侠帮忙解决问题所在?谢谢。

巧用窗体母版项:

下面就开始行动(本文是以VisualStudio2013作为编程环境,可能在某些步骤与其他版本有所出入,请自行注意):

1、在项目中添加一Web窗体母版页test.Master:右键项目—添加—新建项—Web窗体母版页;

 

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="test.master.cs" Inherits="Web.test1" %>
 
 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
     
 
 
    <form id="form1" runat="server">
    <div>
         
         
        </asp:contentplaceholder>
    </div>
    </form>
 
<!--html>

 

2、在窗体母版页test.Master的标记之间添加CSS、JS等引用(这里先只添加CSS文件为例):

 

?

1
2
3
4
5
<link href="css/common.css" rel="stylesheet">    <%--添加引用CSS文件--%>     
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
 
</asp:contentplaceholder>

3、编辑窗体母版页test.Master,添加每个网页的公共内容(此处以网页布局为上图的布局为例,三个div的css样式就暂不说明):

 

 

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form id="form1" runat="server">
    <div id="top">                                 <%--每个网页的公共样式:网页头部--%>
        <h1>某某某网站</h1>
    </div>
         
    <div id="main">                                <%--每个网页的不同样式:网页主体内容--%>
         
             <%--此处为每个嵌套此母版的各个网页的不同内容--%>
        </asp:contentplaceholder>
    </div>    
 
    <div id="footer">                              <%--每个网页的公共样式:网页版权信息区--%>
        <p>版权所有:******</p>
    </div>
</form>

4、在每个网页中嵌套窗体母版页test.Master:右键项目—添加—新建项—包含母版页的Web窗体test.aspx,在选择母版页对话框中选择test.Master,确定,生成的网页为:

 

 

?

1
2
3
4
5
<%@ Page Title="" Language="C#" MasterPageFile="~/common.Master" AutoEventWireup="true" CodeBehind="test2.aspx.cs" Inherits="Web.test2" %>
 
</asp:content>
 
</asp:content>

此时这个窗体test.aspx和母版页test.Master的运行效果是一样的,接下来就是加上每个网页中的不同的内容。

 

 

5、此时,网页test.aspx中ContentPlaceHolderID=“head”和ContentPlaceHolderID=“contentPlaceHolder”的就相当于母版页test.Master中对应的。所以假如每个网页都会有相同部分,就可以把相同部分写在母版页的相应位置,而将每个网页的不同内容写在ContentPlaceHolderID=“contentPlaceHolder”的中。

比如,第4步中,这个test.aspx已经嵌套了这个样式,它的主题内容为 “ 网站内容 网站内容 网站内容 网站内容…… ”,则test.aspx中的代码为:

 

?

1
2
3
4
5
6
<%@ Page Title="" Language="C#" MasterPageFile="~/common.Master" AutoEventWireup="true" CodeBehind="test2.aspx.cs" Inherits="Web.test2" %>
 
</asp:content>
 
    <p>网站内容 网站内容 网站内容 网站内容…… </p>
</asp:content>

假如我又建了一个名为test1.aspx的网页,除了与test1.aspx中的主体内容不一样之外,其他都一样,那么就可以让test1.aspx嵌套母版页test.Master,代码为:

 

 

?

1
2
3
4
5
6
<%@ Page Title="" Language="C#" MasterPageFile="~/common.Master" AutoEventWireup="true" CodeBehind="test2.aspx.cs" Inherits="Web.test2" %>
 
</asp:content>
 
    <p>网站内容1 网站内容1 网站内容1 网站内容1…… </p>
</asp:content>

 

 

Getting Started with Coded UI Test

拓展:母版页嵌套母版页

当整个网站内的所有网页并不是这一种样式,而是一个大的网站分为几个栏目,每个栏目中网页的风格样式统一,这时候可以用母版页来嵌套母版页 :

 

现在再建立一个母版页(我在这里给它取名为“子母版页”),用它来嵌套上面的母版页test.Master,代码为:

 

?

1
2
3
4
5
6
7
8
9
10
11
<%@ Master Language="C#" MasterPageFile="~/test.Master" AutoEventWireup="true" CodeBehind="m_common.master.cs" Inherits="Web.admin.m_common" %>
 
 
     
</asp:content>
 
     
     
         <%--此处为嵌套“子母版页”的各个网页的不同内容--%>
    </asp:contentplaceholder>
</asp:content>

注意,代码第一行的MasterPageFile=“~/test.Master”即要嵌套的母版页的地址,“~”为当前目录。

 

 

Introduction to Coded UI Test

嵌套网页母版项的好处:

可以利用VisualStudio中的窗体母版页来将每个页面中相同的部分进行封装,在创建相同结构的网页时,便可以直接嵌套这个窗体母版页,避免了代码的重复,提高了代码的复用性;另外,如果要修改一个栏目甚至整个网站的风格,则只需修改母版页以及母版页中引入的<script>等文件,提高了代码的可维护性,充分体现了OOP的思想。

Testing the User Interface with Automated UI Tests.aspx)

Platform Support

Supported Configurations and Platforms for Coded UI Tests and Action Recordings.aspx)

A more frequently updated version can be found at

Platform Support for Coded UI Test(and Fast Forward feature of Test Runner)

Testing support for Silverlight Apps in Visual Studio 2010

Online Help

How to: Generate a Coded UI Test from an Action Recording.aspx)

How to: Create an Action Recording.aspx)

How to: Generate a Coded UI Test by Recording the Application Under Test.aspx)

How to: Add UI Controls And Validation Code Using the Coded UI Test Builder.aspx)

How to: Create a Data-Driven Coded UI Test.aspx)

How to: Add Requirements or User Stories to Your Test Plan.aspx)

Running Automated Tests.aspx)

 

How to: Configure and Run Scheduled Tests After Building Your Application.aspx)

Running Automated Tests from the Command Line.aspx)

 

How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop.aspx)

Best Practices for Coded UI Tests.aspx)

FAQ

 

FAQs - 1

FAQs - 2

Next Sibling

Why is my application launch not recorded properly

Automating Mouse Actions with 2 buttons clicked at the same time

Forum

Visual Studio UI Automation Testing (includes CodedUI)

What is new in Beta2/RC?

What’s new for testers doing UI automation in VS 2010 Beta2?

Visual Studio 2010 RC is now available

Webcasts & Videos

VS2010 demos for testing tools – MTLM, CUIT and related features

More on testing capabilities of VS 2010

Defining Your Testing Effort Using Test Plans.aspx)
Creating and Managing Tests.aspx)
Setting Up Test Machines to Run Tests or Collect Data.aspx)
Running Tests
Submitting Bugs.aspx)
Tracking Software Quality.aspx)

Working with Coded UI Test

Creating a Coded UI Test

How to: Generate a Coded UI Test from an Action Recording.aspx)

How to: Generate a Coded UI Test by Recording the Application Under Test.aspx)

How to: Add UI Controls And Validation Code Using the Coded UI Test Builder.aspx)

Understanding the generated code/ Customizing the code

Understanding the code generated by “Coded UI Test” – Part 1
Understanding the code generated by “Coded UI Test” – Part 2

Data Driving

Data Driving Coded UI Tests

Running on remote machine

How to: Configure and Run Scheduled Tests After Building Your Application.aspx)

Running from Microsoft Test Manager

How to: Run Automated Tests from a Test Plan Using Microsoft Test and Lab Manager.aspx)

Debugging & Troubleshooting

 Logging a message in test result as part of an automated test

How To: Enable Tracing for “UI Test” Components

Analysis of Results

Analyzing Test Results in MTM – Part I

Analyzing Test Results in MTM – Part II

Build, Deploy & Test workflow

Quick Start Guide for Automating Build, Deployment, and Test.aspx)

API References

Microsoft.VisualStudio.TestTools.UITesting.aspx)
Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.aspx)
Microsoft.VisualStudio.TestTools.UITesting.WinControls.aspx)
Microsoft.VisualStudio.TestTools.UITesting.WpfControls.aspx)

Best Practices for Coded UI Test

Best Practices for Coded UI Tests

How To's

How To: Get automation working properly on data bound WPF list or combo box
How To: Select a list item directly
How To: Get same test running under different environments
How To: Make playback wait for certain event?
How To: Configure search properties used by recordercode generation
Walkthrough: Using multiple Coded UI maps in test automation

How To: Image comparison in Coded UI Test How To: Get UI Testing methods working outside the Test Method of Coded UI Test How To: Validate Background Color or other custom properties of WPF control in Coded UI Test

Extending Coded UI Test

Adding support for a UI Framework

Introduction to Coded UI Test Extensibility
“Hello, World” Extension for Coded UI Test
Introducing Sample Excel Extension
Technology Adapter of Sample Excel Extension

Supplementing additional properties for a control

Property Provider of Sample Excel Extension

Adding filtering rules to recording

Action Filter of Sample Excel Extension

Other extensibility scenarios

Writing your own client using uitest object model Extending Supported Properties set of a controlWriting Extension for WPF Custom Control

API Library of common tasks

 

Extensibility API References

Microsoft.VisualStudio.TestTools.UITest.Extension.aspx)
Microsoft.VisualStudio.TestTools.UITest.Common.aspx)
Microsoft.VisualStudio.TestTools.UITest.Common.UIMap.aspx)
Microsoft.VisualStudio.TestTools.UITest.CodeGeneration.aspx)

Extensibility in other testing tools in VS

Extending the Visual Studio Unit Test Type
Creating a Diagnostic Data Adapter to Collect Custom Data or Impact a Test System.aspx)
The Test Management API - Getting Started

Deep Dives

Accessibility

 

Verify Accessibility Support

 

Fix Accessibility Issue

How To: Get automation working properly on data bound WPF list or combo box

Implement Client Side Providers for Accessibility

 

Exploit lesser known features of Accessibility to improve experience

 

UI Test Framework

UI Test Framework - Part 1
UI Test Framework - Part 2

Details of each UI Framework Supported - Differences, Known Issues and Workarounds

 

Web

IE Plugin Part 1
IE Plugin Part 2
UI Test Framework Firefox support

WinForms

WinForms Plugin Part 1
WinForms Plugin Part 2

WPF

WPF Plugin Part 1
WPF Plugin Part 2

SharePoint

 UI Test Framework Sharepoint support

MFC/Win32

 UI Test Framework MFC support

Samples

 

Web

 

WinForms

 

WPF

 

SharePoint

 

MFC/Win32

 

Popular Blogs

Anutthara Bharadwaj
Gautam Goenka Balachander G. Subramaniam
Rubel Singhal Rituparna Paul
Team Blog

 

欢迎转载,转载请注明:转载自周金根 [ ]

编辑:编程 本文来源:好多网站中,  本篇是一个内容索引

关键词: