org.openqa.selenium.remote.DesiredCapabilities Java Examples
The following examples show how to use
org.openqa.selenium.remote.DesiredCapabilities.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebDriverTypeTests.java From vividus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private static DesiredCapabilities testGetFirefoxWebDriver(WebDriverConfiguration configuration) throws Exception { DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); FirefoxOptions firefoxOptions = new FirefoxOptions(); whenNew(FirefoxOptions.class).withArguments(desiredCapabilities).thenReturn(firefoxOptions); whenNew(FirefoxOptions.class).withNoArguments().thenReturn(firefoxOptions); FirefoxDriver expected = mock(FirefoxDriver.class); whenNew(FirefoxDriver.class).withParameterTypes(FirefoxOptions.class).withArguments(firefoxOptions) .thenReturn(expected); WebDriver actual = WebDriverType.FIREFOX.getWebDriver(desiredCapabilities, configuration); assertEquals(expected, actual); Map<String, Object> options = (Map<String, Object>) desiredCapabilities .getCapability(FirefoxOptions.FIREFOX_OPTIONS); Map<String, Object> prefs = (Map<String, Object>) options.get("prefs"); assertEquals("about:blank", prefs.get("startup.homepage_welcome_url.additional")); return desiredCapabilities; }
Example #2
Source File: AppiumAndroidTest.java From candybean with GNU Affero General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { // set up appium DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android"); capabilities.setCapability(CapabilityType.VERSION, "4.2.2"); capabilities.setCapability("device", "Android"); capabilities.setCapability(CapabilityType.PLATFORM, "Mac"); capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/TestApp.apk.zip"); capabilities.setCapability("app-package", "com.example.TestApp"); capabilities.setCapability("app-activity", "MyActivity"); driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); values = new ArrayList<>(); }
Example #3
Source File: BaseTest.java From test-samples with Apache License 2.0 | 6 votes |
private void setupRemoteDriver(String device, String xmlTestName) throws MalformedURLException { loadProperties(device); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("bitbar_apiKey", "<YOUR_BITBAR_API_KEY>"); capabilities.setCapability("bitbar_testrun", this.getClass().getSimpleName()); capabilities.setCapability("bitbar_project", xmlTestName); capabilities.setCapability("bitbar_device", bitbarDevice); capabilities.setCapability("browserName", browserName); capabilities.setCapability("platformName", platformName); capabilities.setCapability("deviceName", deviceName); if (automationName != null) capabilities.setCapability("automationName", automationName); driver.set(new RemoteWebDriver(new URL("https://appium.bitbar.com/wd/hub/"), capabilities)); }
Example #4
Source File: RemoteDesiredCapabilitiesFactory.java From jmeter-plugins-webdriver with Apache License 2.0 | 6 votes |
public static DesiredCapabilities build(RemoteCapability capability){ DesiredCapabilities desiredCapabilities; if(RemoteCapability.CHROME.equals(capability)){ ChromeOptions options = new ChromeOptions(); desiredCapabilities = DesiredCapabilities.chrome(); desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options); return desiredCapabilities; } else if (RemoteCapability.FIREFOX.equals(capability)){ FirefoxProfile profile = new FirefoxProfile(); desiredCapabilities = DesiredCapabilities.firefox(); desiredCapabilities.setCapability(FirefoxDriver.PROFILE, profile); return desiredCapabilities; } else if (RemoteCapability.INTERNET_EXPLORER.equals(capability)){ desiredCapabilities = DesiredCapabilities.internetExplorer(); return desiredCapabilities; } else if (RemoteCapability.PHANTOMJS.equals(capability)){ desiredCapabilities = DesiredCapabilities.phantomjs(); return desiredCapabilities; } throw new IllegalArgumentException("No such capability"); }
Example #5
Source File: BaseEspressoTest.java From java-client with Apache License 2.0 | 6 votes |
/** * initialization. */ @BeforeClass public static void beforeClass() { service = AppiumDriverLocalService.buildDefaultService(); service.start(); if (service == null || !service.isRunning()) { throw new AppiumServerHasNotBeenStartedLocallyException( "An appium server node is not started!"); } DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ESPRESSO); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); capabilities.setCapability(MobileCapabilityType.APP, apiDemosApk().toAbsolutePath().toString()); capabilities.setCapability("eventTimings", true); driver = new AndroidDriver<>(service.getUrl(), capabilities); }
Example #6
Source File: SugarAndroidTest.java From candybean with GNU Affero General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { // set up appium DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "Selendroid"); capabilities.setCapability(CapabilityType.VERSION, "4.2.2"); capabilities.setCapability("device", "Android"); capabilities.setCapability(CapabilityType.PLATFORM, "Mac"); capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/SugarCRM.apk.zip"); capabilities.setCapability("app-package", "com.sugarcrm.nomad"); capabilities.setCapability("app-activity", "NomadActivity"); driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); values = new ArrayList<>(); }
Example #7
Source File: Browser.java From coteafs-selenium with Apache License 2.0 | 6 votes |
private static WebDriver setupRemote() { LOG.i("Setting up Remote driver..."); final RemoteSetting remoteSetting = appSetting().getRemote(); final RemoteSource source = remoteSetting.getSource(); final DesiredCapabilities caps = new DesiredCapabilities(); switch (source) { case SAUCELABS: setupCloud(remoteSetting, caps, "sauce"); break; case BROWSERSTACK: setupCloud(remoteSetting, caps, "bstack"); break; case GRID: default: setupCloud(remoteSetting, caps, null); break; } return createRemoteSession(remoteSetting, caps); }
Example #8
Source File: WebTestAndroid.java From samples with MIT License | 6 votes |
@BeforeTest @Override public void Setup() throws Exception { super.Setup(); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "Android Web Test"); capabilities.setCapability("sessionDescription", "Kobiton sample session"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("browserName", "chrome"); capabilities.setCapability("deviceName", "Galaxy S6"); capabilities.setCapability("platformName", "Android"); driver = new RemoteWebDriver(getAutomationUrl(), capabilities); }
Example #9
Source File: StartingAppLocallyTest.java From java-client with Apache License 2.0 | 6 votes |
@Test public void startingIOSAppWithCapabilitiesAndServiceTest() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, BaseIOSTest.DEVICE_NAME); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.APPIUM); capabilities.setCapability(MobileCapabilityType.APP, uiCatalogAppZip().toAbsolutePath().toString()); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, BaseIOSTest.PLATFORM_VERSION); //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); AppiumServiceBuilder builder = new AppiumServiceBuilder() .withArgument(GeneralServerFlag.SESSION_OVERRIDE) .withArgument(GeneralServerFlag.STRICT_CAPS); IOSDriver<?> driver = new IOSDriver<>(builder, capabilities); try { Capabilities caps = driver.getCapabilities(); assertTrue(caps.getCapability(MobileCapabilityType.PLATFORM_NAME) .toString().equalsIgnoreCase(MobilePlatform.IOS)); assertNotNull(null, caps.getCapability(MobileCapabilityType.DEVICE_NAME)); } finally { driver.quit(); } }
Example #10
Source File: SearchOnAndroidTest.java From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License | 6 votes |
@BeforeTest public void setUp() throws Exception { // Set the desired capabilities for Android Device DesiredCapabilities caps = DesiredCapabilities.android(); caps.setCapability("deviceOrientation", "portrait"); caps.setCapability("platformVersion", "8.1"); caps.setCapability("platformName", "Android"); caps.setCapability("browserName", "Chrome"); // Create an instance of AndroidDriver for testing on Android platform // connect to the local Appium server running on a different machine // We will use WebElement type for testing the Web application driver = new AndroidDriver<WebElement>(new URL( "http://192.168.0.101:4723/wd/hub"), caps); driver.get("http://demo-store.seleniumacademy.com/"); }
Example #11
Source File: UtilsTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void providesRemoteAccessToWebStorage() { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, true); CapableDriver driver = mock(CapableDriver.class); when(driver.getCapabilities()).thenReturn(caps); WebStorage storage = Utils.getWebStorage(driver); LocalStorage localStorage = storage.getLocalStorage(); SessionStorage sessionStorage = storage.getSessionStorage(); localStorage.setItem("foo", "bar"); sessionStorage.setItem("bim", "baz"); verify(driver).execute(DriverCommand.SET_LOCAL_STORAGE_ITEM, ImmutableMap.of( "key", "foo", "value", "bar")); verify(driver).execute(DriverCommand.SET_SESSION_STORAGE_ITEM, ImmutableMap.of( "key", "bim", "value", "baz")); }
Example #12
Source File: AppTestIOS.java From samples with MIT License | 6 votes |
@BeforeTest @Override public void Setup() throws Exception { super.Setup(); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "iOS App Test"); capabilities.setCapability("sessionDescription", "Kobiton sample session"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("app", "https://s3-ap-southeast-1.amazonaws.com/kobiton-devvn/apps-test/demo/iFixit.ipa"); capabilities.setCapability("deviceName", "iPhone 6s"); capabilities.setCapability("platformName", "iOS"); driver = new IOSDriver<>(getAutomationUrl(), capabilities); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); }
Example #13
Source File: Edition003_Arbitrary_ADB.java From appiumpro with Apache License 2.0 | 6 votes |
@Test public void testArbitraryADBCommands() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("deviceName", "Android Emulator"); capabilities.setCapability("automationName", "UiAutomator2"); capabilities.setCapability("appPackage", "com.google.android.apps.photos"); capabilities.setCapability("appActivity", ".home.HomeActivity"); // Open the app. AndroidDriver driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities); try { List<String> removePicsArgs = Arrays.asList("-rf", ANDROID_PHOTO_PATH + "/*.*"); Map<String, Object> removePicsCmd = ImmutableMap .of("command", "rm", "args", removePicsArgs); driver.executeScript("mobile: shell", removePicsCmd); List<String> lsArgs = Arrays.asList("/mnt/sdcard"); Map<String, Object> lsCmd = ImmutableMap.of("command", "ls", "args", lsArgs); String lsOutput = (String) driver.executeScript("mobile: shell", lsCmd); Assert.assertEquals("", lsOutput); } finally { driver.quit(); } }
Example #14
Source File: StandaloneDriverFactory.java From teasy with MIT License | 5 votes |
StandaloneDriverFactory(String browserName, String platformName, DesiredCapabilities customCaps, boolean isHeadless, final URL gridUrl) { this.browserName = browserName; this.platformName = platformName; this.customCaps = customCaps; this.isHeadless = isHeadless; this.gridUrl = gridUrl; }
Example #15
Source File: Edition002_Android_Photos.java From appiumpro with Apache License 2.0 | 5 votes |
@Test public void testSeedPhotoPicker() throws IOException { DesiredCapabilities capabilities = new DesiredCapabilities(); File classpathRoot = new File(System.getProperty("user.dir")); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("deviceName", "Android Emulator"); capabilities.setCapability("automationName", "UiAutomator2"); capabilities.setCapability("appPackage", "com.google.android.apps.photos"); capabilities.setCapability("appActivity", ".home.HomeActivity"); // Open the app. AndroidDriver driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities); try { // there's some screens we need to navigate through and ensure there are no existing photos setupAppState(driver); // set up the file we want to push to the phone's library File assetDir = new File(classpathRoot, "../assets"); File img = new File(assetDir.getCanonicalPath(), "cloudgrey.png"); // actually push the file driver.pushFile(ANDROID_PHOTO_PATH + "/" + img.getName(), img); // wait for the system to acknowledge the new photo, and use the WebDriverWait to verify // that the new photo is there WebDriverWait wait = new WebDriverWait(driver, 10); ExpectedCondition condition = ExpectedConditions.numberOfElementsToBe(photo,1); wait.until(condition); } finally { driver.quit(); } }
Example #16
Source File: WebDriverFactory.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private static DesiredCapabilities getFFUAECaps(DesiredCapabilities caps, Emulator emulator) { FirefoxProfile profile = new FirefoxProfile(); if (!emulator.getUserAgent().trim().isEmpty()) { profile.setPreference("general.useragent.override", emulator.getUserAgent()); } caps.setCapability(FirefoxDriver.PROFILE, profile); return caps; }
Example #17
Source File: Edition022_Tap_By_Coords.java From appiumpro with Apache License 2.0 | 5 votes |
@Test public void testTapByCoord_iOS() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "iOS"); capabilities.setCapability("platformVersion", "11.4"); capabilities.setCapability("deviceName", "iPhone 8"); capabilities.setCapability("app", APP_IOS); IOSDriver driver = new IOSDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities); actualTest(driver); }
Example #18
Source File: Edition066_Automating_iOS_System_Apps.java From appiumpro with Apache License 2.0 | 5 votes |
@Test public void launchSystemApp() throws MalformedURLException, InterruptedException { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("platformName", "iOS"); caps.setCapability("platformVersion", "12.2"); caps.setCapability("deviceName", "iPhone Xs"); caps.setCapability("automationName", "XCUITest"); caps.setCapability("app", IOS_APP); driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps); WebElement picker = driver.findElementByAccessibilityId("Picker Demo"); picker.click(); // open iMessage driver.activateApp("com.apple.MobileSMS"); // do things with SMS here Thread.sleep(3000); // open Settings app driver.activateApp("com.apple.Preferences"); // regular automation commands to change device settings here // go back to our app driver.activateApp("io.cloudgrey.the-app"); Thread.sleep(3000); }
Example #19
Source File: Configs.java From samples with MIT License | 5 votes |
public static DesiredCapabilities desiredCapabilitiesiOSApp(){ DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("sessionName", "iOS app"); capabilities.setCapability("sessionDescription", "This is an example for iOS App testing"); capabilities.setCapability("deviceOrientation", "portrait"); capabilities.setCapability("captureScreenshots", true); capabilities.setCapability("app", "https://s3-ap-southeast-1.amazonaws.com/kobiton-devvn/apps-test/demo/iFixit.ipa"); capabilities.setCapability("deviceGroup", "KOBITON"); capabilities.setCapability("deviceName", "iPhone 7"); capabilities.setCapability("platformName", "iOS"); return capabilities; }
Example #20
Source File: UiDriverFactory.java From Quantum with MIT License | 5 votes |
private Browsers(DesiredCapabilities desiredCapabilities) { this.desiredCapabilities = desiredCapabilities; this.desiredCapabilities.setJavascriptEnabled(true); this.desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true); this.desiredCapabilities.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true); }
Example #21
Source File: Edition080_iOS_FaceId.java From appiumpro with Apache License 2.0 | 5 votes |
@Before public void setUp() throws IOException { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("platformName", "iOS"); caps.setCapability("platformVersion", "12.4"); caps.setCapability("deviceName", "iPhone Xs"); caps.setCapability("automationName", "XCUITest"); caps.setCapability("app", app); driver = new IOSDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), caps); }
Example #22
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 5 votes |
/** * Задает options для запуска Firefox драйвера * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension * * @return FirefoxOptions */ private FirefoxOptions getFirefoxDriverOptions(DesiredCapabilities capabilities) { log.info("---------------Firefox Driver---------------------"); FirefoxOptions firefoxOptions = !options[0].equals("") ? new FirefoxOptions().addArguments(options) : new FirefoxOptions(); capabilities.setVersion(loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST)); firefoxOptions.setHeadless(getHeadless()); firefoxOptions.merge(capabilities); return firefoxOptions; }
Example #23
Source File: Edition118_Multi_Device.java From appiumpro with Apache License 2.0 | 5 votes |
private IOSDriver<WebElement> getSafari() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "iOS"); capabilities.setCapability("platformVersion", "13.3"); capabilities.setCapability("deviceName", "iPhone 11"); capabilities.setCapability("browserName", "Safari"); capabilities.setCapability("automationName", "XCUITest"); return new IOSDriver<>(new URL("http://localhost:4723/wd/hub"), capabilities); }
Example #24
Source File: LogSearchUIStories.java From ambari-logsearch with Apache License 2.0 | 5 votes |
public LogSearchUIStories() { String dockerHost = System.getProperty("docker.host") != null ? System.getProperty("docker.host") : "localhost"; System.setProperty("REMOTE_WEBDRIVER_URL", String.format("http://%s:4444/wd/hub", dockerHost)); DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setPlatform(Platform.LINUX); capability.setVersion("45.8.0"); driverProvider = new RemoteWebDriverProvider(capability); StoryDataRegistry.INSTANCE.setWebDriverProvider(driverProvider); context = new SeleniumContext(); configuredEmbedder().useExecutorService(new SameThreadExecutors().create(configuredEmbedder().embedderControls())); }
Example #25
Source File: Edition016_Clipboard.java From appiumpro with Apache License 2.0 | 5 votes |
@Test public void testClipboard_Android() throws IOException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("deviceName", "Android Emulator"); capabilities.setCapability("automationName", "UiAutomator2"); capabilities.setCapability("avd", AVD_NAME); capabilities.setCapability("app", ANDROID_APP); AndroidDriver driver = new AndroidDriver(new URL(APPIUM_SERVER), capabilities); automateClipboard(driver); }
Example #26
Source File: BrowserDriver.java From SWET with MIT License | 5 votes |
private static DesiredCapabilities capabilitiesAndroid() { DesiredCapabilities capabilities = DesiredCapabilities.chrome(); Map<String, String> mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceName", "Google Nexus 5"); Map<String, Object> chromeOptions = new HashMap<>(); chromeOptions.put("mobileEmulation", mobileEmulation); capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); return capabilities; }
Example #27
Source File: JsonTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void shouldProperlyFillInACapabilitiesObject() { DesiredCapabilities capabilities = new DesiredCapabilities("browser", CapabilityType.VERSION, Platform.ANY); capabilities.setJavascriptEnabled(true); String text = new Json().toJson(capabilities); Capabilities readCapabilities = new Json().toType(text, DesiredCapabilities.class); assertThat(readCapabilities).isEqualTo(capabilities); }
Example #28
Source File: BaseBrowserFactory.java From webtester-core with Apache License 2.0 | 5 votes |
protected DesiredCapabilities getDefaultCapabilities() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, false); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); setOptionalProxyConfiguration(capabilities); return capabilities; }
Example #29
Source File: AndroidElementGeneratingTest.java From java-client with Apache License 2.0 | 5 votes |
@Test public void whenAndroidHybridAppIsLaunched() { assertTrue(check(() -> { DesiredCapabilities clientCapabilities = commonCapabilitiesSupplier.get(); clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "io.appium.android.apis"); clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".view.WebView1"); return clientCapabilities; }, (by, aClass) -> { driver.context("WEBVIEW_io.appium.android.apis"); return commonPredicate.test(by, aClass); }, tagName("a"))); }
Example #30
Source File: CapabilitiesComparatorTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void matchesByCapabilitiesProvided() { DesiredCapabilities sparse = new DesiredCapabilities(); sparse.setBrowserName(BrowserType.FIREFOX); Capabilities windows = capabilities(BrowserType.IE, "", Platform.WINDOWS, true); Capabilities firefox = capabilities(BrowserType.FIREFOX, "", Platform.WINDOWS, true); assertThat(getBestMatch(sparse, asList(windows, firefox))).isEqualTo(firefox); sparse.setBrowserName(BrowserType.IE); assertThat(getBestMatch(sparse, asList(windows, firefox))).isEqualTo(windows); }