yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
默认安装后执行文件路径是:
path.chrome: /usr/bin/google-chrome
2、linux下Chromedriver安装
这个只需要下载对应系统版本就可以了,注意:chrome版本和chromedriver版本对应关系(参考:下载地址中有notes.txt做介绍)
notes.txt
Chromedriver下载地址:http://npm./mirrors/chromedriver/
下载后复制到需要需要的目录就可以了,例如:
chrome-driver: /usr/bin/chromedriver
注意要给chromedriver可执行权限:chmod 777 chromedriver
3、java工程中使用创建Webdriver示例
* @return org.openqa.selenium.WebDriver public static WebDriver getOneFreeDriver(String queueName, boolean useProxy) throws IOException { WebDriver driver = driverQueue.poll(queueName); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("headless");//无界面参数 chromeOptions.addArguments("no-sandbox");//禁用沙盒 就是被这个参数搞了一天 chromeOptions.addExtensions(new File(Const.PROXY_EXTENSION_PATH)); DesiredCapabilities chromeCap = DesiredCapabilities.chrome().merge(chromeOptions); ChromeDriverService service = createChromeDriverService(); driver = new RemoteWebDriver(service.getUrl(), chromeCap); driver.manage().window().maximize();
linux下注意这几行:
chromeOptions.addArguments("headless");//无界面参数 chromeOptions.addArguments("no-sandbox");//禁用沙盒 就是被这个参数搞了一天
|