本文主要讨论Selenium不一样webdriver的构造web
Selenium 2,又名 WebDriver,它的主要新功能是集成了 Selenium 1.0 以及 WebDriver(WebDriver 曾经是 Selenium 的竞争对手)。也就是说 Selenium 2 是 Selenium 和 WebDriver 两个项目的合并,即 Selenium 2 兼容 Selenium,它既支持 Selenium API 也支持 WebDriver API。chrome
phantomis就是一个基于webkit的无界面浏览器,而ghost driver是phantomis的WebDriver Wire Protocol的js实现。
后来ghost driver跟phantomjs合并在一块儿,内嵌在phantomis中,至关于如今的phantomis = ghost driver + phantomis浏览器浏览器
chrome driver的好处是支持mobile emulationiphone
Map<String, String> mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceName", "iphone 5"); Map<String, Object> chromeOptions = new HashMap<>(); chromeOptions.put("mobileEmulation", mobileEmulation); dcaps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
geckodriver
)FirefoxProfile profile = new FirefoxProfile(); profile.setEnableNativeEvents(true); profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(false); dcaps.setCapability(FirefoxDriver.PROFILE, profile);
firefox的功能看起来相对鸡肋一些firefox
LoggingPreferences logging = new LoggingPreferences(); logging.enable(LogType.PERFORMANCE, Level.ALL); logging.enable(LogType.BROWSER, Level.ALL); dcaps.setCapability(CapabilityType.LOGGING_PREFS, logging); dcaps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);