首先,安装并配置JDK,安装eclipse,安装firefox和chrome。下载selenium语言的JAVA库文件,下载地址为,如果打不开,则需要FQ;http://www.seleniumhq.org/download/;
其次, 在eclipse中新建项目,在新建项目中将下载的selenium的所有以 .jar为后缀的文件导入项目;导入方式:右键项目名-->build path-->config build path-->java build path-->libraries-->add External jarars
然后,新建测试编写代码,开始运行;运行报错“”Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases“” 因为是用的selenium3,所以需要在谷歌上下载驱动程序,下载地址https://github.com/mozilla/geckodriver/releases/tag/v0.9.0,根据系统版本选择。解压后放到chrome的浏览器按照目录,并添加代码System.setProperty("webdriver.chrome.marionette","C:\\Program Files (x86)\\Google\\Chrome\\Application\\geckodriver.exe");
运行结果,打开了浏览器并访问了正确的地址,就对了。