简体   繁体   English

为什么我们需要下载浏览器(IE,Chrome)驱动程序

[英]why we need to download browser(IE,Chrome) drivers

In order to execute test scripts on diff browsers, we download specific browser driver from seleniumhq.com and run the scripts. 为了在diff浏览器上执行测试脚本,我们从seleniumhq.com下载特定的浏览器驱动程序并运行脚本。

This code works fine as it should: 此代码可以正常工作:

System.setProperty("webdriver.ie.driver", "C:\\Users\\Public\\CIO\\resources\\iedriver.exe");

WebDriver driver = new InternetExplorerDriver();
driver.get("www.mywebsite.com");

When I already have IE Executable -'iexplore.exe' on my machine, can't selenium webdriver use that to launch IE? 当我的机器上已经有IE Executable -'iexplore.exe'时,selenium webdriver是否可以使用它来启动IE?

Why do we specifically download IEDriver from seleniumhq.com here? 为什么我们在这里专门从seleniumhq.com下载IEDriver

C:\Program Files\Internet Explorer\iexplore.exe

I tried to even setup that up and ran the program. 我试着设置它并运行程序。 Browser got launched with address as --port=1234/ however it could not navigate to respective website and eventually threw exception: 浏览器启动时的地址为--port=1234/但它无法导航到相应的网站并最终抛出异常:

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. 线程“main”中的异常org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。 Possible causes are invalid address of the remote server or browser start-up failure. 可能的原因是远程服务器的无效地址或浏览器启动失败。 Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:18' 构建信息:版本:'2.28.0',修订版:'18309',时间:'2012-12-11 20:21:18'

The "Browser Drivers" are servers that implement the WebDriver's wire protocol , and know how to convert those commands into the specific browser's proprietary native API. “浏览器驱动程序”是实现WebDriver 有线协议的服务器,并且知道如何将这些命令转换为特定浏览器的专有本机API。

The WebDriver site explains: WebDriver网站解释说:

Selenium-WebDriver makes direct calls to the browser using each browser's native support for automation. Selenium-WebDriver使用每个浏览器对自动化的本机支持直接调用浏览器。 How these direct calls are made, and the features they support depends on the browser you are using. 如何进行这些直接调用,以及它们支持的功能取决于您使用的浏览器。

For example, the ChromeDriver wiki describes it as follows: 例如, ChromeDriver wiki将其描述如下:

The ChromeDriver consists of three separate pieces. ChromeDriver由三个独立的部分组成。 There is the browser itself ("chrome"), the language bindings provided by the Selenium project ("the driver") and an executable downloaded from the Chromium project which acts as a bridge between "chrome" and the "driver". 有浏览器本身(“chrome”),Selenium项目提供的语言绑定(“驱动程序”)和从Chromium项目下载的可执行文件,它充当“chrome”和“driver”之间的桥梁。

Essentially, the browser doesn't know how to "talk" WebDriver Wire Protocol, and the WebDriver doesn't know how to "talk" Browser API. 从本质上讲,浏览器不知道如何“谈论”WebDriver Wire Protocol,而WebDriver不知道如何“对话”浏览器API。 In fact, each Browser has its own native API. 实际上,每个浏览器都有自己的原生API。 The "browser driver" knows how to interpret the Wire Protocol and invoke that browser's API. “浏览器驱动程序”知道如何解释有线协议并调用该浏览器的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM