我创建了一个在 Chrome 浏览器中完美运行的 selenium 脚本。为了让它运行,我浏览了一些以前的答案并下载了“ChromeDriver.exe”文件并在代码中添加了路径,它工作正常,但我的问题是为什么我们必须下载这个 exe 以及它的作用?
我在互联网上浏览了一些文章,但我不清楚。文章说 ChromeDriver 是“有线协议(protocol)”的实现,并且 Webdriver 在执行脚本时与 ChromeDriver 对话。如果是这样,它在做什么?
一些专家可以提出一些指示以更清楚地说明这一点吗?
最佳答案
ChromeDriver 文档的“getting start”给出了明确的答案。
ChromeDriver is a separate executable that WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. [...] The ChromeDriver class starts the ChromeDriver server process at creation and terminates it when quit is called. [...]
看到这个answer from the Chrome Driver users group其中包括对 chromedriver.exe 如何与 Chrome 浏览器进行通信的高级描述。
[...] ChromeDriver implements the WebDriver protocol, which is a REST-like interface [...]. WebDriver clients communicate with ChromeDriver by sending HTTP requests. ChromeDriver then communicates with the browser through the DevTools remote debugging interface, which is a WebSockets interface [...].
关于selenium - WebDriver、ChromeDriver 和 Browser 之间如何通信?什么是 WIRE 协议(protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38312546/