您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium體系結構的疑惑及解答
作者:網(wǎng)絡轉載 發(fā)布時間:[ 2015/12/3 13:47:47 ] 推薦標簽:功能測試工具 軟件測試

  一直以來都覺得Selenium只是一個web browser自動化測試框架,但近實際使用中接觸到Appium,Selenium Server等以前沒接觸過的新的和selenium有關的工具,開始覺得Selenium不僅僅是一個browser自動化測試框架。因此去研究了一下Selenium官網(wǎng)的介紹及其歷史。
  疑惑的地方:
  Selenium既然是為了做瀏覽器自動化測試,為何會有Appium這樣的測試手機app的工具?
  Selenium Server、各種瀏覽器的Driver之間有什么關系?
  Selenium RC又是什么?
  解答步驟:
  Selenium的介紹:
  Selenium automates browsers. That’s it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.
  簡單地說,Selenium能實現(xiàn)瀏覽器自動化操作。它主要是以測試為目的來自動化web應用,但也可以做其他事情。好吧,這個對解答上面的疑惑沒有任何幫助
  Selenium歷史
  Selenium first came to life in 2004 when Jason Huggins was testing an internal application at ThoughtWorks. Being a smart guy, he realized there were better uses of his time than manually stepping through the same tests with every change he made. He developed a Javascript library that could drive interactions with the page, allowing him to automatically rerun tests against multiple browsers. That library eventually became Selenium Core, which underlies all the functionality of Selenium Remote Control (RC) and Selenium IDE. Selenium RC was ground-breaking because no other product allowed you to control a browser from a language of your choice.
  While Selenium was a tremendous tool, it wasn’t without its drawbacks. Because of its Javascript based automation engine and the security limitations browsers apply to Javascript, different things became impossible to do. To make things worse, webapps became more and more powerful over time, using all sorts of special features new browsers provide and making this restrictions more and more painful.
  In 2006 a plucky engineer at Google named Simon Stewart started work on a project he called WebDriver. Google had long been a heavy user of Selenium, but testers had to work around the limitations of the product. Simon wanted a testing tool that spoke directly to the browser using the ‘native’ method for the browser and operating system, thus avoiding the restrictions of a sandboxed Javascript environment. The WebDriver project began with the aim to solve the Selenium’ pain-points.
  Jump to 2008. The Beijing Olympics mark China’s arrival as a global power, massive mortgage default in the United States triggers the worst international recession since the Great Depression, The Dark Knight is viewed by every human (twice), still reeling from the untimely loss of Heath Ledger. But the most important story of that year was the merging of Selenium and WebDriver. Selenium had massive community and commercial support, but WebDriver was clearly the tool of the future. The joining of the two tools provided a common set of features for all users and brought some of the brightest minds in test automation under one roof. Perhaps the best explanation for why WebDriver and Selenium are merging was detailed by Simon Stewart, the creator of WebDriver, in a joint email to the WebDriver and Selenium community on August 6, 2009.
  “Why are the projects merging? Partly because webdriver addresses some shortcomings in selenium (by being able to bypass the JS sandbox, for example. And we’ve got a gorgeous API), partly because selenium addresses some shortcomings in webdriver (such as supporting a broader range of browsers) and partly because the main selenium contributors and I felt that it was the best way to offer users the best possible framework.”
  這里已經(jīng)解答了上面的幾個問題。在此說一下這段話的大意:
  Selenium在2004年由Jason Huggins在工作中創(chuàng)造出來。開始的目的是節(jié)省手工重復測試的時間,實現(xiàn)方式是javascript庫。
  但隨著web技術發(fā)展及瀏覽器對javascript的種種限制,javascript庫的結構導致Selenium越來越難以滿足自動化測試的需求。
  然后在2006年,Simon Stewart在google創(chuàng)建了WebDriver項目。Selenium在Google中非常普及,但它的局限性讓Simon產(chǎn)生讓測試工具直接調用瀏覽器的原生(Native)方法,來打破Selenium的局限性。WebDriver項目是為了解決Selenium的痛點而創(chuàng)建的。
  然后在2008年,Selenium和WebDriver合并了。合并后的Selenium是現(xiàn)在大家使用的Selenium2。合并的原因主要是:
  WebDriver解決了Selenium的缺點(例如突破JS沙箱,同時得到了一個清晰的API,也是我們使用的WebDriver API,支持多種語言)
  Selenium也解決了WebDriver的缺點(例如支持大量的瀏覽器)
  Selenium的貢獻者以及Simon本人都覺得融合是好的方案
  至此,解答了第一個問題:
  問:Selenium既然是為了做瀏覽器自動化測試,為何會有Appium這樣的測試手機app的工具?
  答:這是WebDriver融合后帶來的好處。因為WebDriver設計時是用一套統(tǒng)一的API來驅動不同的平臺,因此對于手機app這種有自己原生方法(Appium中使用的是iOS的UIAutomation,Android的UiAutomator或通過Selendroid使用Instrumentation)的應用平臺也是適用的。
  Selenium測試套件
  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 1’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 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.
  大意:
  Selenium2(也被稱為Selenium Webdriver),是目前主要使用的版本。
  Selenium1(也被稱為SeleniumRC, Selenium Remote Control),目前已經(jīng)被分離出來,且處于維護狀態(tài)。
  Selenium IDE(Integrated Development Environment)是一個編寫用例的原型工具,可以用來協(xié)助編寫用例原型。
  至此,解答了第三個問題:
  問:Selenium RC又是什么?
  答:Selenium RC是Selenium 1.0版本,現(xiàn)已主要被Selenium2取代,僅處于維護狀態(tài)。
  WebDriver和Selenium Server
  You may, or may not, need the Selenium Server, depending on how you intend to use Selenium-WebDriver. If you will be only using the WebDriver API you do not need the Selenium-Server. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server; WebDriver will run the browser directly.
  There are some reasons though to use the Selenium-Server with Selenium-WebDriver.
  ·You are using Selenium-Grid to distribute your tests over multiple machines or virtual machines (VMs).
  ·You want to connect to a remote machine that has a particular browser version that is not on your current machine.
  ·You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver
  大意:
  你并不一定需要Selenium Server,這取決于你如何使用Selenium-WebDriver。如果你只是為了使用WebDriver API,你不需要使用Selenium-Server。需要使用Selenium Server配合Selenium-WebDriver的場景主要有以下幾個:
  你使用了Selenium-Grid(可以理解為分布式的Selenium)在多臺機器或虛擬機上分發(fā)測試
  你希望連接到一臺擁有特定的、你目前機器上沒有的瀏覽器版本的遠程機器
  你沒有使用Java綁定(如Python, C#,Ruby)并希望使用HtmlUnit Driver。

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd