选择三种做为介绍:
一、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。