可以使用 selenium 自动化 angularjs 应用程序吗?如果是,我们为什么要使用量角器? [英] Can angularjs apps be automated with selenium? if yes, why should we use protractor?

查看:14
本文介绍了可以使用 selenium 自动化 angularjs 应用程序吗?如果是,我们为什么要使用量角器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以使用 Selenium 自动化 AngularJs 应用程序.但是我们有一个单独的 E2E 测试框架,它是用于 AngularJs 应用自动化的 Protractor.

I know that we can automate AngularJs apps with Selenium. But we have a separate E2E testing framework that is Protractor for AngularJs apps automation.

谁能帮我理解为什么我们应该使用量角器?为什么不使用 Selenium?

Can anyone help me understand why we should use Protractor? Why not Selenium?

推荐答案

不确定我是否理解您的问题.我是否正确地假设您宁愿使用 Selenium - 但想了解您缺少什么?

Not sure I understand your question. Am I right to assume you'd rather use Selenium - but want to understand what you're missing?

嗯 - Selenium 提供了自动化 Web 浏览器的方法 - 因此用于自动化 e2e 测试.Selenium API 有多种主要编程语言的实现 - 允许您使用 Java、C#、python、ruby、JavaScript 等编写测试.

Well - Selenium provides means to automate web browsers - and thus used for automated e2e tests. Selenium API has implementations in several major programming languages - allowing you to write your tests in Java, C#, python, ruby, JavaScript and more.

如果您已经有一个基于 selenium 的 e2e 测试框架 - 您也可以将它用于 AngularJS 网络应用程序.您还可以编写必要的 JavaScript 脚本,一旦使用 webdriver 运行 - 将让您完成 Protractor 所做的所有事情 - 但您必须自己完成(只需借用 Protractor 源代码).

If you already have a selenium-based e2e testing framework in place - you can use it also for AngularJS web-apps. You can also write the necessary JavaScript scripts that, once ran using the webdriver - will let you do all that Protractor does - but you'll have to do it yourself (just borrow from Protractor source code).

为什么可行?因为 Protractor 基本上采用了 Selenium Webdriver 的 JavaScript 实现,并以一种让您在测试 Angular JS Web 应用程序时更轻松的方式包装了它.

Why is it doable? Because Protractor basically took the JavaScript implementation of Selenium Webdriver and wrapped it in a way that makes your life a bit easier when testing Angular JS web apps.

你可以在我的这个旧帖子中看到具体的解释:http://testautomation.applitools.com/post/94994807787/protractor-vs-selenium-哪个更容易

You can see specific explanations in this old post of mine: http://testautomation.applitools.com/post/94994807787/protractor-vs-selenium-which-is-easier

如果你:1.想用JavaScript写你的测试代码2. 主要专注于 Angular JS 应用程序

I'd say that if you: 1. want to write your test code in JavaScript 2. are focused on mainly Angular JS apps

您可能需要考虑使用 Protractor.再一次 - 那里没有魔法.他们所做的一切都在他们的源代码中 - 因此,如果您更愿意坚持使用 selenium,您可以自行选择.

You might want to consider using Protractor. Again - no magic there. Everything they did is there in their source code - so you can just take your picks if you'd rather stick with selenium.

这篇关于可以使用 selenium 自动化 angularjs 应用程序吗?如果是,我们为什么要使用量角器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