How to use getCapability method of org.openqa.selenium.MutableCapabilities class

Best Selenium code snippet using org.openqa.selenium.MutableCapabilities.getCapability

Source:TestFirefoxCapabilitiesFactory.java Github

copy

Full Screen

...94 Assert.assertTrue(capa.is(CapabilityType.TAKES_SCREENSHOT));95 Assert.assertTrue(capa.is(CapabilityType.ACCEPT_SSL_CERTS));96 Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));97 Assert.assertEquals(capa.getVersion(), "");98 Assert.assertEquals(capa.getCapability(CapabilityType.PROXY), proxyConfig);99 Assert.assertEquals(((Map<?,?>)(((FirefoxOptions)capa).asMap().get(FirefoxOptions.FIREFOX_OPTIONS))).get("args").toString(), "[]");100 }101102 /**103 * Check default behaviour when node tags are defined in grid mode104 * tags are transferred to driver105 */106 @Test(groups={"ut"})107 public void testCreateDefaultCapabilitiesWithNodeTagsInGridMode() {108 109 Mockito.when(config.isEnableJavascript()).thenReturn(true);110 Mockito.when(config.getProxy()).thenReturn(proxyConfig);111 Mockito.when(config.getNodeTags()).thenReturn(Arrays.asList("foo", "bar"));112 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);113 114 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();115 116 Assert.assertEquals(capa.getCapability(SeleniumRobotCapabilityType.NODE_TAGS), Arrays.asList("foo", "bar"));117 }118 119 /**120 * Check default behaviour when node tags are defined in local mode121 * tags are not transferred to driver 122 */123 @Test(groups={"ut"})124 public void testCreateDefaultCapabilitiesWithNodeTagsInLocalMode() {125 126 Mockito.when(config.getNodeTags()).thenReturn(Arrays.asList("foo", "bar"));127 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);128 129 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();130 131 Assert.assertFalse(capa.is(SeleniumRobotCapabilityType.NODE_TAGS));132 }133 134 @Test(groups={"ut"})135 public void testCreateDefaultCapabilitiesWithPlatform() {136 137 Mockito.when(config.isEnableJavascript()).thenReturn(true);138 Mockito.when(config.getProxy()).thenReturn(proxyConfig);139 Mockito.when(config.getWebPlatform()).thenReturn(Platform.WINDOWS);140 141 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();142 143 Assert.assertEquals(capa.getPlatform(), Platform.WINDOWS);144 145 }146 147 @Test(groups={"ut"})148 public void testCreateDefaultCapabilitiesWithJavascriptDisabled() {149 150 Mockito.when(config.isEnableJavascript()).thenReturn(false);151 Mockito.when(config.getProxy()).thenReturn(proxyConfig);152 153 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();154 155 Assert.assertFalse(capa.is(CapabilityType.SUPPORTS_JAVASCRIPT));156 157 }158 159 @Test(groups={"ut"})160 public void testCreateDefaultCapabilitiesWithHeadless() {161 162 Mockito.when(config.isEnableJavascript()).thenReturn(false);163 Mockito.when(config.isHeadlessBrowser()).thenReturn(true);164 165 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();166 167 Assert.assertEquals(((Map<?,?>)(((FirefoxOptions)capa).asMap().get(FirefoxOptions.FIREFOX_OPTIONS))).get("args").toString(), "[-headless, --window-size=1280,1024, --width=1280, --height=1024]");168 169 }170 171 @Test(groups={"ut"})172 public void testCreateDefaultCapabilitiesWithVersion() {173 174 Mockito.when(config.isEnableJavascript()).thenReturn(true);175 Mockito.when(config.getProxy()).thenReturn(proxyConfig);176 Mockito.when(config.getBrowserVersion()).thenReturn("60.0");177 178 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();179 180 Assert.assertEquals(capa.getVersion(), "60.0");181 182 }183 184 @Test(groups={"ut"})185 public void testCreateDefaultFirefoxCapabilities() {186187 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);188 Mockito.when(config.isSetAcceptUntrustedCertificates()).thenReturn(true);189 Mockito.when(config.isSetAssumeUntrustedCertificateIssuer()).thenReturn(true);190 191 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();192 193 Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "firefox");194 Assert.assertEquals(capa.getCapability(FirefoxDriver.MARIONETTE), false);195 196 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);197 198 // check profile199 Assert.assertTrue(profile.getBooleanPreference("webdriver_accept_untrusted_certs", false));200 Assert.assertTrue(profile.getBooleanPreference("webdriver_assume_untrusted_issuer", false));201 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.QueryInterface", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);202 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.frameElement.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);203 Assert.assertEquals(profile.getStringPreference("capability.policy.default.HTMLDocument.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);204 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Document.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);205 Assert.assertEquals(profile.getIntegerPreference("dom.max_chrome_script_run_time", 100), 0);206 Assert.assertEquals(profile.getIntegerPreference("dom.max_script_run_time", 100), 0);207 }208 209 @Test(groups={"ut"})210 public void testCreateFirefoxCapabilitiesOverrideUserAgent() {211 212 Mockito.when(config.getUserAgentOverride()).thenReturn("FIREFOX 55");213 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);214 215 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();216 217 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);218 219 // check profile220 Assert.assertEquals(profile.getStringPreference("general.useragent.override", ""), "FIREFOX 55");221 }222 223 @Test(groups={"ut"})224 public void testCreateFirefoxCapabilitiesOverrideBinPath() {225 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);226 Mockito.when(config.getFirefoxBinPath()).thenReturn("/opt/firefox/bin/firefox");227 228 // SeleniumTestsContext class adds a browserInfo when binary path is set229 Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();230 updatedBrowserInfos.put(BrowserType.FIREFOX, Arrays.asList(new BrowserInfo(BrowserType.FIREFOX, "47.0", "", false), 231 new BrowserInfo(BrowserType.FIREFOX, "44.0", "/opt/firefox/bin/firefox", false)));232233 PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);234 235 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();236 237 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/opt/firefox/bin/firefox");238 }239 240 @Test(groups={"ut"})241 public void testCreateFirefoxCapabilitiesStandardBinPath() {242 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);243 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();244245 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/usr/bin/firefox");246 }247 248 @Test(groups={"ut"})249 public void testCreateFirefoxCapabilitiesOverrideNtlmAuth() {250 251 Mockito.when(config.getNtlmAuthTrustedUris()).thenReturn("uri://uri.ntlm");252 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);253 254 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();255 256 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);257 258 // check profile259 Assert.assertEquals(profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris", ""), "uri://uri.ntlm");260 }261 262 @Test(groups={"ut"})263 public void testCreateFirefoxCapabilitiesOverrideDownloadDir() {264 265 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");266 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);267 268 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();269 270 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);271 272 // check profile273 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "/home/download");274 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 2);275 Assert.assertEquals(profile.getBooleanPreference("browser.download.manager.showWhenStarting", true), false);276 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");277 }278 279 /**280 * issue #365: Check DownloadDir is not set in remote281 */282 @Test(groups={"ut"})283 public void testCreateFirefoxCapabilitiesNoOverrideDownloadDirRemote() {284 285 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");286 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);287 288 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();289 290 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);291 292 // check profile293 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "");294 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 0);295 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "");296 }297 298 @Test(groups={"ut"})299 public void testCreateFirefoxCapabilitiesWithDefaultProfile() {300 301 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);302 Mockito.when(config.getFirefoxProfilePath()).thenReturn(BrowserInfo.DEFAULT_BROWSER_PRODFILE);303 304 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();305 306 // check 'firefoxProfile' is set to 'default'307 Assert.assertEquals(capa.getCapability("firefoxProfile"), BrowserInfo.DEFAULT_BROWSER_PRODFILE);308 }309 310 @Test(groups={"ut"})311 public void testCreateFirefoxCapabilitiesWithUserProfile() {312 313 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);314 Mockito.when(config.getFirefoxProfilePath()).thenReturn("/home/user/profile");315 316 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();317 318 // check 'firefoxProfile' is set to 'default'319 Assert.assertEquals(capa.getCapability("firefoxProfile"), "/home/user/profile");320 }321 322 @Test(groups={"ut"})323 public void testCreateFirefoxCapabilitiesWithoutDefaultProfile() {324 325 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);326 327 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();328 329 // check 'firefoxProfile' is set to 'default'330 Assert.assertNull(capa.getCapability("firefoxProfile"));331 }332 333 @Test(groups={"ut"})334 public void testCreateFirefoxCapabilitiesWrongProfile() {335 336 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);337 Mockito.when(config.getFirefoxProfilePath()).thenReturn("foo");338 339 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();340 341 // check 'firefoxProfile' is set to 'default'342 Assert.assertNull(capa.getCapability("firefoxProfile"));343 }344 345} ...

