量角器(Selenium webdriver)VS ghostdriver(phantomjs webdriver)有什么区别?

时间:2022-10-04 01:21:36

I would like to make it clear about the difference between protractor VS ghostdriver.

我想说清楚量角器VS ghostdriver之间的区别。

  1. With protractor:

    用量角器:

    • start selenium web server for testing.
    • 启动selenium web服务器进行测试。
    • multiple browser testing.
    • 多个浏览器测试。
    • whenever it start testing, it open the browser.
    • 无论何时开始测试,它都会打开浏览器。
  2. With ghostdriver:

    用ghostdriver:

    • start phantomjs web server.
    • 启动phantomjs Web服务器。
    • can be config multiple browser too.
    • 也可以配置多个浏览器。
    • can run separate with selenium or integrate with selenium.
    • 可与硒分开或与硒结合。

My question is PhantomJS webdriver can run alone without selenium webdriver, multiple browsers and good for CI. Why do we need to run selenium and integrate selenium with phantomjs using ghostdriver?

我的问题是PhantomJS webdriver可以单独运行,不需要selenium webdriver,多个浏览器和CI。为什么我们需要运行selenium并使用ghostdriver将selenium与phantomjs集成?

1 个解决方案

#1


8  

While I'm not entirely sure I understand your question, I'll take a stab at answering it. With WebDriver, driving a browser is done via a standardized JSON-over-HTTP wire protocol. This means that you need a "server" component that understands the wire protocol to drive any particular browser. For each of the major desktop browsers (Internet Explorer, Chrome, and Firefox), there is a server component that your WebDriver code talks to (IEDriverServer.exe, chromedriver.exe, or a Firefox browser extension, respectively). PhantomJS also implements a server component that understands the WebDriver wire protocol, so the same high-level WebDriver code can be used with PhantomJS that is used with other browsers. Note that the Selenium server is not required to drive any of the browsers on the local machine.

虽然我不完全确定我理解你的问题,但我会采取措施来回答它。使用WebDriver,通过标准化的JSON-over-HTTP线协议来驱动浏览器。这意味着您需要一个“服务器”组件,该组件了解有线驱动任何特定浏览器的有线协议。对于每个主要的桌面浏览器(Internet Explorer,Chrome和Firefox),都有一个WebDriver代码与之对话的服务器组件(分别是IEDriverServer.exe,chromedriver.exe或Firefox浏览器扩展)。 PhantomJS还实现了一个了解WebDriver有线协议的服务器组件,因此与其他浏览器一起使用的PhantomJS可以使用相同的高级WebDriver代码。请注意,Selenium服务器不需要驱动本地计算机上的任何浏览器。

Now, since the protocol used is simply transmitted over HTTP, that gives WebDriver the opportunity to run the WebDriver code on one machine, while driving a browser located on an entirely different machine. That's where the Selenium server comes in. The Selenium server starts an HTTP server that understands the WebDriver JSON wire protocol. When that server receives a WebDriver command, it can forward that command to another "server" component, either running on that machine (as a standalone remote server), or on yet another machine running another instance of the Selenium server (in a "grid" configuration).

现在,由于使用的协议只是通过HTTP传输,这使WebDriver有机会在一台机器上运行WebDriver代码,同时驱动位于完全不同的机器上的浏览器。这就是Selenium服务器的用武之地.Selenium服务器启动了一个了解WebDriver JSON有线协议的HTTP服务器。当该服务器收到WebDriver命令时,它可以将该命令转发到另一个“服务器”组件,该组件在该机器上运行(作为独立的远程服务器),或者运行另一个运行Selenium服务器实例的另一台机器(在“网格”中) “配置)。

So to answer your question, yes, WebDriver code can be executed against PhantomJS without using the Selenium server. It can likewise be executed against Internet Explorer, Firefox, Chrome, Safari, and some versions of Opera, all without using the Selenium server. Notice that all of this is true without mentioning Protractor at all. Since Protractor is based on WebDriverJS, as long as there's a "server" component running, whether that's a Selenium server, chromedriver.exe, IEDriverServer.exe, or PhantomJS, the driver should be able to communicate with and drive that browser. Looking at the code, it appears that WebDriverJS (and, by extension, Protractor), should be able to execute against Chrome and PhantomJS without requiring the Selenium server, but I don't know enough about Protractor's wrapping of WebDriverJS to speak with authority.

