1)Selenium Web driver
- mvn 部署
- copy pom.xml文件: http://seleniumhq.org/docs/03_webdriver.html#setting-up-a-selenium-webdriver-project
- mvn clean install
- mvn eclipse:eclipse
- 导入到eclipse: http://seleniumhq.org/docs/appendix_installing_java_driver_Sel20_via_maven.html#importing-maven-into-eclipse-reference
- 必要时安装m2e:http://www.sonatype.org/m2eclipse
- 直接下载jar:
- http://selenium.googlecode.com/files/selenium-java-2.25.0.zip (http://seleniumhq.org/download/)
- 启动 hub:
java -jar selenium-server-standalone-2.14.0.jar -role hub
- 启动 node:
java -jar selenium-server-standalone-2.14.0.jar -role hub
- 使用 RemoteWebDriver:
-
// We could use any driver for our tests... DesiredCapabilities capabilities = new DesiredCapabilities(); // ... but only if it supports javascript capabilities.setJavascriptEnabled(true); // Get a handle to the driver. This will throw an exception // if a matching driver cannot be located WebDriver driver = new RemoteWebDriver(capabilities); // Query the driver to find out more information Capabilities actualCapabilities = ((RemoteWebDriver) driver).getCapabilities(); // And now use it driver.get("http://www.google.com");
- 参考:http://code.google.com/p/selenium/wiki/RemoteWebDriver
-
HtmlUnit Driver最快,无UI的WebDriver,javascript引擎使用Rhino
WebDriver driver = new HtmlUnitDriver();
3)Selenium IDE
- 用export as 可以导出test case.
4)Python 接口
看例子中Python用法
driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.HTMLUNIT)推测非java语言都要通过http接口呼叫selenium-server来执行用例。