Full Screen

Full Screen

Source:SeleniumTest.java Github

copy

Full Screen

...151 }152 private static ChromeOptions enhanceChromeCaps(MutableCapabilities caps) {153 ChromeOptions options = new ChromeOptions();154 options.merge(caps);155 if (options.getCapability(ChromeOptions.CAPABILITY) != null) {156 HashMap chromeOptions = (HashMap) options.getCapability(ChromeOptions.CAPABILITY);157 if (chromeOptions.get("mobileEmulation") != null)158 options.setExperimentalOption("mobileEmulation", chromeOptions.get("mobileEmulation"));159 if (chromeOptions.get("args") != null)160 options.addArguments((List<String>) chromeOptions.get("args"));161 if (chromeOptions.get("extensions") != null)162 options.addExtensions((List<File>) chromeOptions.get("extensions"));163 }164 return options;165 }166 private static void writeCapabilities() {167 DesiredCapabilities caps = new DesiredCapabilities("safari", "", Platform.ANY);168 caps.setCapability("platformName", "iOS");169 caps.setCapability("manufacturer", "Apple");170 caps.setCapability("model", "iPhone-5S");...

Full Screen

Full Screen

Source:SynthesizedFirefoxDriver.java Github

copy

Full Screen

...48 }49 private static Capabilities tweakCapabilities(Capabilities desiredCaps) {50 Objects.requireNonNull(desiredCaps, "Capabilities to tweak must not be null");51 MutableCapabilities tweaked = new MutableCapabilities(desiredCaps);52 if (tweaked.getCapability(PROFILE) == null) {53 tweaked.setCapability(PROFILE, createTemporaryProfile());54 } else {55 try {56 FirefoxProfile profile;57 if (tweaked.getCapability(PROFILE) instanceof FirefoxProfile) {58 profile = (FirefoxProfile) tweaked.getCapability(PROFILE);59 } else {60 profile = FirefoxProfile.fromJson((String) tweaked.getCapability(PROFILE));61 }62 copyExtensionTo(profile);63 tweaked.setCapability(PROFILE, profile);64 } catch (IOException e) {65 throw new RuntimeException(e);66 }67 }68 return tweaked;69 }70 private static FirefoxProfile createTemporaryProfile() {71 if (!isInDevMode()) {72 return new CustomProfile();73 }74 try {...

Full Screen

Full Screen

Source:CommonCapabilitiesTest.java Github

copy

Full Screen

...29 void transferCapabilitiesFromConfiguration() {30 SelenideConfig config = new SelenideConfig();31 config.pageLoadStrategy("foo");32 Capabilities commonCapabilities = driverFactory.createCommonCapabilities(config, browser(config), proxy);33 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_INSECURE_CERTS))).isTrue();34 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_SSL_CERTS))).isTrue();35 assertThat(commonCapabilities.getCapability(PAGE_LOAD_STRATEGY)).isEqualTo(config.pageLoadStrategy());36 }37 @Test38 void transferCapabilitiesFromConfigurationInternetExplorer() {39 SelenideConfig config = new SelenideConfig();40 config.browser(INTERNET_EXPLORER);41 Capabilities commonCapabilities = driverFactory.createCommonCapabilities(config, browser(config), proxy);42 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_INSECURE_CERTS))).isFalse();43 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_SSL_CERTS))).isTrue();44 }45 @Test46 void transferCapabilitiesFromConfigurationIE() {47 SelenideConfig config = new SelenideConfig();48 config.browser(IE);49 Capabilities commonCapabilities = driverFactory.createCommonCapabilities(config, browser(config), proxy);50 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_INSECURE_CERTS))).isFalse();51 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_SSL_CERTS))).isTrue();52 }53 @Test54 void transferCapabilitiesFromConfigurationEdge() {55 SelenideConfig config = new SelenideConfig();56 config.browser(EDGE);57 Capabilities commonCapabilities = driverFactory.createCommonCapabilities(config, browser(config), proxy);58 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_INSECURE_CERTS))).isFalse();59 assertThat(asBool(commonCapabilities.getCapability(ACCEPT_SSL_CERTS))).isTrue();60 }61 private boolean asBool(Object raw) {62 if (raw != null) {63 if (raw instanceof String) {64 return Boolean.parseBoolean((String) raw);65 } else if (raw instanceof Boolean) {66 return (Boolean) raw;67 }68 }69 return false;70 }71 private Browser browser(SelenideConfig config) {72 return new Browser(config.browser(), config.headless());73 }...

