本文介绍了在不使用ANT,Maven,JUnit或Eclipse的情况下运行WebDriver测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以仅使用纯文本编辑器,Firefox浏览器,Java SDK和WebDriver JAR来运行Java中的WebDriver测试?

I would like to know if it's possible to run a WebDriver test in Java using just a plain text editor, Firefox browser, Java SDK and WebDriver JAR?

我试图提出一种最裸机"的方式来运行测试,而无需添加测试运行器,测试框架,依赖管理器.

I am trying to come up with the most "bare-metal" way to run a test without adding Test Runners, Test Frameworks, Dependency Managers into the mix.

我知道这不是做事的正确"方法,但是我正在尝试寻找一种方法来创建一种新型的WebDriver教程,该教程仅关注API.

I understand that this is not the "right" way to do things, but I am trying to find a way to create a new kind of WebDriver tutorial that will focus only on the API.

我现在正在使用OS X,但同样会赞赏Windows的使用说明.

I am using OS X right now but instructions for Windows would be equally appreciated.

推荐答案

运行WebDriver非常简单

Running WebDriver is as simple as

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {

public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

您唯一需要的是正确的类路径,它只是selenium-java-2.38.0.jar并且支持库,即:guava-15.0.jar json-20080701.jar commons-exec-1.1.jar httpcore-4.3.jar httpclient-4.3.1.jar commons-logging-1.1.1.jar

The only thing that you need is a correct classpath, which is just selenium-java-2.38.0.jar and supporting libraries, namely: guava-15.0.jar json-20080701.jar commons-exec-1.1.jar httpcore-4.3.jar httpclient-4.3.1.jar commons-logging-1.1.1.jar

或者,根据JimEvans,您可以下载独立的包含所有依赖项的selenium-server-standalone-2.40.0.jar .

Or, as per JimEvans, you can download standalone selenium-server-standalone-2.40.0.jar that has all dependencies included.

这篇关于在不使用ANT,Maven,JUnit或Eclipse的情况下运行WebDriver测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 13:45