Web应用程序的测试自动化外文翻译资料

 2021-12-19 09:12

Introduction

Test Automation for Web Applications

Many, perhaps most, software applications today are written as web-based applications to be run in an Internet browser. The effectiveness of testing these applications varies widely among companies and organizations. In an era of highly interactive and responsive software processes where many organizations are using some form of Agile methodology, test automation is frequently becoming a requirement for software projects. Test automation is often the answer. Test automation means using a software tool to run repeatable tests against the application to be tested. For regression testing this provides that responsiveness.

There are many advantages to test automation. Most are related to the repeatability of the tests and the speed at which the tests can be executed. There are a number of commercial and open source tools available for assisting with the development of test automation. Selenium is possibly the most widely-used open source solution. This userrsquo;s guide will assist both new and experienced Selenium users in learning effective techniques in building test automation for web applications.

This userrsquo;s guide introduces Selenium, teaches its features, and presents commonly used best practices accumulated from the Selenium community. Many examples are provided. Also, technical information on the internal structure of Selenium and recommended uses of Selenium are provided.

Test automation has specific advantages for improving the long-term efficiency of a software teamrsquo;s testing processes. Test automation supports:

  • Frequent regression testing
  • Rapid feedback to developers
  • Virtually unlimited iterations of test case execution
  • Support for Agile and extreme development methodologies
  • Disciplined documentation of test cases
  • Customized defect reporting
  • Finding defects missed by manual testing

To Automate or Not to Automate?

Is automation always advantageous? When should one decide to automate test cases?

It is not always advantageous to automate test cases. There are times when manual testing may be more appropriate. For instance, if the applicationrsquo;s user interface will change considerably in the near future, then any automation might need to be rewritten anyway. Also, sometimes there simply is not enough time to build test automation. For the short term, manual testing may be more effective. If an application has a very tight deadline, there is currently no test automation available, and itrsquo;s imperative that the testing get done within that time frame, then manual testing is the best solution.

Introducing Selenium

Selenium is a set of different software tools each with a different approach to supporting test automation. Most Selenium QA Engineers focus on the one or two tools that most meet the needs of their project, however learning all the tools will give you many different options for approaching different test automation problems. The entire suite of tools results in a rich set of testing functions specifically geared to the needs of testing of web applications of all types. These operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior. One of Seleniumrsquo;s key features is the support for executing onersquo;s tests on multiple browser platforms.

Seleniumrsquo;s Tool Suite

Selenium is composed of multiple software tools. Each has a specific role.

Selenium 2 (aka. Selenium WebDriver)

Selenium 2 is the future direction of the project and the newest addition to the Selenium toolkit. This brand new automation tool provides all sorts of awesome features, including a more cohesive and object oriented API as well as an answer to the limitations of the old implementation.

As you can read in Brief History of The Selenium Project, both the Selenium and WebDriver developers agreed that both tools have advantages and that merging the two projects would make a much more robust automation tool.

Selenium 2.0 is the product of that effort. It supports the WebDriver API and underlying technology, along with the Selenium 1 technology underneath the WebDriver API for maximum flexibility in porting your tests. In addition, Selenium 2 still runs Selenium 1rsquo;s Selenium RC interface for backwards compatibility.

Selenium 1 (aka. Selenium RC or Remote Control)

As you can read in Brief History of The Selenium Project, Selenium RC was the main Selenium project for a long time, before the WebDriver/Selenium merge brought up Selenium 2, the newest and more powerful tool.

Now Selenium 1 is deprecated and is not actively supported (mostly in maintenance mode).

Selenium IDE

Selenium IDE (Integrated Development Environment) is a prototyping tool for building test scripts. It is a Firefox and Chrome plugin and provides an easy-to-use interface for developing automated tests. Selenium IDE has a recording feature, which records user actions as they are performed and then exports them as a reusable script in one of many programming languages that can be later executed.

Note