Full Screen

Full Screen

Source:RemoteDriverManager.java Github

copy

Full Screen

...22 Configuration configuration = ConfigCache.getOrCreate(Configuration.class);23 try {24 // a composition of the target grid address and port25 String gridURL = String.format("http://%s:%s/wd/hub", configuration.gridUrl(), configuration.gridPort());26 remoteWebDriver = new RemoteWebDriver(new URL(gridURL), getCapability(browser));27 } catch (MalformedURLException e) {28 log.error("Grid URL is invalid or Grid is not available");29 log.error("Browser: " + browser, e);30 } catch (IllegalArgumentException e) {31 log.error("Browser: " + browser + "is not valid or recognized", e);32 }33 return remoteWebDriver;34 }35 private static MutableCapabilities getCapability(String browser) {36 MutableCapabilities mutableCapabilities;37 DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase());38 switch (driverManagerType) {39 case CHROME:40 mutableCapabilities = defaultChromeOptions();41 break;42 case FIREFOX:43 mutableCapabilities = new FirefoxOptions();44 break;45 case OPERA:46 mutableCapabilities = new OperaOptions();47 break;48 case EDGE:49 mutableCapabilities = new EdgeOptions();...

Full Screen

Full Screen

Source:RemoteDriver.java Github

copy

Full Screen

...11import org.openqa.selenium.safari.SafariOptions;12import java.net.MalformedURLException;13import java.net.URL;14public class RemoteDriver {15 private static MutableCapabilities getCapability(String browser) {16 MutableCapabilities mutableCapabilities;17 DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase());18 switch (driverManagerType) {19 case CHROME:20 mutableCapabilities = defaultChromeOptions();21 break;22 case FIREFOX:23 mutableCapabilities = new FirefoxOptions();24 break;25 case OPERA:26 mutableCapabilities = new OperaOptions();27 break;28 case EDGE:29 mutableCapabilities = new EdgeOptions();30 break;31 case IEXPLORER:32 mutableCapabilities = new InternetExplorerOptions();33 break;34 case SAFARI:35 mutableCapabilities = new SafariOptions();36 break;37 default:38 throw new RuntimeException(driverManagerType.toString());39 }40 return mutableCapabilities;41 }42 private static MutableCapabilities defaultChromeOptions() {43 ChromeOptions capabilities = new ChromeOptions();44 capabilities.addArguments("start-maximized");45 return capabilities;46 }47 public WebDriver getDriver(String browserName) {48 RemoteWebDriver remoteWebDriver = null;49 try {50 // a composition of the target grid address and port51 String gridURL = String.format("http://%s:%s/wd/hub", "localhost", "4444");52 MutableCapabilities cap = getCapability(browserName);53 cap.setCapability("version", "96.0.4664.45");54 remoteWebDriver = new RemoteWebDriver(new URL(gridURL), cap);55 } catch (MalformedURLException e) {56 } catch (IllegalArgumentException e) {57 }58 return remoteWebDriver;59 }60}...

Full Screen

Full Screen

Source:Firefox.java Github

copy

Full Screen

...23 }24 var headless = Boolean.parseBoolean(properties.getProperty("headless", "false"));25 options.setHeadless(headless);26 // do not copy logging preferences, if running in headless mode: https://github.com/SeleniumHQ/selenium/issues/1034927 capabilities.getCapabilityNames().stream().filter(x -> {28 return !CapabilityType.LOGGING_PREFS.equals(x);29 }).forEach(x -> {30 options.setCapability(x, capabilities.getCapability(x));31 });32 return options;33 }34}...

Full Screen

Full Screen

Source:DriverBuilder.java Github

copy

Full Screen

...8import org.openqa.selenium.opera.OperaOptions;9public class DriverBuilder {10 private DriverBuilder() {11 }12 public static MutableCapabilities getCapability(String browser) {13 MutableCapabilities mutableCapabilities;14 DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase());15 switch (driverManagerType) {16 case CHROME:17 mutableCapabilities = defaultChromeOptions();18 break;19 case FIREFOX:20 mutableCapabilities = new FirefoxOptions();21 break;22 case OPERA:23 mutableCapabilities = new OperaOptions();24 break;25 case EDGE:26 mutableCapabilities = new EdgeOptions();...

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.MutableCapabilities;2import org.openqa.selenium.chrome.ChromeOptions;3public class MutableCapabilitiesDemo {4 public static void main(String[] args) {5 ChromeOptions options = new ChromeOptions();6 options.addArguments("start-maximized");7 options.addArguments("disable-infobars");8 options.addArguments("--disable-extensions");9 options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});10 options.setExperimentalOption("useAutomationExtension", false);11 options.setExperimentalOption("prefs", new MutableCapabilities());12 System.out.println(options.getCapability("prefs"));13 }14}15{}16import org.openqa.selenium.MutableCapabilities;17import org.openqa.selenium.chrome.ChromeOptions;18public class MutableCapabilitiesDemo {19 public static void main(String[] args) {20 ChromeOptions options = new ChromeOptions();21 options.addArguments("start-maximized");22 options.addArguments("disable-infobars");23 options.addArguments("--disable-extensions");24 options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});25 options.setExperimentalOption("useAutomationExtension", false);26 options.setCapability("prefs", new MutableCapabilities());27 System.out.println(options.getCapability("prefs"));28 }29}30{}31import org.openqa.selenium.MutableCapabilities;32import org.openqa.selenium.chrome.ChromeOptions;33public class MutableCapabilitiesDemo {34 public static void main(String[] args) {35 ChromeOptions options = new ChromeOptions();36 options.addArguments("start-maximized");37 options.addArguments("disable-infobars");38 options.addArguments("--disable-extensions");39 options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});40 options.setExperimentalOption("useAutomationExtension", false);41 options.setCapability("prefs", new MutableCapabilities());42 System.out.println(options.getCapability("prefs"));43 }44}45{}46import org.openqa.selenium.MutableCapabilities;47import org.openqa.selenium.chrome.ChromeOptions;48public class MutableCapabilitiesDemo {49 public static void main(String[] args) {50 ChromeOptions options = new ChromeOptions();51 options.addArguments("start-maximized");52 options.addArguments("disable-infobars");53 options.addArguments("--disable-extensions");54 options.setExperimentalOption("excludeSwitches", new String

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.browserstack;2import org.openqa.selenium.MutableCapabilities;3public class MutableCapabilitiesExample {4 public static void main(String[] args) {5 MutableCapabilities caps = new MutableCapabilities();6 caps.setCapability("browser", "Chrome");7 caps.setCapability("browser_version", "latest");8 caps.setCapability("os", "Windows");9 caps.setCapability("os_version", "10");10 caps.setCapability("name", "MutableCapabilitiesExample");11 caps.setCapability("build", "Java-MutableCapabilities");12 caps.setCapability("browserstack.debug", "true");13 caps.setCapability("browserstack.local", "true");14 caps.setCapability("browserstack.selenium_version", "3.5.2");15 System.out.println(caps.getCapability("browser"));16 System.out.println(caps.getCapability("browser_version"));17 System.out.println(caps.getCapability("os"));18 System.out.println(caps.getCapability("os_version"));19 System.out.println(caps.getCapability("name"));20 System.out.println(caps.getCapability("build"));21 System.out.println(caps.getCapability("browserstack.debug"));22 System.out.println(caps.getCapability("browserstack.local"));23 System.out.println(caps.getCapability("browserstack.selenium_version"));24 }25}

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.browserstack;2import org.openqa.selenium.MutableCapabilities;3public class MutableCapabilitiesExample {4 public static void main(String[] args) {5 MutableCapabilities caps = new MutableCapabilities();6 caps.setCapability("browser", "Chrome");7 caps.setCapability("browser_version", "latest");8 caps.setCapability("os", "Windows");9 caps.setCapability("os_version", "10");10 caps.setCapability("name", "MutableCapabilitiesExample");11 caps.setCapability("build", "Java-MutableCapabilities");12 caps.setCapability("browserstack.debug", "true");13 caps.setCapability("browserstack.local", "true");14 caps.setCapability("browserstack.selenium_version", "3.5.2");15 System.out.println(caps.getCapability("browser"));16 System.out.println(caps.getCapability("browser_version"));17 System.out.println(caps.getCapability("os"));18 System.out.println(caps.getCapability("os_version"));19 System.out.println(caps.getCapability("name"));20 System.out.println(caps.getCapability("build"));21 System.out.println(caps.getCapability("browserstack.debug"));22 System.out.println(caps.getCapability("browserstack.local"));23 System.out.println(caps.getCapability("browserstack.selenium_version"));24 }25}

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.edureka.selenium;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6public class SeleniumTest {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Rahul\\eclipse-workspace\\edureka\\drivers\\chromedriver.exe");9 ChromeOptions options = new ChromeOptions();10 options.addArguments("--start-maximized");11 options.setExperimentalOption("useAutomationExtension", false);12 options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});13 WebDriver driver = new ChromeDriver(options);14 System.out.println(driver.getTitle());15 driver.quit();16 }17}

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.browserstack;2import org.openqa.selenium.MutableCapabilities;3public class GetCapability {4public static void main(String[] args) {5MutableCapabilities capabilities = new MutableCapabilities();6capabilities.setCapability("os_version", "10");7capabilities.setCapability("resolution", "1024x768");8capabilities.setCapability("browser", "Chrome");9capabilities.setCapability("browser_version", "80");10capabilities.setCapability("os", "Windows");11System.out.println(capabilities.getCapability("os_version"));12System.out.println(capabilities.getCapability("resolution"));13System.out.println(capabilities.getCapability("browser"));14System.out.println(capabilities.getCapability("browser_version"));15System.out.println(capabilities.getCapability("os"));16System.out.println(capabilities.getCapability("name"));17System.out.println(capabilities.getCapability("build"));18}19}20package com.browserstack;21import org.openqa.selenium.MutableCapabilities;22public class MergeCapabilities {23public static void main(String[] args) {24MutableCapabilities capabilities = new MutableCapabilities();25capabilities.setCapability("os_version", "10");26capabilities.setCapability("resolution", "1024x768");27capabilities.setCapability("browser", "Chrome");28capabilities.setCapability("browser_version", "80");29capabilities.setCapability("os", "Windows");30MutableCapabilities capabilities1 = new MutableCapabilities();31capabilities1.setCapability("os_version", "10");32capabilities1.setCapability("resolution", "1024x768");33capabilities1.setCapability("browser", "Chrome");34capabilities1.setCapability("browser_version", "80");35capabilities1.setCapability("os", "Windows");36capabilities1.setCapability("

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.edureka.selenium;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6public class SeleniumTest {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Rahul\\eclipse-workspace\\edureka\\drivers\\chromedriver.exe");9 ChromeOptions options = new ChromeOptions();10 options.addArguments("--start-maximized");11 options.setExperimentalOption("useAutomationExtension", false);12 options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});13 WebDriver driver = new ChromeDriver(options);14 System.out.println(driver.getTitle());15 driver.quit();16 }17}

Full Screen

Full Screen

getCapability

Using AI Code Generation

copy

Full Screen

1package com.browserstack;2import org.openqa.selenium.MutableCapabilities;3public class GetCapability {4public static void main(String[] args) {5MutableCapabilities capabilities = new MutableCapabilities();6capabilities.setCapability("os_version", "10");7capabilities.setCapability("resolution", "1024x768");8capabilities.setCapability("browser", "Chrome");9capabilities.setCapability("browser_version", "80");10capabilities.setCapability("os", "Windows");11System.out.println(capabilities.getCapability("os_version"));12System.out.println(capabilities.getCapability("resolution"));13System.out.println(capabilities.getCapability("browser"));14System.out.println(capabilities.getCapability("browser_version"));15System.out.println(capabilities.getCapability("os"));16System.out.println(capabilities.getCapability("name"));17System.out.println(capabilities.getCapability("build"));18}19}20package com.browserstack;21import org.openqa.selenium.MutableCapabilities;22public class MergeCapabilities {23public static void main(String[] args) {24MutableCapabilities capabilities = new MutableCapabilities();25capabilities.setCapability("os_version", "10");26capabilities.setCapability("resolution", "1024x768");27capabilities.setCapability("browser", "Chrome");28capabilities.setCapability("browser_version", "80");29capabilities.setCapability("os", "Windows");30MutableCapabilities capabilities1 = new MutableCapabilities();31capabilities1.setCapability("os_version", "10");32capabilities1.setCapability("resolution", "1024x768");33capabilities1.setCapability("browser", "Chrome");34capabilities1.setCapability("browser_version", "80");35capabilities1.setCapability("os", "Windows");36capabilities1.setCapability("

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful