硒的重点是什么? [英] What's the Point of Selenium?

查看:28
本文介绍了硒的重点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,也许我遗漏了一些东西,但我真的不明白 Selenium 的意义.使用代码打开浏览器、使用代码单击按钮以及使用代码检查文本的意义何在?我阅读了该网站,我看到理论上自动对您的 Web 应用程序进行单元测试会很好,但最终编写所有这些代码需要更多的时间,而不仅仅是单击并直观地验证事情的工作?

Ok, maybe I'm missing something, but I really don't see the point of Selenium. What is the point of opening the browser using code, clicking buttons using code, and checking for text using code? I read the website and I see how in theory it would be good to automatically unit test your web applications, but in the end doesn't it just take much more time to write all this code rather than just clicking around and visually verifying things work?

我不明白...

推荐答案

它允许您在单元"测试框架中编写功能测试(问题在于后者的命名).

It allows you to write functional tests in your "unit" testing framework (the issue is the naming of the later).

当您通过浏览器测试您的应用程序时,您通常是在测试完全集成的系统.考虑到您必须在提交更改之前对其进行测试(冒烟测试),您不想一遍又一遍地手动测试它.

When you are testing your application through the browser you are usually testing the system fully integrated. Consider you already have to test your changes before committing them (smoke tests), you don't want to test it manually over and over.

非常棒的一点是,您可以自动进行冒烟测试,而 QA 可以增强这些测试.非常有效,因为它减少了重复工作并使整个团队更加紧密.

Something really nice, is that you can automate your smoke tests, and QA can augment those. Pretty effective, as it reduces duplication of efforts and gets the whole team closer.

Ps,因为您第一次使用的任何练习都有学习曲线,所以第一次通常需要更长的时间.我还建议您查看 Page Object 模式,它有助于保持测试干净.

Ps as any practice that you are using the first time it has a learning curve, so it usually takes longer the first times. I also suggest you look at the Page Object pattern, it helps on keeping the tests clean.

更新 1:请注意,测试还将在页面上运行 javascript,这有助于测试高度动态的页面.另请注意,您可以使用不同的浏览器运行它,因此您可以检查跨浏览器问题(至少在功能方面,因为您仍然需要检查视觉效果).

Update 1: Notice that the tests will also run javascript on the pages, which helps testing highly dynamic pages. Also note that you can run it with different browsers, so you can check cross-browser issues(at least on the functional side, as you still need to check the visual).

另请注意,随着测试覆盖的页面数量的增加,您可以快速创建具有完整交互周期的测试.使用页面对象模式,它们看起来像:

Also note that as the amount of pages covered by tests builds up, you can create tests with complete cycles of interactions quickly. Using the Page Object pattern they look like:

   LastPage aPage = somePage
      .SomeAction()
      .AnotherActionWithParams("somevalue")
      //... other actions
      .AnotherOneThatKeepsYouOnthePage(); 
  // add some asserts using methods that give you info
  // on LastPage (or that check the info is there).
  // you can of course break the statements to add additional 
  // asserts on the multi-steps story.

重要的是要了解您要循序渐进.如果它是一个已经构建的系统,您可以为您正在处理的功能/更改添加测试.在此过程中增加越来越多的覆盖范围.改为手动操作,通常会隐藏您错过的测试内容,因此如果您进行了影响每个页面的更改,并且您将检查一个子集(因为时间不允许),您就会知道您实际测试了哪些,并且 QA 可以使用那里(希望通过添加更多测试).

It is important to understand that you go gradual about this. If it is an already built system, you add tests for features/changes you are working on. Adding more and more coverage along the way. Going manual instead, usually hides what you missed to test, so if you made a change that affects every single page and you will check a subset (as time doesn't allows), you know which ones you actually tested and QA can work from there (hopefully by adding even more tests).

这篇关于硒的重点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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