sequence
This article mainly discusses the construction of Different Selenium WebDrivers
The Selenium 2.0
Selenium 2, also known as WebDriver, is a major new feature that integrates Selenium 1.0 with WebDriver, which was once Selenium’s competitor. In other words, Selenium 2 is a combination of Selenium and WebDriver projects. Selenium 2 is compatible with Selenium and supports both Selenium and WebDriver apis.
Supported Web drivers
- ChromeDriver
- EventFiringWebDriver
- FirefoxDriver
- HtmlUnitDriver
- InternetExplorerDriver
- PhantomJSDriver
- RemoteWebDriver
- SafariDriver
PhantomJS with Ghost Driver
Phantomis is a WebKit-based interface browser, and Ghost Driver is a JS implementation of Phantomis’s WebDriver Wire Protocol. Ghost Driver was later merged with PhantomJS and embedded in Phantomis, the equivalent of the phantomis = Ghost Driver + Phantomis browser
Driver features
chromedriver
The benefit of Chrome Driver is that it supports Mobile emulation
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);Copy the code
firefoxdriver(geckodriver
)
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false);
dcaps.setCapability(FirefoxDriver.PROFILE, profile);Copy the code
Firefox’s features look relatively weak
General Settings
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);Copy the code
doc
- webdriver