所以要回答你的问题,是的,可以在不使用Selenium服务器的情况下对PhantomJS执行WebDriver代码。它同样可以针对Internet Explorer,Firefox,Chrome,Safari和某些版本的Opera执行,所有这些都不使用Selenium服务器。请注意,所有这一切都是正确的,而根本没有提到量角器。由于Protractor基于WebDriverJS,只要运行“服务器”组件,无论是Selenium服务器,chromedriver.exe,IEDriverServer.exe还是PhantomJS,驱动程序都应该能够与该浏览器通信并驱动该浏览器。看一下代码,看起来WebDriverJS(以及扩展名为Protractor)应该能够在不需要Selenium服务器的情况下针对Chrome和PhantomJS执行,但是我对Protractor包装WebDriverJS与权威说话的了解不够。

#1


8  

While I'm not entirely sure I understand your question, I'll take a stab at answering it. With WebDriver, driving a browser is done via a standardized JSON-over-HTTP wire protocol. This means that you need a "server" component that understands the wire protocol to drive any particular browser. For each of the major desktop browsers (Internet Explorer, Chrome, and Firefox), there is a server component that your WebDriver code talks to (IEDriverServer.exe, chromedriver.exe, or a Firefox browser extension, respectively). PhantomJS also implements a server component that understands the WebDriver wire protocol, so the same high-level WebDriver code can be used with PhantomJS that is used with other browsers. Note that the Selenium server is not required to drive any of the browsers on the local machine.

虽然我不完全确定我理解你的问题,但我会采取措施来回答它。使用WebDriver,通过标准化的JSON-over-HTTP线协议来驱动浏览器。这意味着您需要一个“服务器”组件,该组件了解有线驱动任何特定浏览器的有线协议。对于每个主要的桌面浏览器(Internet Explorer,Chrome和Firefox),都有一个WebDriver代码与之对话的服务器组件(分别是IEDriverServer.exe,chromedriver.exe或Firefox浏览器扩展)。 PhantomJS还实现了一个了解WebDriver有线协议的服务器组件,因此与其他浏览器一起使用的PhantomJS可以使用相同的高级WebDriver代码。请注意,Selenium服务器不需要驱动本地计算机上的任何浏览器。

Now, since the protocol used is simply transmitted over HTTP, that gives WebDriver the opportunity to run the WebDriver code on one machine, while driving a browser located on an entirely different machine. That's where the Selenium server comes in. The Selenium server starts an HTTP server that understands the WebDriver JSON wire protocol. When that server receives a WebDriver command, it can forward that command to another "server" component, either running on that machine (as a standalone remote server), or on yet another machine running another instance of the Selenium server (in a "grid" configuration).

现在,由于使用的协议只是通过HTTP传输,这使WebDriver有机会在一台机器上运行WebDriver代码,同时驱动位于完全不同的机器上的浏览器。这就是Selenium服务器的用武之地.Selenium服务器启动了一个了解WebDriver JSON有线协议的HTTP服务器。当该服务器收到WebDriver命令时,它可以将该命令转发到另一个“服务器”组件,该组件在该机器上运行(作为独立的远程服务器),或者运行另一个运行Selenium服务器实例的另一台机器(在“网格”中) “配置)。

So to answer your question, yes, WebDriver code can be executed against PhantomJS without using the Selenium server. It can likewise be executed against Internet Explorer, Firefox, Chrome, Safari, and some versions of Opera, all without using the Selenium server. Notice that all of this is true without mentioning Protractor at all. Since Protractor is based on WebDriverJS, as long as there's a "server" component running, whether that's a Selenium server, chromedriver.exe, IEDriverServer.exe, or PhantomJS, the driver should be able to communicate with and drive that browser. Looking at the code, it appears that WebDriverJS (and, by extension, Protractor), should be able to execute against Chrome and PhantomJS without requiring the Selenium server, but I don't know enough about Protractor's wrapping of WebDriverJS to speak with authority.

所以要回答你的问题,是的,可以在不使用Selenium服务器的情况下对PhantomJS执行WebDriver代码。它同样可以针对Internet Explorer,Firefox,Chrome,Safari和某些版本的Opera执行,所有这些都不使用Selenium服务器。请注意,所有这一切都是正确的,而根本没有提到量角器。由于Protractor基于WebDriverJS,只要运行“服务器”组件,无论是Selenium服务器,chromedriver.exe,IEDriverServer.exe还是PhantomJS,驱动程序都应该能够与该浏览器通信并驱动该浏览器。看一下代码,看起来WebDriverJS(以及扩展名为Protractor)应该能够在不需要Selenium服务器的情况下针对Chrome和PhantomJS执行,但是我对Protractor包装WebDriverJS与权威说话的了解不够。