本文整理匯總了Java中org.openqa.selenium.Capabilities.getCapability方法的典型用法代碼示例。如果您正苦於以下問題:Java Capabilities.getCapability方法的具體用法?Java Capabilities.getCapability怎麽用?Java Capabilities.getCapability使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.Capabilities
的用法示例。
在下文中一共展示了Capabilities.getCapability方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
EdgeDriverManager.getInstance().version(driverVersion).setup();
return new EdgeDriver((EdgeOptions) capabilities);
}
示例2: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
ChromeDriverManager.getInstance().version(driverVersion).setup();
return new ChromeDriver((ChromeOptions) capabilities);
}
示例3: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
PhantomJsDriverManager.getInstance().version(driverVersion).setup();
return new PhantomJSDriver(capabilities);
}
示例4: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
OperaDriverManager.getInstance().version(driverVersion).setup();
return new OperaDriver((OperaOptions) capabilities);
}
示例5: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
InternetExplorerDriverManager.getInstance().version(driverVersion).setup();
return new InternetExplorerDriver((InternetExplorerOptions) capabilities);
}
示例6: createDriver
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
FirefoxDriverManager.getInstance().version(driverVersion).setup();
return new FirefoxDriver((FirefoxOptions) capabilities);
}
示例7: getBrowserVersion
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
public String getBrowserVersion() {
if (runContext.BrowserVersion.equalsIgnoreCase("default")) {
if (!runContext.Browser.equals((Browser.HtmlUnit))) {
String browser_version;
Capabilities cap;
if (driver instanceof ExtendedHtmlUnitDriver) {
cap = ((ExtendedHtmlUnitDriver) driver).getCapabilities();
} else if (driver instanceof MobileDriver) {
cap = ((RemoteWebDriver) driver).getCapabilities();
Object pV = cap.getCapability("platformVersion");
return pV == null ? "" : pV.toString();
} else if (driver instanceof RemoteWebDriver) {
cap = ((RemoteWebDriver) driver).getCapabilities();
} else {
return runContext.BrowserVersion;
}
String browsername = cap.getBrowserName();
// This block to find out IE Version number
if ("internet explorer".equalsIgnoreCase(browsername)) {
String uAgent = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");
// uAgent return as "MSIE 8.0 Windows" for IE8
if (uAgent.contains("MSIE") && uAgent.contains("Windows")) {
browser_version = uAgent.substring(uAgent.indexOf("MSIE") + 5, uAgent.indexOf("Windows") - 2);
} else if (uAgent.contains("Trident/7.0")) {
browser_version = "11.0";
} else {
browser_version = "0.0";
}
} else {
// Browser version for Firefox and Chrome
browser_version = cap.getVersion();
}
if (browser_version.contains(".") && browser_version.length() > 5) {
return browser_version.substring(0, browser_version.indexOf("."));
} else {
return browser_version;
}
}
}
return runContext.BrowserVersion;
}
示例8: getPlatformName
import org.openqa.selenium.Capabilities; //導入方法依賴的package包/類
public String getPlatformName() {
if (runContext.Platform.equals(Platform.ANY) || runContext.Platform.equals(Platform.getCurrent())) {
Capabilities cap;
if (driver instanceof ExtendedHtmlUnitDriver) {
cap = ((ExtendedHtmlUnitDriver) driver).getCapabilities();
} else if (driver instanceof MobileDriver) {
cap = ((RemoteWebDriver) driver).getCapabilities();
Object platf = cap.getCapability("platformName");
if (platf != null && !platf.toString().isEmpty()) {
return platf.toString();
} else {
return (driver instanceof AndroidDriver) ? "Android" : "IOS";
}
} else if (driver instanceof EmptyDriver) {
return "Any";
} else {
cap = ((RemoteWebDriver) driver).getCapabilities();
}
Platform p = cap.getPlatform();
if (p.name().equals(Platform.VISTA.name()) || p.name().equals(Platform.XP.name())
|| p.name().equals(Platform.WINDOWS.name()) || p.name().equals(Platform.WIN8.name())) {
switch (p.getMajorVersion() + "." + p.getMinorVersion()) {
case "5.1":
return "XP";
case "6.0":
return "VISTA";
case "6.1":
return "WIN7";
case "6.2":
return "WIN8";
case "6.3":
return "WIN8.1";
default:
return p.name();
}
} else {
return p.toString();
}
} else if (runContext.PlatformValue.equals("WINDOWS")) {
return "WIN";
} else {
return runContext.PlatformValue;
}
}