当前位置: 首页>>代码示例>>Java>>正文


Java DesiredCapabilities.setBrowserName方法代码示例

本文整理汇总了Java中org.openqa.selenium.remote.DesiredCapabilities.setBrowserName方法的典型用法代码示例。如果您正苦于以下问题:Java DesiredCapabilities.setBrowserName方法的具体用法?Java DesiredCapabilities.setBrowserName怎么用?Java DesiredCapabilities.setBrowserName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.remote.DesiredCapabilities的用法示例。


在下文中一共展示了DesiredCapabilities.setBrowserName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: capabilitiesInternetExplorer

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
private static DesiredCapabilities capabilitiesInternetExplorer() {

		DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
		final String ieDriverPath = (applicationIeDriverPath == null)
				? "c:/java/selenium/IEDriverServer.exe" : applicationIeDriverPath;
		System.setProperty("webdriver.ie.driver", ieDriverPath
		/* (new File(ieDriverPath)).getAbsolutePath() */);
		capabilities.setCapability(
				InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
				true);
		capabilities.setCapability("ignoreZoomSetting", true);
		capabilities.setCapability("ignoreProtectedModeSettings", true);
		capabilities.setCapability("requireWindowFocus", true);
		capabilities.setBrowserName(
				DesiredCapabilities.internetExplorer().getBrowserName());
		return capabilities;
	}
 
开发者ID:sergueik,项目名称:SWET,代码行数:18,代码来源:BrowserDriver.java

示例2: createDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
 * Создание instance google chrome эмулирующего работу на мобильном устройстве (по умолчанию nexus 5)
 * Мобильное устройство может быть задано через системные переменные
 *
 * @param capabilities настройки Chrome браузера
 * @return возвращает новый instance Chrome драйера
 */

@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    log.info("---------------run CustomMobileDriver---------------------");
    String mobileDeviceName = loadSystemPropertyOrDefault("device", "Nexus 5");
    Map<String, String> mobileEmulation = new HashMap<>();
    mobileEmulation.put("deviceName", mobileDeviceName);

    Map<String, Object> chromeOptions = new HashMap<>();
    chromeOptions.put("mobileEmulation", mobileEmulation);

    DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
    desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
    desiredCapabilities.setBrowserName(desiredCapabilities.chrome().getBrowserName());
    return new ChromeDriver(desiredCapabilities);
}
 
开发者ID:alfa-laboratory,项目名称:akita,代码行数:24,代码来源:MobileChrome.java

