Selenium在Eclipse上驱动Chrome浏览器

Selenium在Eclipse上驱动Chrome浏览器

前提 Eclipse上配置好Selenium

  1. 参考https://editor.****.net/md/?articleId=105737920
  2. 下载Chrome浏览器驱动器
  3. 配置Chrome驱动器的环境变量,在系统变量中添加Path路径
    在Path路径最后,加入Chrome浏览器驱动的目录,例如F:\Driver
    Selenium在Eclipse上驱动Chrome浏览器
    Selenium在Eclipse上驱动Chrome浏览器
  4. 可以在cmd中输入chromedriver,启动驱动
    Selenium在Eclipse上驱动Chrome浏览器
  5. 在Eclipse上驱动浏览器
    WebDriver driver=new ChromeDriver();
    driver.get(“http:www.baidu.com”);
  6. 没有配置Chrome的默认环境变量时,可以手动添加驱动路径
    System.setProperty(“webdriver.chrome.driver”, “F:\Driver\chromedriver.exe”);