use of org.openqa.selenium.remote.DesiredCapabilities in project webmagic by code4craft.
the class SeleniumTest method testSelenium.
@Ignore("need chrome driver")
@Test
public void testSelenium() {
System.getProperties().setProperty("webdriver.chrome.driver", "/Users/yihua/Downloads/chromedriver");
Map<String, Object> contentSettings = new HashMap<String, Object>();
contentSettings.put("images", 2);
Map<String, Object> preferences = new HashMap<String, Object>();
preferences.put("profile.default_content_settings", contentSettings);
DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.prefs", preferences);
caps.setCapability("chrome.switches", Arrays.asList("--user-data-dir=/Users/yihua/temp/chrome"));
WebDriver webDriver = new ChromeDriver(caps);
webDriver.get("http://huaban.com/");
WebElement webElement = webDriver.findElement(By.xpath("/html"));
System.out.println(webElement.getAttribute("outerHTML"));
webDriver.close();
}
use of org.openqa.selenium.remote.DesiredCapabilities in project Ebselen by Ardesco.
the class EbselenCore method setHTMLUnitCapabilities.
private DesiredCapabilities setHTMLUnitCapabilities(htmlUnitEmulation browserVersion) {
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setJavascriptEnabled(true);
switch(browserVersion) {
case FIREFOX:
capabilities.setBrowserName("firefox");
break;
case IE6:
capabilities.setBrowserName("internet explorer");
capabilities.setVersion("6");
break;
case IE7:
capabilities.setBrowserName("internet explorer");
capabilities.setVersion("7");
break;
case IE8:
capabilities.setBrowserName("internet explorer");
capabilities.setVersion("8");
break;
default:
break;
}
return capabilities;
}
use of org.openqa.selenium.remote.DesiredCapabilities in project page-factory-2 by sbtqa.
the class TagMobileDriver method createDriver.
private static void createDriver() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", PROPERTIES.getAppiumDeviceName());
capabilities.setCapability("platformVersion", PROPERTIES.getAppiumDevicePlatform());
capabilities.setCapability("appPackage", PROPERTIES.getAppiumAppPackage());
capabilities.setCapability("appActivity", PROPERTIES.getAppiumAppActivity());
capabilities.setCapability("autoGrantPermissions", "true");
capabilities.setCapability("unicodeKeyboard", "true");
capabilities.setCapability("resetKeyboard", "true");
LOG.info("Capabilities are {}", capabilities);
URL url;
try {
url = new URL(PROPERTIES.getAppiumUrl());
} catch (MalformedURLException e) {
throw new FactoryRuntimeException("Could not parse appium url. Check 'appium.url' property", e);
}
PageFactory.setAspectsEnabled(false);
LOG.debug("Aspect disabled");
mobileDriver = new AndroidDriver<>(url, capabilities);
LOG.info("Mobile driver created {}", mobileDriver);
deviceUdId = (String) mobileDriver.getSessionDetails().get("deviceUDID");
}
use of org.openqa.selenium.remote.DesiredCapabilities in project page-factory-2 by sbtqa.
the class TagWebDriver method createDriver.
private static void createDriver() throws UnsupportedBrowserException, MalformedURLException {
DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
if (!PROPERTIES.getProxy().isEmpty()) {
Proxy seleniumProxy = ProxyConfigurator.configureProxy();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
}
String browserName = getBrowserName();
capabilities.setBrowserName(browserName);
String webDriverUrl = PROPERTIES.getWebDriverUrl();
if (!webDriverUrl.isEmpty()) {
setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
} else {
if (browserName.equalsIgnoreCase(FIREFOX)) {
setWebDriver(new FirefoxDriver(capabilities));
} else if (browserName.equalsIgnoreCase(SAFARI)) {
setWebDriver(new SafariDriver(capabilities));
} else if (browserName.equalsIgnoreCase(CHROME)) {
WebDriverManagerConfigurator.configureDriver(ChromeDriverManager.getInstance(), CHROME);
setWebDriver(new ChromeDriver(capabilities));
} else if (browserName.equalsIgnoreCase(IE)) {
WebDriverManagerConfigurator.configureDriver(InternetExplorerDriverManager.getInstance(), IE);
setWebDriver(new InternetExplorerDriver(capabilities));
} else {
throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
}
}
webDriver.manage().timeouts().pageLoadTimeout(PageFactory.getTimeOutInSeconds(), TimeUnit.SECONDS);
setBrowserSize();
webDriver.get(PROPERTIES.getStartingUrl());
}
use of org.openqa.selenium.remote.DesiredCapabilities in project android by nextcloud.
the class Common method setUpCommonDriver.
protected AndroidDriver setUpCommonDriver() throws Exception {
File rootPath = new File(System.getProperty("user.dir"));
File appDir = new File(rootPath, "src/test/resources");
File app = new File(appDir, "ownCloud.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "test");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.owncloud.android");
capabilities.setCapability("appActivity", ".ui.activity.FileDisplayActivity");
capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(waitingTime, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, waitingTime, 50);
return driver;
}
Aggregations