示例3: defaultConfiguration

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
default Capabilities defaultConfiguration(final XmlConfig config) {
    final DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(config.getBrowser());
    capabilities.setVersion(config.getVersion());
    capabilities.setPlatform(config.getPlatform());
    return capabilities;
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:8,代码来源:Browser.java

示例4: createDriver

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
public static WebDriver createDriver(Browser browser, DesiredCapabilities capabilities) {
    capabilities.setBrowserName(browser.toString().toLowerCase());
    return browser.initialize(capabilities);
}
 
开发者ID:endless-qa,项目名称:webdriver-examples-java,代码行数:5,代码来源:BrowserProvider.java

示例5: createCapabilities

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
/**
 * Creates a Capabilities object based on the given Browser object.
 *
 * @param browser Browser
 * @param testName name for individual test case
 * @return Capabilities
 */
private static Capabilities createCapabilities(Browser browser, String testName) {

  DesiredCapabilities capabilities = new DesiredCapabilities();

  capabilities.setBrowserName(browser.getBrowserName());
  if (browser.getVersion() != null)
    capabilities.setVersion(browser.getVersion());
  if (browser.getPlatform() != null)
    capabilities.setCapability("platform", browser.getPlatform());
  // Remote test identifier
  capabilities.setCapability("name", testName);

  switch (browser.getBrowserName()) {
    case "chrome":
      // capabilities = DesiredCapabilities.chrome();
      ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.addArguments("use-fake-ui-for-media-stream");
      chromeOptions.addArguments("use-fake-device-for-media-stream");
      /*
       * chromeOptions.addArguments("no-sandbox"); chromeOptions.addArguments("disable-infobars");
       * chromeOptions.addArguments("test-type=browser");
       * chromeOptions.addArguments("disable-extensions");
       * chromeOptions.addArguments("--js-flags=--expose-gc");
       * chromeOptions.addArguments("--disable-default-apps");
       * chromeOptions.addArguments("--disable-popup-blocking");
       * chromeOptions.addArguments("--enable-precise-memory-info");
       */
      capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
      break;
    case "firefox":
      // capabilities = DesiredCapabilities.firefox();
      FirefoxProfile firefoxProfile = new FirefoxProfile();
      firefoxProfile.setPreference("media.navigator.streams.fake", true);
      FirefoxOptions firefoxOptions = new FirefoxOptions();
      firefoxOptions.setProfile(firefoxProfile);
      capabilities.merge(firefoxOptions.toCapabilities());
      /*
       * capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
       */
      break;
    case "MicrosoftEdge":
      // capabilities = DesiredCapabilities.edge();
      capabilities.setCapability("avoidProxy", true);
      break;
    case "safari":
      // capabilities = DesiredCapabilities.safari();
      SafariOptions options = new SafariOptions();
      options.setUseTechnologyPreview(true);
      capabilities.setCapability(SafariOptions.CAPABILITY, options);
      break;
  }

  // Capabilities for mobile browsers
  Mobile mobile = browser.getMobile();
  if (mobile != null) {
    capabilities.setCapability("deviceName", mobile.getDeviceName());
    capabilities.setCapability("platformName", mobile.getPlatformName());
    capabilities.setCapability("platformVersion", mobile.getPlatformVersion());
    if (mobile.getPlatformName().equalsIgnoreCase("iOS")) {
      capabilities.setCapability("automationName", "XCUITest");
    } else {
      capabilities.setCapability("autoGrantPermissions", true);
      capabilities.setCapability("noReset", true);
    }
  }

  return capabilities;

}
 
开发者ID:webrtc,项目名称:KITE,代码行数:77,代码来源:WebDriverFactory.java

示例6: capabilitiesFirefox

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static DesiredCapabilities capabilitiesFirefox() {

	final String geckoDriverPath = (applicationGeckoDriverPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/java/selenium/geckodriver.exe" : "/var/run/geckodriver"
			: applicationGeckoDriverPath;
	// firefox.browser.path
	final String firefoxBrowserPath = (applicationFirefoxBrowserPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/Program Files (x86)/Mozilla Firefox/firefox.exe"
					: osName.toLowerCase().startsWith("mac")
							? "/Applications/Firefox.app/Contents/MacOS/firefox.bin"
							: "/usr/bin/firefox/firefox"
			: applicationFirefoxBrowserPath;
	System.setProperty("webdriver.gecko.driver",
			new File(geckoDriverPath).getAbsolutePath());
	System.setProperty("webdriver.firefox.bin",
			new File(firefoxBrowserPath).getAbsolutePath());
	System.setProperty("webdriver.reap_profile", "false");
	DesiredCapabilities capabilities = DesiredCapabilities.firefox();

	// TODO: switch to Selenium 3.X+
	/*
	FirefoxOptions firefoxOptions = new FirefoxOptions();
	firefoxOptions.setBinary(new File(firefoxBrowserPath).getAbsolutePath());
	
	capabilities.setCapability("moz:firefoxOptions", firefoxOptions);
	*/
	capabilities.setCapability("firefox_binary",
			new File(firefoxBrowserPath).getAbsolutePath());

	capabilities.setCapability("marionette", false);
	FirefoxProfile profile = new FirefoxProfile();
	// no longer exists in Selenium
	// profile.setEnableNativeEvents(true);
	profile.setAcceptUntrustedCertificates(true);
	profile.setAssumeUntrustedCertificateIssuer(false);

	// Disable Firefox Auto-Updating
	profile.setPreference("app.update.auto", false);
	profile.setPreference("app.update.enabled", false);

	capabilities.setCapability(FirefoxDriver.PROFILE, profile);
	capabilities.setCapability("elementScrollBehavior", 1);
	capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
	return capabilities;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:49,代码来源:BrowserDriver.java

示例7: addDesiredCapabilities

import org.openqa.selenium.remote.DesiredCapabilities; //导入方法依赖的package包/类
@Override
public void addDesiredCapabilities(DesiredCapabilities desiredCapabilities) {
    desiredCapabilities.setCapability("applicationCacheEnabled", false);
    desiredCapabilities.setJavascriptEnabled(true);
    desiredCapabilities.setBrowserName("firefox");
}
 
开发者ID:willhaben,项目名称:willtest,代码行数:7,代码来源:DefaultFirefoxConfigurationParticipant.java


注:本文中的org.openqa.selenium.remote.DesiredCapabilities.setBrowserName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。