本文整理汇总了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;
}
}