Even though Selenium IDE has a “Save” feature that allows users to keep the tests in a table-based format for later import and execution, it is not designed to run your test passes nor is it designed to build all the automated tests you will need. Specifically, Selenium IDE doesnrsquo;t provide iteration or conditional statements for test scripts. At the time of writing there is no plan to add such thing. The reasons are partly technical and partly

介绍

Web应用程序的测试自动化

当今许多(可能是大多数)软件应用程序都是基于Web的应用程序编写的,以便在Internet浏览器中运行。在公司和组织之间,测试这些应用程序的有效性差异很大。在高度互动和响应迅速的软件流程的时代,许多组织正在使用某种形式的敏捷方法,测试自动化经常成为软件项目的必需品。测试自动化通常就是答案。测试自动化意味着使用软件工具对要测试的应用程序运行可重复的测试。对于回归测试,这提供了响应性。

测试自动化有许多优点。大多数都与测试的可重复性和测试执行的速度有关。有许多商业和开源工具可用于协助开发自动化测试软件。Selenium可能是最广泛使用的开源解决方案。本用户指南将帮助新的和经验丰富的Selenium用户学习有效的技术,为Web应用程序构建测试自动化。

本用户指南介绍了Selenium软件,教授其功能,并介绍了Selenium社区积累下来的常用实践方案,还提供了许多示例。此外,还提供了有关Selenium内部结构和Selenium的推荐用途的技术信息。

测试自动化具有提高软件团队测试过程长期效率的特定优势。测试自动化支持:

  • 频繁的回归测试
  • 快速反馈给开发人员
  • 几乎无限次迭代的测试用例执行
  • 支持敏捷和极端开发方法
  • 有纪律的测试用例文档
  • 定制的缺陷报告
  • 找出手动测试遗漏的缺陷

自动化还是不自动化?

自动化总是有利吗?什么时候应该决定自动化测试用例?

自动化测试用例并非永远有优势,有时手动测试可能更合适。例如,如果应用程序的用户界面在不久的将来会发生很大变化,那么无论如何都可能需要重写所有自动化程序。此外,有时候没有足够的时间来构建测试自动化。从短期来看,手动测试可能更有效。如果应用程序的截止日期非常紧迫,目前没有可用的测试自动化,并且必须在该时间范围内完成测试,那么手动测试就是最佳解决方案。

介绍Selenium

Selenium是一套不同的软件工具,每种工具都有不同的方法来支持测试自动化。大多数Selenium QA工程师专注于最能满足其项目需求的一两个工具,但是学习所有工具将为您提供许多不同的选项来解决不同的测试自动化问题。整套工具有丰富的测试功能,能够满足几乎所有类型的Web应用程序的测试需求。这些操作非常灵活,允许定位UI元素和将预期测试结果与实际应用程序行为进行比较的许多选项。Selenium的一个主要功能是支持在多个浏览器平台上执行一个测试。

Selenium的工具套件

Selenium由多个软件工具组成。每个人都有特定的角色。

Selenium 2(又名Selenium WebDriver)

Selenium 2是该项目的未来发展方向,也是Selenium工具包的最新成员。这个全新的自动化工具提供了各种令人敬畏的功能,包括更具凝聚力和面向对象的API,以及对旧实现的局限性的解释。

正如您在Selenium项目简史中所读到的,Selenium和WebDriver开发人员都认为这两种工具都具有优势,并且合并这两个项目将创造一个更加强大的自动化工具。

Selenium 2.0是这项努力的产物。它支持WebDriver API和底层技术,以及WebDriver API下的Selenium 1技术,可以最大程度地灵活地移植测试。此外,Selenium 2仍然运行Selenium 1的Selenium RC接口,以实现向后兼容。

Selenium 1(又名Selenium RC或遥控器)

正如您在Selenium项目简史中所读到的那样,Selenium RC长期以来一直是主要的Selenium项目,在WebDriver / Selenium合并之前推出了Selenium 2,这是最新的,功能更强大的工具。

