VS硒的HtmlUnit?
我想了解测试框架更好,一直在寻找到硒。我用 的HtmlUnit之前,主要是当我需要一些刮关信息的网站或喜欢。
I am trying to understand testing framework better and been looking into Selenium. I've used HTMLUnit before, mainly when I needed to scrape some information off website or the likes.
在写作测试自动化的背景下,什么是硒的优势/劣势VS的HtmlUnit?在我看来硒是更复杂的设置比的HtmlUnit,但同时有一个为硒我认为行为完全相同的方式为自己的HtmlUnit一个HTMLUnitDriver?
In the context of writing test automation, what's the advantage / disadvantages of Selenium vs HTMLUnit? Looks to me Selenium is more complicated to set up than HTMLUnit, although at the same time there's a HTMLUnitDriver for Selenium which I think behave the exact same way as in HTMLUnit itself?
硒显然提供了更强有力的框架,它具有硒的RC pararel测试,它也有可以使用不同的浏览器驱动程序 - 尽管当您使用的浏览器驱动程序,测试将真正开启/关闭浏览器应用程序,而不是无头。
Selenium obviously provides more robust framework, it has the Selenium RC for pararel testing, it also has different browser drivers that can be used - although when you used the browser drivers, the test will actually open/close a browser application rather than headless.
可能是我没有理解正确硒。某些方向和指针将是巨大的!
May be I am not understanding Selenium correctly. Some directions and pointers would be great!
另外要注意的 - 一个单独的问题 - 我还期待着在移动浏览器做自动化测试,我发现硒具有的 IPhoneDriver 它,但后来这不是一个无头的测试要么因为它需要实际的iOS模拟器。
On another note - a separate question - I am also looking at doing automated testing on mobile browser, I see that Selenium has an IPhoneDriver for it, but then this is not a headless testing either as it requires actual iOS simulator.
反正有做移动网站上的无头测试?将改变用户代理是足够的?我看到周围不断变化的用户代理了几个帖子,似乎有自己的挑战,如: 设置用户代理硒RC
Is there anyway to do headless testing on mobile sites? Would changing user-agent be sufficient? I've seen a couple posts around changing user-agent that seem to have their own challenges, eg. Set user-agent in Selenium RC
非常感谢!
很好,会尽量详细解释差异。
well, would try to explain differences in detail.
在谈到并行测试,它更好地使用硒电网。
硒RC和硒电网的基本概念。
你可以得到更多的细节这里
Speaking about parallel testing, it better to use selenium grid. Basic concept of selenium RC and selenium grid. You can get into more details here
有关的某些单词的硒的webdriver
的硒2.0的主要新特性是webdriver的API的整合。的webdriver被设计为与所述硒-RC API中处理一些限制沿提供一个更简单的,更简洁的编程接口。硒的webdriver的开发是为了更好地支持动态网页,其中一个页面元素可能更改,恕不本身被重新加载页面。的webdriver的目标是提供一个设计良好的面向对象的API,它提供了现代先进的web应用程序的测试问题的改进支持。的
如何webdriver的驱动器的浏览器相比,硒-RC?
的硒的webdriver使得使用自动化每个浏览器的原生支持,浏览器直接调用。这些直接调用是如何制造的,他们支持的功能取决于您所使用的浏览器。每个浏览器驾驶员信息本章稍后提供。
对于那些熟悉硒-RC,这与你所习惯的大不相同。硒-RC的工作以同样的方式为每个支持的浏览器。它注入JavaScript函数到时,浏览器加载,然后用它的JavaScript在浏览器内驱动AUT浏览器。 webdriver的不使用这种技术。再次,它驱动直接使用浏览器浏览器的内置支持自动化。的
的webdriver和硒服务器
的您可能会或可能不会,需要Selenium服务器,这取决于你打算如何使用硒的webdriver。如果你只使用webdriver的API是你并不需要硒的服务器。如果你的浏览器和测试都将在同一台机器上运行,你的测试只使用webdriver的API,那么你并不需要运行硒服务器;的webdriver将直接运行浏览器。
有一些原因,虽然用硒服务器与硒的webdriver。的
- 您正在使用硒网格分发到多个你的测试
机或虚拟机(VM)。 - 您想要连接到具有特定浏览器的远程计算机
版本,是不是你的当前机器上。 - 您没有使用Java绑定(即Python和C#或Ruby)和
想可以使用HtmlUnit驱动程序
硒的webdriver的驱动程序
的webdriver是针对它测试应写入键接口的名称,但也有几个实现。这些措施包括:的
驱动的HtmlUnit
这是目前最快,最轻量级实现的webdriver的。顾名思义,这是基于的HtmlUnit。是的HtmlUnit一个基于java实现web浏览器中没有一个GUI。对于任何语言绑定(Java以外)Selenium服务器需要使用该驱动程序。
HtmlUnit Driver This is currently the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. HtmlUnit is a java based implementation of a WebBrowser without a GUI. For any language binding (other than java) the Selenium Server is required to use this driver.
赞成
- 实施最快的的webdriver
- 一个纯Java的解决方案,所以它是独立的平台。
- 支持JavaScript
反对
- C仿真等浏览器的JavaScript的行为(见下文)
的 JavaScript中的驱动程序的HtmlUnit
主流浏览器都没有使用由的HtmlUnit(犀牛)所使用的JavaScript引擎。如果您使用的HtmlUnit测试JavaScript的结果可能与浏览器显著不同。
当我们说的JavaScript我们实际上是指JavaScript和DOM。虽然DOM是由W3C定义的每个浏览器都有自己的怪癖,并在执行的DOM和JavaScript中如何与它进行交互的差异。 HtmlUnit的DOM中的IM pressively完整的实现,并有使用JavaScript很好的支持,但它是从其他浏览器没有什么不同:它有自己的怪癖和来自W3C的标准和主要的DOM实现差异浏览器,尽管它模仿其他浏览器的能力。
有了webdriver的,我们必须做出选择;我们做的HtmlUnit启用的JavaScript功能和运行运行到,只有体现自己存在的问题团队的风险,还是我们离开禁用JavaScript,知道有一些依赖于JavaScript越来越多的网站?我们采取了保守的做法,并默认禁用了支持,当我们可以使用HtmlUnit。与这两个和的webdriver中的HtmlUnit每一个版本中,我们重新评估这一决定:我们希望在在某个时刻化的HtmlUnit默认启用的JavaScript 的
要探讨更深入的webdriver的设置请参阅这
To investigate deeper into webDriver's setUp see this
文档的HtmlUnit :
的HtmlUnit不是一个普通的单元测试框架。它是专为模拟用于测试目的的浏览器的方式,并旨在被另一个测试框架如JUnit或TestNG的内使用。的
所以缔结硒和差异的HtmlUnit :
的HtmlUnit是一个没有GUI 和的方式来模拟用于测试的浏览器的和的硒的webdriver使直接调用浏览器中使用基于Java的实现web浏览器的自动化每个浏览器的原生支持。的我们可以看到,提供的HtmlUnit API,而GUI可能性自动化而webdriver的自动化提供内部浏览器的可能性。
So to conclude Selenium and HtmlUnit difference: HtmlUnit is a java based implementation of a WebBrowser without a GUI and a way to simulate a browser for testing purposes and Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation. we can see that HtmlUnit provides API without GUI possibility for automation whereas WebDriver provides internal browsers' possibilities for automation.
在谈到移动自动化,
硒也有一个iPhone司机
iPhone驱动wiki文章
和Android驱动程序
Android的驱动程序wiki文章
又见this presentation
不幸的是我不能给你我的手机驱动程序的工作经验评价,因为我处理网络自动化(无移动)。也知道黄瓜
(自动化工具)是流行的移动自动化工程师之一。
看到这并的此。
Unfortunately I can not give you my working experience evaluation of mobile drivers as I deal with web automation (no mobile). Also know that Cucumber
(automation tool) is popular among mobile automators.
see this and this.
希望现在来为你更加清晰律位=)
Hope it come a lil bit more clear for you now =)