为什么我们需要为Chrome和IE浏览器而不是Firefox浏览器设置系统属性 [英] Why do we need to set the System Property for Chrome And IE Browser and Not For Firefox Browser

查看:171
本文介绍了为什么我们需要为Chrome和IE浏览器而不是Firefox浏览器设置系统属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Chrome,

public class Chrome {

  public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
        WebDriver driver = new ChromeDriver();              
        driver.get("http://www.google.com");

    }

}

对于Firefox,

public class Firefox {

      public static void main(String[] args) {

            WebDriver driver = new FirefoxDriver();              
            driver.get("http://www.google.com");

        }

    }

为什么我们需要为Chrome和IE指定system.setProperty?

Why do we need to specify the system.setProperty for Chrome and IE?

推荐答案

我也有同样的问题,但在挖掘后发现,

I had also same question, but after digging I found,

WebDriver使用本机浏览器方法.硒提供内置 Firefox的驱动程序,但不适用于其他浏览器.所有驱动程序(Chrome浏览器 驱动程序,IE驱动程序等)是基于使用的特殊JS引擎构建的 每个浏览器.

WebDriver uses native browser approach. Selenium offers inbuilt driver for Firefox but not for other browsers. All drivers (Chrome Driver, IE driver, etc.) are built based on the special JS Engine used by each browser.

WebDriver与Mozilla Firefox一起很好地工作,因为它具有内置的驱动程序服务器.但是对于Internet Explorer和Google Chrome而言并非如此. Firefox是最传统的浏览器,因此Selenium WebDriver不需要在启动浏览器之前设置任何其他实用程序. Selenium程序包会自动引用firefox.exe的默认位置,因此用户无需设置任何其他属性.

Selenium WebDriver works very well with Mozilla Firefox because it has a built in driver server. But the same is not true for Internet Explorer and Google Chrome. Firefox is the most traditional browser, thus Selenium WebDriver do not require any additional utility to be set before launching the browser. The Selenium package automatically references towards the default location of the firefox.exe, thus the user need not to set any other property.

如果您获得了驱动程序可执行文件的路径,则必须由webdriver设置. IE.驱动程序系统属性"错误或与之类似的Chrome浏览器等效词,这意味着您需要在浏览器上安装驱动程序服务器.驱动程序服务器管理浏览器和Selenium Wire协议之间的调用.

If you ever get the "the path to the driver executable must be set by the webdriver. ie. driver system property" error or its similarly worded Chrome equivalent, it means that you need to install the driver servers on your browser. The driver server manages the calls between the browsers and the Selenium wire protocol.

InternetExplorerDriver是实现WebDriver的有线协议的独立服务器

The InternetExplorerDriver is a standalone server which implements WebDriver’s wire protocol

类似地,Google Chrome浏览器没有内置的服务器,因此您需要使用Chrome驱动程序服务器将Selenium代码传递到浏览器.您可以下载Chrome驱动程序服务器.

Similarly, Google Chrome doesn’t have a built-in server so you will need a Chrome driver server for communicating your Selenium code to the browser. You can download the Chrome driver server.

此处创建.

这篇关于为什么我们需要为Chrome和IE浏览器而不是Firefox浏览器设置系统属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