0

可能重复:
如何在 WebDriver 中初始化多个浏览器?

我如何为 IE 和 Chrome 配置文件。司机=新的firefoxDriver();工作正常,但驱动程序=新的 InterExploraDriver 或驱动程序=新的 ChromeDriver 无法正常工作。需要对 IE 和 Chrome 进行一些配置。我必须如何以及在哪里进行配置?Java中必要的代码是什么?

4

2 回答 2

1

You would need standalone servers for IE and Chrome in order to run your tests on those browsers. They can be found at

http://www.seleniumhq.org/download/

https://sites.google.com/a/chromium.org/chromedriver/downloads

Download those servers and place the path to the exe files and initialize the drivers as shown below:

IE

System.setProperty("webdriver.ie.driver", pathOftheexe);
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");

You would also need to set the Protected Mode settings for each security zone to be the same value. on IE, choose Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode". Keep this setting same for all zones i.e. either ON or OFF .

Chrome:

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

Please refer the following links for details:

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

于 2012-08-07T01:59:02.670 回答
0

您可以只使用 selenium-server-standalone.jar。将它添加到您的类路径中,您不必添加每个浏览器服务器。

于 2012-08-07T06:24:31.750 回答