现在,Selenium 1已被弃用,并且不再被积极支持(主要是在维护模式下)。

SeleniumIDE

Selenium IDE(集成开发环境)是用于构建测试脚本的原型工具。它是一个Firefox和Chrome插件,它为开发自动化测试提供易于使用的界面。Selenium IDE具有记录功能,可记录执行时的用户操作,然后将其作为可重用脚本导出为可在以后执行的多种编程语言之一。

注意

尽管Selenium IDE具有“保存”功能,允许用户将测试保持在表格的格式中以供以后导入和执行,但它不是为运行测试版而设计的,也不是为了构建所有你需要的自动化测试而设计的。具体来说,Selenium IDE不为测试脚本提供迭代或条件语句。在撰写本文时,没有计划添加此类内容。原因部分是技术性的,部分是基于Selenium开发人员鼓励测试自动化的最佳实践,这总是需要一些编程。Selenium IDE简单地用作快速原型制作工具。Selenium开发人员推荐使用Selenium 2或Selenium 1进行严格,强大的自动化测试,以便与众多支持的编程语言中的一种一起使用。

Selenium- Gird

Selenium-Grid允许Selenium RC解决方案适用于大型测试套件和必须在多个环境中运行的测试套件。Selenium Grid允许您并行运行测试,也就是说,可以在不同的远程计算机上同时运行不同的测试。这有两个好处。首先,如果你有一个大型测试套件或一个运行缓慢的测试套件,你可以通过使用Selenium Grid来划分它们,使用这些不同的机器同时运行不同的测试,从而大大提高其性能。此外,如果必须在多个环境中运行测试套件,则可以让不同的远程计算机同时支持和运行测试。在每种情况下,Selenium Grid通过使用并行处理大大缩短了运行套件所需的时间。

选择你的Selenium工具

许多人开始使用Selenium IDE。如果您还不熟悉编程或脚本语言,可以使用Selenium IDE熟悉Selenium命令。使用IDE,您可以快速创建简单的测试,有时可在几秒钟内完成。

但是,我们不建议您使用Selenium IDE进行所有测试自动化。要有效地使用Selenium,您需要使用Selenium 2或Selenium 1以及一种受支持的编程语言来构建和运行测试。你选择哪一个取决于你。

在撰写本文时,Selenium正在计划将Selenium-WebDriver API作为Selenium未来的发展方向。提供Selenium1是为了向后兼容。但是,两者都有优点和缺点,本文件的相应章节对此进行了讨论。

我们建议那些新接触到Selenium的人阅读这些部分。但是,对于那些第一次采用Selenium并因此从头开始构建新测试套件的人来说,您可能希望选择Selenium 2,因为这是Selenium的一部分,将来会继续得到支持。

支持的浏览器和平台

在Selenium 2.0中,支持的浏览器取决于您使用的是Selenium-WebDriver还是Selenium-RC。

Selenium的webdriver

Selenium-WebDriver支持以下浏览器以及这些浏览器兼容的操作系统。

  • 谷歌浏览器
  • 有关Vista,Windows 7,Windows 8和Windows 8.1的适当组合的Internet Explorer 7,8,9,10和11。截至2014年4月15日,不再支持IE 6。该驱动程序支持在适用的情况下运行32位和64位版本的浏览器
  • Firefox:最新的ESR,以前的ESR,当前版本,前一个版本
  • 苹果浏览器
  • 歌剧
  • 的HtmlUnit
  • phantomjs
  • Android(使用Selendroid或appium)
  • iOS(使用ios-driver或appium)

Selenium 1.0和Selenium-RC。

这是Selenium 1.0的旧支持平台。它仍应适用于Selenium-RC的Selenium 2.0版本。

*通过Selenium IDE在Firefox上开发的测试可以通过简单的Selenium RC命令行在任何其他支持的浏览器上执行。

** Selenium RC服务器可以启动任何可执行文件,但根据浏览器安全设置,可能存在限制某些功能的技术限制。

