javascript 使用 Selenium 和 PhantomJS 测试 AngularJS 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21629969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 21:21:16  来源:igfitidea点击:

Testing AngularJS application using Selenium and PhantomJS

javascriptangularjsselenium-webdriverphantomjs

提问by Utpal

I want to test my AngularJS application using Selenium and PhantomJS, but I am not finding an easy to start resource or video tutorial. Can you please suggest some good resource as a starting point.

我想使用 Selenium 和 PhantomJS 测试我的 AngularJS 应用程序,但我找不到易于启动的资源或视频教程。您能否建议一些好的资源作为起点。

采纳答案by glepretre

As @Nima-Vaziri said, you should have a look at Karma to run unit tests on your app. This articlewill help you on this way.

正如@Nima-Vaziri 所说,您应该查看 Karma 以在您的应用程序上运行单元测试。本文将在此方面为您提供帮助。

Then to run e2e tests, the new runner developped by the Angular team is Protractor and you can start with this demo : Protractor demo

然后要运行 e2e 测试,Angular 团队开发的新运行器是 Protractor,您可以从这个演示开始:Protractor demo

To understand, these docs were very useful to me:

要理解,这些文档对我非常有用:

If you're going to work with AngularJS: you definitely should know about eggehead.io videos! This oneis about Protractor. But, there's a lot of video tutorials very interesting to teach you how to build an Angular app!

如果您打算使用 AngularJS:您绝对应该了解 eggehead.io 视频!是关于量角器的。但是,有很多非常有趣的视频教程可以教您如何构建 Angular 应用程序!

回答by Nima Vaziri

Have you looked at this tutorial?

你看过这个教程吗?

The tutorial itself seems decent. You might have to change some stuff depending on what you choose as your test-runner (this tutorial chose Mocha).

教程本身看起来不错。根据您选择的测试运行器(本教程选择 Mocha),您可能需要更改一些内容。

I'd also look at Karmaand Protractorwhich are built by the AngularJS team. Protractor is targeted more towards end-to-end testing in AngularJS apps.

我还会看看由 AngularJS 团队构建的KarmaProtractor。Protractor 更针对 AngularJS 应用程序中的端到端测试。

If you're set on Selenium, you could also look at Nightwatchjswhich is also end-to-end and runs against a Selenium server but requires Node.js. Nightwatchjs could be compared to Protractor but seems like it has easier-to-understand syntax.

如果您设置在 Selenium 上,您还可以查看Nightwatchjs,它也是端到端的并针对 Selenium 服务器运行,但需要 Node.js。Nightwatchjs 可以与 Protractor 进行比较,但似乎它的语法更容易理解。