当前位置: 代码迷 >> Web前端 >> selenium WebDriver 浏览器发动机
  详细解决方案

selenium WebDriver 浏览器发动机

热度:561   发布时间:2012-09-07 10:38:15.0
selenium WebDriver 浏览器引擎

选择三种做为介绍:

一、Firefox Driver

引入方式:

WebDriver driver = new FirefoxDriver();

二、InternetExplorer Driver

引入方式1:

WebDriver driver = new InternetExplorerDriver();

对于报错,采用方式2:

?

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); 
		ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); 
		driver = new InternetExplorerDriver(ieCapabilities);

?

三、Chrome Driver?

引入方式1:

WebDriver driver = new ChromeDriver()

?

对于报错,采用方式2:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
		capabilities.setCapability("chrome.binary", "/opt/google/chrome/chromedriver");
		driver = new ChromeDriver(capabilities);

?

注:Firefox Driver速度较慢。对于https的页面,需要安装安全证书,要不然会找不到客户端cookie。

  相关解决方案