首先,安装并配置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 jararsselenium2-java环境搭建  示例为chrome浏览器
 
然后,新建测试编写代码,开始运行;运行报错“”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");
 
selenium2-java环境搭建  示例为chrome浏览器
 
运行结果,打开了浏览器并访问了正确的地址,就对了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2021-11-21
  • 2021-06-26
  • 2022-01-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-10-07
  • 2021-10-29
  • 2021-09-05
  • 2021-09-27
相关资源
相似解决方案