灵活性和可扩展性

你会发现Selenium非常灵活。您可以通过多种方式为Selenium测试脚本和Selenium框架添加功能,以自定义自动化测试。与其他自动化工具相比,这可能是Selenium的最大优势。这些自定义在本文档的各个地方都有描述。此外,由于Selenium是开源的,因此始终可以下载和修改源代码。

这本书里有什么?

本用户指南针对新用户和已使用Selenium但正在寻求其他知识的用户。我们向新用户介绍Selenium时,不会假设用户之前的Selenium经验。但是,我们假设用户至少对测试自动化有基本的了解。对于更有经验的用户,本指南可以作为参考。对于经验更丰富的人,我们建议您浏览章节和副标题。我们提供了有关Selenium体系结构的信息、常见用法示例以及有关测试设计技术的章节。

Selenium的webdriver para;

注意:我们目前正在编写这些部分的文档。我们相信这里的信息是准确的,但请注意我们仍然在编写本章。我们将提供更多信息,这将使本章内容更加稳固。

引进的webdriver

Selenium 2.0的主要新功能是集成WebDriver API。除了解决Selenium-RC API中的一些限制之外,WebDriver还旨在提供更简单,更简洁的编程接口。Selenium-WebDriver的开发是为了更好地支持动态网页,页面元素可能会在不重新加载页面的情况下发生变化。WebDriver的目标是提供精心设计的面向对象的API,为现代高级Web应用程序测试问题提供改进的帮助。

与Selenium-RC相比,WebDriver如何“驱动”浏览器?

Selenium-WebDriver使用每个浏览器对自动化的本机支持直接调用浏览器。如何进行这些直接调用,以及它们支持的功能取决于您使用的浏览器。有关每个“浏览器驱动程序”的信息将在本章后面提供。

对于熟悉Selenium-RC的人来说,这与你习惯的完全不同。Selenium-RC以相同的方式为每个支持的浏览器工作。它在浏览器加载时将“javascript函数”注入浏览器,然后使用其javascript在浏览器中驱动AUT。WebDriver不使用此技术。同样,它使用浏览器内置的自动化支持直接驱动浏览器。

WebDriver和Selenium-Server

您可能需要也可能不需要Selenium Server,具体取决于您打算如何使用Selenium-WebDriver。如果您的浏览器和测试都在同一台机器上运行,并且您的测试只使用WebDriver API,那么您不需要运行Selenium-Server; WebDriver将直接运行浏览器。

有一些原因可以将Selenium-Server与Selenium-WebDriver一起使用。

  • 您正在使用Selenium-Grid在多台计算机或虚拟机上分发测试。
  • 您希望连接到具有特定浏览器版本但不在当前计算机上的远程计算机。
  • 您没有使用Java绑定(也可能是Python,C#或Ruby),并且希望使用HtmlUnit Driver

Selenium 1(Selenium RC)

介绍

正如您在Selenium项目简史中所读到的那样,Selenium RC长期以来一直是主要的Selenium项目,在WebDriver / Selenium合并之前推出了Selenium 2,这是最新,功能更强大的工具。

Selenium 1仍然受到积极支持(主要是在维护模式下)并提供一些功能,这些功能在Selenium 2中可能暂时不可用,包括支持多种语言(Java,Javascript,Ruby,PHP,Python,Perl和C#)和支持对于几乎所有的浏览器。

Selenium RC的工作

首先,我们将描述Selenium RC的组件如何运行以及每个组件在运行测试脚本中的作用。

RC组件

Selenium RC组件是:

  • 负责启动并关闭浏览器,解释并运行从测试程序传递的Selenese命令,充当HTTP代理,拦截和验证在浏览器和AUT之间传递的HTTP消息的Selenium Server。
  • 客户端库,提供每种编程语言和Selenium RC Server之间的接口。

Selenium服务器

Selenium Server从您的测试程序接收Sele

资料编号:[4452]

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。