Selenium is browser automation tool, for more information select this link.
We already have Selenium1.0, why Selenium2.0?
Selenium1.0 can't tackle following items.
1. Native keyboard and mouse events.
2. Same origin policy XSS/HTPP(S)
3. Pop-ups, dialogs (Basic authentication, Self signed certificates and File upload/download)
Selenium2.0 has cleaner API, webdriver and webelements object, better abstraction.
2 |
browser = webdriver.firefox() |
4 |
search_box_google = browser.find_element_name( 'q' )
|
Support of mobile devices- Android, iOS (Open web testing)
node.JS is server side JavaScript new programming language supported.
I have not seen Java Docs for Opera and Safari browsers.
Support for different types of mobile testing
1. Emulator.
2. Device connected to workstation.
3. Real device on real location on real network
Improved architecture.
Removing road blocks, hacks and workarounds
Scales up/down.
Selenium2 = Webdriver + Selenium1.0 (merging two different projects)
Lets understand the reason behind merging these two projects.
Selenium 1.0 - You can program in any language, but the prerequisite is that it should support HTTP library. It initially started as bucket of JavaScript, later Selenium RC(Remote Control) was introduced. RC is a headless Java serer that acts as a proxy server to send commands to to the Selenium Core (JavaScript program that is running in the browser, set of functions). RC receives commands from the test program, interprets them, report back the results of those tests to the test program. RC consist of Selenium core, that is inject into the browser using client library API when the test program opens the browser. Selenium core interprets the commands coming from the test program and execute selenese commands using browsers built-in JavaScript engine.
Selenium is the first open source browser based testing framework that quickly added support for new browsers as it is written in JavaScript.
Like any large project, Selenium is not perfect. As it is entirely written in JavaScript, which causes significant weakness. Every browser impose very strict security rules on the JavaScript being executed to protect the users from malicious scripts. This make testing harder for some scenarios. For example IE JavaScript security model don't allow to change the value of the INPUT file element for uploading the file and navigating between different domains ( same origin policy) .
As it is a mature product, Selenium APIs has grown over time and it becomes harder to understand how best to use it.
Webdriver project was created by Simon Stewart, it is a clean and fast framework for browser testing automation. Webdriver take different approach for the problems faced by selenium (discussed above). Rather than being a JavaScript application used in the browser, it uses whichever mechanism is most appropriate to control the browser. IE - C++ mainly using automation APIs, Firefox - JavaScript in a XPCOM component (Add-in) ,Chrome - ???.
By changing the mechanism used to control the browser we can overcome the JavaScript security model. When these techniques are not sufficient, Webdiver can use facilities provided by operating System, especially when user want to simulate inputs from the Keyboard and mouse. By using these techniques we are trying to simulate how a real user interact with the browser.
Webdriver had Object Base API when compared with the Selenium which as Directory based approach.
Webdriver JAVA API looks like this.
02 |
WebDriver driver = new FirefoxDriver();
|
08 |
WebElement searchBox = driver.findElement(By.name( "q" ));
|
09 |
searchBox.sendKeys( "selenium" );
|
12 |
System.out.println( "Title: " + driver.getTitle());
|
When these two frameworks are compared side by side, weakness of one framework is addressed by other.
Webdriver support for multiple browsers require lot of effort from the framework developers, where as selenium can be easily extended. Selenium always require real browser, but it can make use of Webdriver HTML unit driver which is very fast and light weight browser that execute in the system memory. Selenium solve most of the common situations in an automation testing, but Webdriver ability to support out side the JavaScript sandbox provides more interesting possibilities. Webdriver don't support parallel testing, where as Selenium has answer by using Selenium GRID (new GRID 2.0 require selenium server). Although this would not solve the limitations of existing Selenium JavaScript, but it would become easier to test broad range of browsers.
Webdriver APIs are used for driving the browsers as per the user requirement, every browser has most natural language "Best Fit" for driving it, so that each developer can develop the driver independently.
But there is a problem, a fix made to one driver don't guarantee that the same fix will resolve the issue in other drivers. Every programmer is good in his own language, Java programmer many not be efficient in writing C++ programs, this create lot of redundant work across the drivers and huge testing activity.
Now the team came up with the concept of Atoms, they have decided to merge the common code across the drivers so that maintenance and development is easy. What will be the common code across all the drivers? Querying the state of browser to find an element and getting attribute values from the page DOM is the major effort across the drivers, the best common language across all the browsers for accessing DOM is by using JavaScript and this is what Selenium Core consist of. Instead of loading the single large JavaScript file into the browser and creating burden on the browser engine. They have decided to break the code into chunks(i.e Atoms), compress the JavaScript with other tools and load it on demand. These atoms are common across all the drivers.
IE browser use C++ as best fit language, how do they pass atoms(JavaScript) to it? I think by placing it in header files.
Following are the drivers available in Selenium2.0 currently
AndroidDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, IPhoneSimulatorDriver, RemoteWebDriver
HTMLUnit driver is a pure Java driver that run in memory without displaying the browser on the screen. It use Rihno as JavaScript engine.
Selenium2 five minutes starting guide
Selenium2 documentation
Selenium2 webdriver new kid
Enjoy using Selenium 2.0 clean API.
分享到:
相关推荐
selenium-htmlunit-driver-2.9.0jar包 selenium-htmlunit-driver-2.9.0jar包 selenium-htmlunit-driver-2.9.0jar包 selenium-htmlunit-driver-2.9.0jar包
在实际应用中,使用Selenium-server-2.0进行自动化测试时,你需要安装相应的WebDriver驱动,如geckodriver(Firefox的WebDriver)。然后,你可以编写测试脚本,使用选择的语言(如Java)来创建WebDriver实例,启动...
在IT行业中,Selenium是一个广泛使用的自动化测试框架,主要用于Web应用程序的测试。它提供了一组强大的API,使得开发者能够用多种编程语言(如Java、Python、C#等)编写自动化测试脚本。在这个主题中,我们将深入...
使用selenium与webdriver打交道,是启动webdriver去调用浏览器,来完成操作。这就是selenium-chrome-driver-3.14.0.jar,作为chrome浏览器的webdriver,被selenium调用执行操作。
标题中的"selenium-2.0-dev-9341.tar.gz"表明这是一个Selenium的开发版本,版本号为2.0-dev,编号9341,且文件是使用tar.gz格式压缩的。Selenium是一个广泛使用的自动化测试工具,主要用于Web应用程序的测试。它支持...
selenium-firefox-driver-2.47.1.jar
4. **selenium-devtools-4.0.0-alpha-6-sources.jar** 和 **selenium-remote-driver-4.0.0-alpha-6-sources.jar**、**selenium-api-4.0.0-alpha-6-sources.jar**、**selenium-support-4.0.0-alpha-6-sources.jar**:...
【标题】"selenium-2.0-dev-9338.tar.gz" 是一个与Python相关的压缩包,其中包含了selenium库的一个开发版本,版本号为2.0-dev-9338。这个库主要用于自动化Web浏览器的测试,是Python开发者进行网页应用自动化测试的...
Selenium 是一款强大的自动化测试工具,尤其在Web应用程序的测试领域,它备受推崇。本文将深入探讨Selenium 2.0(也称为Selenium WebDriver)的开发版本9212,并分析其在Python环境中的应用。 Selenium 2.0的核心是...
总结来说,Selenium 2.0-dev-9310是Python测试者和开发者的重要资源,它提供了强大的Web自动化测试能力。无论是进行功能测试、回归测试还是性能测试,Selenium都能提供强大的支持。通过深入理解这个开发版本,开发者...
【标题】"selenium-2.0-dev-9340.tar...总的来说,"selenium-2.0-dev-9340.tar.gz" 包含的Python Selenium库是Web自动化测试的重要工具,其丰富的功能和强大的社区支持,使得开发者能够高效地对Web应用进行自动化测试。
1. **WebDriver**: 这部分包含了各个浏览器驱动(如 ChromeDriver、GeckoDriver)的实现,它们作为桥梁,使得 WebDriver API 能够与具体的浏览器进行交互。源码中会展示如何处理浏览器命令,以及如何与浏览器通信的...
【标题】"selenium-remote-driver-2.44.0.zip" 提供的是Selenium Remote Driver的一个旧版本,这是Selenium WebDriver库的一部分,用于控制浏览器进行自动化测试。Selenium WebDriver是一个开放源代码的API,它允许...
Selenium 是一个广泛使用的自动化测试工具,主要用于 Web 应用程序的测试,它支持多种编程语言,包括 Python。Python Selenium 库允许开发者通过编写 Python 代码来控制浏览器,执行各种交互操作,如点击、输入、...
【Selenium-Java 3.7.1.jar】是一个关键组件,主要用于自动化Web应用程序的测试。这个特定的版本,3.7.1,是Selenium WebDriver的一个Java绑定,它允许开发者使用Java语言来编写测试脚本,从而实现对浏览器的自动化...
Selenium是一款广泛使用的自动化测试工具,专为Web应用程序设计。它允许开发者编写脚本来模拟用户在浏览器上的操作,如点击、输入文本、导航等,从而进行功能测试、回归测试和性能测试。 描述中提到“py依赖包”,...
2. **selenium-java-2.0a7-srcs.jar**:这个文件包含了Selenium Java客户端驱动程序的源代码,对于开发者来说非常有用,因为它允许他们查看和理解内部的工作原理,便于调试、学习和扩展Selenium的功能。 3. **...
5. **selenium-chrome-driver-2.44.0.jar**,**selenium-firefox-driver-2.44.0.jar**,**selenium-ie-driver-2.44.0.jar** 等:这些是针对特定浏览器的驱动程序,如 ChromeDriver 和 FirefoxDriver,它们实现了 ...
selenium-chrome-driver-3.6.0.jar,chrome浏览器依赖包
Selenium是一款广泛应用于Web应用程序自动化测试的开源框架。它提供了多种编程语言的API,包括Java、Python、C#等,使得测试人员可以编写脚本来模拟用户在浏览器中的各种操作,如点击、输入、导航等。Selenium的核心...