selenium 控制浏览器的功能在哪里?

Where does the functionality of selenium to control the browser lies in?

Selenium 的功能在哪里?

我在某处读到语言绑定或 API 提供了在 java 中使用 Selenium 的胶水代码。

胶水代码或绑定代码:连接不兼容软件组件的代码。

Jason Huggings 编写了 JavaScriptTestRunner 来控制浏览器。控制浏览器的功能位于 JavaScriptTestRunner 中。 它受到同源政策的影响。 Paul Hammant 创建了 HTTP 代理来绕过同源策略。这打开了用多种语言编写测试的大门。我们提供了 API 来编写测试。

然后创建WebDriver。 WebDriver 和 RC 合并形成 Selenium 2。

控制浏览器的功能去了哪里?

为什么API被称为胶水代码或绑定代码?它绑定了什么?

Selenium in the general usage of the term is a library - a collection of code organized in modules and packages. In this form it's a

Where does the functionality to control the browser gone to?

WebDriver protocol, .
Selenium 作为客户端使您能够以您选择的语言使用此功能 - 方便,您无需学习或直接 运行 WebDriver 请求并解析他们的响应。

Why does the API is called as glue code or binding code? What does it bind?

在编程中,绑定是库的统一/或明确定义的 API,它连接较低级别的代码(其他程序或 OS)或协议 - 在本例中为 WebDriver ,到更高层次的概念——你的代码。 Wikipedia to the rescue, with more details.

胶水代码

Glue Code is the executable code most often the source code that serves the purpose of adapting different parts of code that would otherwise be incompatible. Glue code does not contribute any functionality towards meeting any program requirements as such. Instead, it often appears in code that lets the existing libraries or programs to interoperate among themselves, as in language bindings or foreign function interfaces. Glue code may be written in the same language as the code it is gluing together, or in a separate glue language。胶水代码在 rapid 原型制作环境中非常有效,在这种环境中,多个组件被快速组合成一种语言或框架。


JavaScriptTestRunner

Jason Huggins 在 ThoughtWorks 测试内部应用程序时减少了手动逐步完成相同测试所需的时间,他在开发 Javascript 库时所做的每一项更改这可以推动与网页的交互,从而使他能够针对多个浏览器自动重新运行测试。他将这个程序命名为 JavaScriptTestRunner。后来,他做了JavaScriptTestRunner开源。该库最终成为 Selenium Core,它是 Selenium Remote Control (RC) and Selenium IDE.

所有功能的基础

不幸的是,要在 Same Origin Policy 中工作,Selenium Core 必须与 被测应用程序 (AUT)。因此,另一位 ThoughtWork 工程师 Paul Hammant 创建了一个服务器,该服务器将充当 HTTP 代理,在虚构的 URL 下屏蔽 AUT,嵌入 Selenium Core 和一组测试并像它们来自同一来源一样交付它们。该系统被称为 Selenium 远程控制 (Selenium RC)Selenium 1.


为什么要使用 HTTP 代理

同样,当 Web 框架变得越来越复杂和强大时,Web 浏览器的沙盒 Javascript 环境 的限制越来越限制 硒核心。 Simon 想要一个测试工具,它使用浏览器和操作系统的 "native" 方法直接与浏览器对话,从而避免沙盒 Javascript 环境的限制。那是在WebDriver and Selenium RC were merged to form Selenium 2. All implementations of WebDriver that communicate with web browsers started using a common wire protocol. This wire protocol defined the RESTful web service using .

的时候

结论

简而言之,控制浏览器的功能始终在 Javascript 库 中,该库 驱动与作为 [=37= 一部分的网页的交互]JavaScriptTestRunner 及更高版本 Selenium Core.

根据下图关于不同的 classes/interfaces 控制浏览器的功能是使用 selenium-api