本文主要討論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);