zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

【总结】selenium webdriver 远程连接firefox和IE 环境搭建

连接 远程 环境 总结 搭建 selenium IE firefox
2023-09-14 08:58:56 时间

参考链接:http://code.google.com/p/selenium/wiki/Grid2 

本地环境为:win7,eclipse,jdk 1.7,本机ip为192.168.0.30

1.下载所需文件

1.1 下载好jar包,下载网址为:http://selenium.googlecode.com/files/selenium-server-standalone-2.37.0.jar 目前2.37为最新版本,或者直接点击官网 http://docs.seleniumhq.org/download/

 

Selenium Server (formerly the Selenium RC Server)

 

The Selenium Server is needed in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones. The 2.x server is a drop-in replacement for the old Selenium RC server and is designed to be backwards compatible with your existing infrastructure.

Download version 2.37.0

To use the Selenium Server in a Grid configuration see the wiki page.

点击2.37.0超链接即可下载。

1.2下载好IEDriverServer.exe,打开IE的驱动程序,这里选择32位的哦,64位的有bug.(系统是64位的用32位驱动也能启动IE)

 

 

The Internet Explorer Driver Server

This is required if you want to make use of the latest and greatest features of the WebDriver InternetExplorerDriver. Please make sure that this is available on your $PATH (or %PATH% on Windows) in order for the IE Driver to work as expected.

Download version 2.37.0 for (recommended) 32 bit Windows IE or 64 bit Windows IE
CHANGELOG

点击 32 bit Windows IE,即可下载,或者直接点击http://code.google.com/p/selenium/downloads/detail?name=IEDriverServer_Win32_2.37.0.zip 下载

 

 

2.把下载好的jar包随便放到一个目录下,编辑一个txt文件,然后把下面的代码改下,保存为.bat文件,双击之后即打开了selenium rc 的4444端口,程序即是从此调用开始的。

 打开firefox端口脚本如下: 

java -jar  D:\developsoft\Selenium_Test\selenium-server-standalone-2.35.0.jar -browser “browserName=firefox,version=25.0,firefox_binary=C:\Program Files\Mozilla Firefox\firefox.exe,maxInstances=5, platform=WINDOWS”

 打开IE端口脚本如下: 

java -Dwebdriver.ie.driver=D:\developsoft\Selenium_Test\IEDriverServer.exe -jar D:\developsoft\Selenium_Test\selenium-server-standalone-2.35.0.jar -mode hub

   

3.java程序配置连接设置情况:

     firefox程序配置如下:

           DesiredCapabilities ffCapabilities = DesiredCapabilities.firefox();
            	webDriver = new RemoteWebDriver(new URL("http://192.168.0.30:4444/wd/hub"), ffCapabilities);//在另一台电脑上打开本机即可。

  ie程序配置如下: 

     DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); //internetExplorer
     	ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        webDriver = new RemoteWebDriver(new URL("http://192.168.0.30:4444/wd/hub"), DesiredCapabilities.internetExplorer());

  

 

4.可以开始写测试脚本程序了

这里只是讲环境搭建,就不举实例了,如有问题欢迎留言。