How to use valueOf method of org.openqa.selenium.Enum Proxy.ProxyType class

Best Selenium code snippet using org.openqa.selenium.Enum Proxy.ProxyType.valueOf

Source:JsonTest.java Github

copy

Full Screen

...58 assertThat((Boolean) new Json().toType("false", Boolean.class)).isFalse();59 }60 @Test61 public void canReadANumber() {62 assertThat((Number) new Json().toType("42", Number.class)).isEqualTo(Long.valueOf(42));63 assertThat((Integer) new Json().toType("42", Integer.class)).isEqualTo(Integer.valueOf(42));64 assertThat((Double) new Json().toType("42", Double.class)).isEqualTo(Double.valueOf(42));65 }66 @Test67 public void canRoundTripNumbers() {68 Map<String, Object> original = ImmutableMap.of(69 "options", ImmutableMap.of("args", ImmutableList.of(1L, "hello")));70 Json json = new Json();71 String converted = json.toJson(original);72 Object remade = json.toType(converted, MAP_TYPE);73 assertThat(remade).isEqualTo(original);74 }75 @Test76 public void roundTripAFirefoxOptions() {77 Map<String, Object> caps = ImmutableMap.of(78 "moz:firefoxOptions", ImmutableMap.of(79 "prefs", ImmutableMap.of("foo.bar", 1)));80 String json = new Json().toJson(caps);81 assertThat(json).doesNotContain("1.0");82 try (JsonInput input = new Json().newInput(new StringReader(json))) {83 json = new Json().toJson(input.read(Json.MAP_TYPE));84 assertThat(json).doesNotContain("1.0");85 }86 }87 @Test88 public void shouldCoerceAListOfCapabilitiesIntoSomethingMutable() {89 // This is needed since Grid expects each of the capabilities to be mutable90 List<Capabilities> expected = ImmutableList.of(91 new ImmutableCapabilities("cheese", "brie"),92 new ImmutableCapabilities("peas", 42L));93 Json json = new Json();94 String raw = json.toJson(expected);95 List<Capabilities> seen = json.toType(raw, new TypeToken<List<Capabilities>>(){}.getType());96 assertThat(seen).isEqualTo(expected);97 assertThat(seen.get(0)).isInstanceOf(MutableCapabilities.class);98 }99 @Test100 public void shouldUseBeanSettersToPopulateFields() {101 Map<String, String> map = ImmutableMap.of("name", "fishy");102 Json json = new Json();103 String raw = json.toJson(map);104 BeanWithSetter seen = json.toType(raw, BeanWithSetter.class);105 assertThat(seen.theName).isEqualTo("fishy");106 }107 public static class BeanWithSetter {108 String theName;109 public void setName(String name) {110 theName = name;111 }112 }113 @Test114 public void shouldAllowUserToPopulateFieldsDirectly() {115 Map<String, String> map = ImmutableMap.of("theName", "fishy");116 Json json = new Json();117 String raw = json.toJson(map);118 BeanWithSetter seen = json.toType(raw, BeanWithSetter.class, PropertySetting.BY_FIELD);119 assertThat(seen.theName).isEqualTo("fishy");120 }121 @Test122 public void settingFinalFieldsShouldWork() {123 Map<String, String> map = ImmutableMap.of("theName", "fishy");124 Json json = new Json();125 String raw = json.toJson(map);126 BeanWithFinalField seen = json.toType(raw, BeanWithFinalField.class, PropertySetting.BY_FIELD);127 assertThat(seen.theName).isEqualTo("fishy");128 }129 public static class BeanWithFinalField {130 private final String theName;131 public BeanWithFinalField() {132 this.theName = "magic";133 }134 }135 @Test136 public void canConstructASimpleString() {137 String text = new Json().toType("\"cheese\"", String.class);138 assertThat(text).isEqualTo("cheese");139 }140 @Test141 public void canPopulateAMap() {142 String raw = "{\"cheese\": \"brie\", \"foodstuff\": \"cheese\"}";143 Map<String, String> map = new Json().toType(raw, Map.class);144 assertThat(map)145 .hasSize(2)146 .containsEntry("cheese", "brie")147 .containsEntry("foodstuff", "cheese");148 }149 @Test150 public void canPopulateAMapThatContainsNull() {151 String raw = "{\"foo\": null}";152 Map<?,?> converted = new Json().toType(raw, Map.class);153 assertThat(converted.size()).isEqualTo(1);154 assertThat(converted.containsKey("foo")).isTrue();155 assertThat(converted.get("foo")).isNull();156 }157 @Test158 public void canPopulateASimpleBean() {159 String raw = "{\"value\": \"time\"}";160 SimpleBean bean = new Json().toType(raw, SimpleBean.class);161 assertThat(bean.getValue()).isEqualTo("time");162 }163 @Test164 public void willSilentlyDiscardUnusedFieldsWhenPopulatingABean() {165 String raw = "{\"value\": \"time\", \"frob\": \"telephone\"}";166 SimpleBean bean = new Json().toType(raw, SimpleBean.class);167 assertThat(bean.getValue()).isEqualTo("time");168 }169 @Test170 public void shouldSetPrimitiveValuesToo() {171 String raw = "{\"magicNumber\": 3}";172 Map<?,?> map = new Json().toType(raw, Map.class);173 assertThat(map.get("magicNumber")).isEqualTo(3L);174 }175 @Test176 public void shouldPopulateFieldsOnNestedBeans() {177 String raw = "{\"name\": \"frank\", \"bean\": {\"value\": \"lots\"}}";178 ContainingBean bean = new Json().toType(raw, ContainingBean.class);179 assertThat(bean.getName()).isEqualTo("frank");180 assertThat(bean.getBean().getValue()).isEqualTo("lots");181 }182 @Test183 public void shouldProperlyFillInACapabilitiesObject() {184 DesiredCapabilities capabilities =185 new DesiredCapabilities("browser", CapabilityType.VERSION, Platform.ANY);186 capabilities.setJavascriptEnabled(true);187 String text = new Json().toJson(capabilities);188 Capabilities readCapabilities = new Json().toType(text, DesiredCapabilities.class);189 assertThat(readCapabilities).isEqualTo(capabilities);190 }191 @Test192 public void shouldUseAMapToRepresentComplexObjects() {193 String toModel = "{\"thing\": \"hairy\", \"hairy\": true}";194 Map<?,?> modelled = new Json().toType(toModel, Object.class);195 assertThat(modelled).hasSize(2);196 }197 @Test198 public void shouldConvertAResponseWithAnElementInIt() {199 String json =200 "{\"value\":{\"value\":\"\",\"text\":\"\",\"selected\":false,\"enabled\":true,\"id\":\"three\"},\"context\":\"con\",\"sessionId\":\"sess\"}";201 Response converted = new Json().toType(json, Response.class);202 Map<String, Object> value = (Map<String, Object>) converted.getValue();203 assertThat(value).containsEntry("id", "three");204 }205 @Test206 public void shouldBeAbleToCopeWithStringsThatLookLikeBooleans() {207 String json = "{\"value\":\"false\",\"context\":\"foo\",\"sessionId\":\"1210083863107\"}";208 new Json().toType(json, Response.class);209 }210 @Test211 public void shouldBeAbleToSetAnObjectToABoolean() {212 String json = "{\"value\":true,\"context\":\"foo\",\"sessionId\":\"1210084658750\"}";213 Response response = new Json().toType(json, Response.class);214 assertThat(response.getValue()).isEqualTo(true);215 }216 @Test217 public void canHandleValueBeingAnArray() {218 String[] value = {"Cheese", "Peas"};219 Response response = new Response();220 response.setSessionId("bar");221 response.setValue(value);222 response.setStatus(1512);223 String json = new Json().toJson(response);224 Response converted = new Json().toType(json, Response.class);225 assertThat(response.getSessionId()).isEqualTo("bar");226 assertThat(((List<?>) converted.getValue())).hasSize(2);227 assertThat(response.getStatus().intValue()).isEqualTo(1512);228 }229 @Test230 public void shouldConvertObjectsInArraysToMaps() {231 Date date = new Date();232 Cookie cookie = new Cookie("foo", "bar", "localhost", "/rooted", date, true, true);233 String rawJson = new Json().toJson(Collections.singletonList(cookie));234 List<?> list = new Json().toType(rawJson, List.class);235 Object first = list.get(0);236 assertThat(first instanceof Map).isTrue();237 Map<String, Object> map = (Map<String, Object>) first;238 assertThat(map)239 .containsEntry("name", "foo")240 .containsEntry("value", "bar")241 .containsEntry("domain", "localhost")242 .containsEntry("path", "/rooted")243 .containsEntry("secure", true)244 .containsEntry("httpOnly", true)245 .containsEntry("expiry", TimeUnit.MILLISECONDS.toSeconds(date.getTime()));246 }247 @Test248 public void shouldConvertAnArrayBackIntoAnArray() {249 Exception e = new Exception();250 String converted = new Json().toJson(e);251 Map<?,?> reconstructed = new Json().toType(converted, Map.class);252 List<?> trace = (List<?>) reconstructed.get("stackTrace");253 assertThat(trace.get(0)).isInstanceOf(Map.class);254 }255 @Test256 public void sShouldBeAbleToReconsituteASessionId() {257 String json = new Json().toJson(new SessionId("id"));258 SessionId sessionId = new Json().toType(json, SessionId.class);259 assertThat(sessionId.toString()).isEqualTo("id");260 }261 @Test262 public void shouldBeAbleToConvertACommand() {263 SessionId sessionId = new SessionId("session id");264 Command original = new Command(265 sessionId,266 DriverCommand.NEW_SESSION,267 ImmutableMap.of("food", "cheese"));268 String raw = new Json().toJson(original);269 Command converted = new Json().toType(raw, Command.class);270 assertThat(converted.getSessionId().toString()).isEqualTo(sessionId.toString());271 assertThat(converted.getName()).isEqualTo(original.getName());272 assertThat(converted.getParameters().keySet()).hasSize(1);273 assertThat(converted.getParameters().get("food")).isEqualTo("cheese");274 }275 @Test276 public void shouldConvertCapabilitiesToAMapAndIncludeCustomValues() {277 Capabilities caps = new ImmutableCapabilities("furrfu", "fishy");278 String raw = new Json().toJson(caps);279 Capabilities converted = new Json().toType(raw, Capabilities.class);280 assertThat(converted.getCapability("furrfu")).isEqualTo("fishy");281 }282 @Test283 public void shouldParseCapabilitiesWithLoggingPreferences() {284 String caps = String.format(285 "{\"%s\": {" +286 "\"browser\": \"WARNING\"," +287 "\"client\": \"DEBUG\", " +288 "\"driver\": \"ALL\", " +289 "\"server\": \"OFF\"}}",290 CapabilityType.LOGGING_PREFS);291 Capabilities converted = new Json().toType(caps, Capabilities.class);292 LoggingPreferences lp =293 (LoggingPreferences) converted.getCapability(CapabilityType.LOGGING_PREFS);294 assertThat(lp).isNotNull();295 assertThat(lp.getLevel(BROWSER)).isEqualTo(WARNING);296 assertThat(lp.getLevel(CLIENT)).isEqualTo(FINE);297 assertThat(lp.getLevel(DRIVER)).isEqualTo(ALL);298 assertThat(lp.getLevel(SERVER)).isEqualTo(OFF);299 }300 @Test301 public void shouldNotParseQuotedJsonObjectsAsActualJsonObjects() {302 String jsonStr = "{\"inner\":\"{\\\"color\\\":\\\"green\\\",\\\"number\\\":123}\"}";303 System.out.println(jsonStr);304 Object convertedOuter = new Json().toType(jsonStr, Map.class);305 assertThat(convertedOuter).isInstanceOf(Map.class);306 Object convertedInner = ((Map<?,?>) convertedOuter).get("inner");307 assertThat(convertedInner).isNotNull();308 assertThat(convertedInner).isInstanceOf(String.class);309 assertThat(convertedInner.toString()).isEqualTo("{\"color\":\"green\",\"number\":123}");310 }311 @Test312 public void shouldBeAbleToConvertASelenium3CommandToASelenium2Command() {313 SessionId expectedId = new SessionId("thisisakey");314 // In selenium 2, the sessionId is an object. In selenium 3, it's a straight string.315 String raw = "{\"sessionId\": \"" + expectedId.toString() + "\", " +316 "\"name\": \"some command\"," +317 "\"parameters\": {}}";318 Command converted = new Json().toType(raw, Command.class);319 assertThat(converted.getSessionId()).isEqualTo(expectedId);320 }321 @Test322 public void shouldCallFromJsonMethodIfPresent() {323 JsonAware res = new Json().toType("\"converted\"", JsonAware.class);324 assertThat(res.convertedValue).isEqualTo("converted");325 }326 @Test327 public void fromJsonMethodNeedNotBePublic() {328 JsonAware res = new Json().toType("\"converted\"", PrivatelyAware.class);329 assertThat(res.convertedValue).isEqualTo("converted");330 }331 @Test332 public void fromJsonMethodNeedNotOnlyAcceptAString() {333 Json json = new Json();334 String raw = json.toJson(ImmutableMap.of("cheese", "truffled brie"));335 MapTakingFromJsonMethod res = json.toType(raw, MapTakingFromJsonMethod.class);336 assertThat(res.cheese).isEqualTo("truffled brie");337 }338 // Test for issue 8187339 @Test340 public void decodingResponseWithNumbersInValueObject() {341 Response response = new Json().toType(342 "{\"status\":0,\"value\":{\"width\":96,\"height\":46.19140625}}",343 Response.class);344 @SuppressWarnings("unchecked")345 Map<String, Number> value = (Map<String, Number>) response.getValue();346 assertThat(value.get("width").intValue()).isEqualTo(96);347 assertThat(value.get("height").intValue()).isEqualTo(46);348 assertThat(value.get("height").doubleValue()).isCloseTo(46.19140625, byLessThan(0.00001));349 }350 @Test351 public void shouldRecognizeNumericStatus() {352 Response response = new Json().toType(353 "{\"status\":0,\"value\":\"cheese\"}",354 Response.class);355 assertThat(response.getStatus().intValue()).isEqualTo(0);356 assertThat(response.getState()).isEqualTo(new ErrorCodes().toState(0));357 String value = (String) response.getValue();358 assertThat(value).isEqualTo("cheese");359 }360 @Test361 public void shouldRecognizeStringStatus() {362 Response response = new Json().toType(363 "{\"status\":\"success\",\"value\":\"cheese\"}",364 Response.class);365 assertThat(response.getStatus().intValue()).isEqualTo(0);366 assertThat(response.getState()).isEqualTo(new ErrorCodes().toState(0));367 String value = (String) response.getValue();368 assertThat(value).isEqualTo("cheese");369 }370 @Test371 public void shouldConvertInvalidSelectorError() {372 Response response = new Json().toType(373 "{\"state\":\"invalid selector\",\"message\":\"invalid xpath selector\"}",374 Response.class);375 assertThat(response.getStatus().intValue()).isEqualTo(32);376 assertThat(response.getState()).isEqualTo(new ErrorCodes().toState(32));377 }378 @Test379 public void shouldRecognizeStringState() {380 Response response = new Json()381 .toType(382 "{\"state\":\"success\",\"value\":\"cheese\"}",383 Response.class);384 assertThat(response.getState()).isEqualTo("success");385 assertThat(response.getStatus().intValue()).isEqualTo(0);386 String value = (String) response.getValue();387 assertThat(value).isEqualTo("cheese");388 }389 @Test390 public void noStatusShouldBeNullInResponseObject() {391 Response response = new Json().toType("{\"value\":\"cheese\"}", Response.class);392 assertThat(response.getStatus()).isNull();393 }394 @Test395 public void canConvertAnEnumWithALowerCaseValue() {396 Proxy.ProxyType type = new Json().toType("\"pac\"", Proxy.ProxyType.class);397 assertThat(type).isEqualTo(PAC);398 }399 @Test400 public void canCoerceSimpleValuesToStrings() {401 Map<String, Object> value = ImmutableMap.of(402 "boolean", true,403 "integer", 42,404 "float", 3.14);405 Json json = new Json();406 String raw = json.toJson(value);407 Map<String, String> roundTripped = json.toType(408 raw,409 new TypeToken<Map<String, String>>(){}.getType());410 assertThat(roundTripped.get("boolean")).isEqualTo("true");411 assertThat(roundTripped.get("integer")).isEqualTo("42");412 assertThat(roundTripped.get("float")).isEqualTo("3.14");413 }414 public static class SimpleBean {415 private String value;416 public String getValue() {417 return value;418 }419 public void setValue(String value) {420 this.value = value;421 }422 }423 public static class ContainingBean {424 private String name;425 private SimpleBean bean;426 public String getName() {427 return name;428 }429 public void setName(String name) {430 this.name = name;431 }432 public SimpleBean getBean() {433 return bean;434 }435 public void setBean(SimpleBean bean) {436 this.bean = bean;437 }438 }439 public static class JsonAware {440 private String convertedValue;441 public JsonAware(String convertedValue) {442 this.convertedValue = convertedValue;443 }444 public static JsonAware fromJson(String json) {445 return new JsonAware(json);446 }447 }448 public static class PrivatelyAware {449 private String convertedValue;450 public PrivatelyAware(String convertedValue) {451 this.convertedValue = convertedValue;452 }453 private static JsonAware fromJson(String json) {454 return new JsonAware(json);455 }456 }457 public static class MapTakingFromJsonMethod {458 private String cheese;459 private static MapTakingFromJsonMethod fromJson(Map<String, Object> args) {460 MapTakingFromJsonMethod toReturn = new MapTakingFromJsonMethod();461 toReturn.cheese = String.valueOf(args.get("cheese"));462 return toReturn;463 }464 }465}...

Full Screen

Full Screen

Source:WebDriverManager.java Github

copy

Full Screen

...96 FirefoxProfile ffProfile = new FirefoxProfile();97 if (SuitesService.PROXY_ENABLE == true){98 ffProfile.setPreference("network.proxy.type", 1); // Configuracion Manual99 ffProfile.setPreference("network.proxy.http", SuitesService.PROXY_HOST);100 ffProfile.setPreference("network.proxy.http_port", Integer.valueOf(SuitesService.PROXY_PORT));101 ffProfile.setPreference("network.proxy.ssl", SuitesService.PROXY_HOST);102 ffProfile.setPreference("network.proxy.ssl_port", Integer.valueOf(SuitesService.PROXY_PORT));103 ffProfile.setPreference("network.proxy.no_proxies_on", SuitesService.NO_PROXY_HOST);104 }105 capability.setCapability(PROFILE, ffProfile);106 return new FirefoxDriver(capability);107 case "safari":108 return new SafariDriver();109 default:110 throw new qaTestException("Navegador [" + SuitesService.BROWSER + "] no soportado!");111 }112 }113 114 /** 115 * <b>Nombre:</b> initGridDriver</br></br>116 * <b>Description:</b> Inicializa el controlador de selenium grid117 * @return WebDriver Rerotna un Objeto de tipo WebDriver basado en los parametros de config.properties o entorno de Jenkins118 **/119 private WebDriver initGridDriver(){120 DesiredCapabilities capability;121 switch(SuitesService.BROWSER) {122 case "chrome": 123 Map <String, String> mobileEmulation = new HashMap <String, String>();124 Map <String, Object> chromeOptions = new HashMap <String, Object>();125 capability = DesiredCapabilities.chrome();126 capability.setPlatform(Platform.VISTA);127 chromeOptions.put("args", Arrays.asList("test-type"));128 if(isMobile) {129 switch (SuitesService.MOBILE_EMUL) {130 case "GalaxyS5" : mobileEmulation.put("deviceName", "Galaxy S5"); break;131 case "iPhone6" : mobileEmulation.put("deviceName", "iPhone 6"); break;132 case "Nexus7" : mobileEmulation.put("deviceName", "Nexus 7"); break;133 }134 chromeOptions.put("mobileEmulation", mobileEmulation);135 }136 capability.setCapability(ChromeOptions.CAPABILITY, chromeOptions);137 if (SuitesService.PROXY_ENABLE == true){138 capability.setCapability(PROXY, getProxySettings());139 } 140 break; 141 case "ie":142 capability = DesiredCapabilities.internetExplorer();143 capability.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);144 capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);145 capability.setCapability("ignoreZoomSetting", true);146 capability.setPlatform(Platform.VISTA);147 break;148 case "firefox":149 capability = DesiredCapabilities.firefox();150 FirefoxProfile ffProfile = new FirefoxProfile();151 if (SuitesService.PROXY_ENABLE == true){152 ffProfile.setPreference("network.proxy.type", 1); // Configuracion Manual153 ffProfile.setPreference("network.proxy.http", SuitesService.PROXY_HOST);154 ffProfile.setPreference("network.proxy.http_port", Integer.valueOf(SuitesService.PROXY_PORT));155 ffProfile.setPreference("network.proxy.ssl", SuitesService.PROXY_HOST);156 ffProfile.setPreference("network.proxy.ssl_port", Integer.valueOf(SuitesService.PROXY_PORT));157 ffProfile.setPreference("network.proxy.no_proxies_on", SuitesService.NO_PROXY_HOST);158 }159 capability.setBrowserName("firefox");160 capability.setPlatform(Platform.VISTA);161 capability.setCapability(PROFILE, ffProfile);162 break;163 case "safari":164 capability = DesiredCapabilities.safari();165 capability.setPlatform(Platform.MAC);166 break;167 default:168 throw new qaTestException("Navegador [" + SuitesService.BROWSER + "] no soportado!");169 }170 try {...

Full Screen

Full Screen

Source:WebDriverProcessor.java Github

copy

Full Screen

...61 if(oProperties.containsKey("ImplicitWait"))62 {63 if(!oProperties.getProperty("ImplicitWait").isEmpty())64 {65 lngImplicitWait = Long.valueOf(oProperties.getProperty("ImplicitWait"));66 }67 }68 69 if(oProperties.containsKey("PageLoadTimeout"))70 {71 if(!oProperties.getProperty("PageLoadTimeout").isEmpty())72 {73 lngPageLoadTimeout = Long.valueOf(oProperties.getProperty("PageLoadTimeout"));74 }75 }76 oBrowser.manage().window().maximize();77 //Commented this line of code since we need cookie id for verificaion in DB78 //oBrowser.manage().deleteAllCookies();79 oBrowser.manage().timeouts().implicitlyWait(lngImplicitWait, TimeUnit.SECONDS);80 //oBrowser.manage().timeouts().pageLoadTimeout(lngPageLoadTimeout, TimeUnit.SECONDS);81 82 if (ApplicationLink.URL2.equals(applicationLinks)) {83 oBrowser.get(oProperties.getProperty("URL2"));84 }85 else {86 oBrowser.get(oProperties.getProperty("BaseUrl"));87 } ...

Full Screen

Full Screen

Source:WebDriverFactory.java Github

copy

Full Screen

...61 throw new IllegalStateException("The webdriver system property must be set");62 }63 try {64 Proxy proxy = null;65 if (Boolean.valueOf(Env.getProperty("proxy.enable", "false"))) {66 String proxyDetails = String.format("%s:%d", Env.getProperty("proxy.host"), Integer.valueOf(Env.getProperty("proxy.port")));67 proxy = new Proxy();68 proxy.setProxyType(MANUAL);69 proxy.setHttpProxy(proxyDetails);70 proxy.setSslProxy(proxyDetails);71 }72 return Drivers.valueOf(webDriverProperty.toUpperCase()).newDriver(proxy, Env.getProperty("remote.hub"));73 } catch (Exception e) {74 String msg = String.format("The webdriver system property '%s' did not match any " +75 "existing browser or the browser was not supported on your operating system. " +76 "Valid values are %s",77 webDriverProperty, Arrays.stream(Drivers78 .values())79 .map(Enum::name)80 .map(String::toLowerCase)81 .collect(Collectors.toList()));82 throw new RuntimeException(msg, e);83 }84 }85 private enum Drivers {86 FIREFOX {...

Full Screen

Full Screen

Source:DriverSelector.java Github

copy

Full Screen

...7import java.net.MalformedURLException;8import java.net.URL;9import static org.openqa.selenium.Proxy.ProxyType.MANUAL;10import static selenium.config.DriverEnum.CHROME;11import static selenium.config.DriverEnum.valueOf;12public class DriverSelector {13 private WebDriver webdriver;14 private DriverEnum selectedDriverType;15 private final DriverEnum defaultDriverType = CHROME;16 private final String browser = System.getProperty("browser", defaultDriverType.toString()).toUpperCase();17 private final String operatingSystem = System.getProperty("os.name").toUpperCase();18 private final String systemArchitecture = System.getProperty("os.arch");19 private final boolean useRemoteWebDriver = Boolean.getBoolean("remoteDriver");20 private final boolean proxyEnabled = Boolean.getBoolean("proxyEnabled");21 private final String proxyHostname = System.getProperty("proxyHost");22 private final Integer proxyPort = Integer.getInteger("proxyPort");23 private final String proxyDetails = String.format("%s:%d", proxyHostname, proxyPort);24 public WebDriver getDriver() throws Exception {25 if (null == webdriver) {26 Proxy proxy = null;27 if (proxyEnabled) {28 proxy = new Proxy();29 proxy.setProxyType(MANUAL);30 proxy.setHttpProxy(proxyDetails);31 proxy.setSslProxy(proxyDetails);32 }33 determineEffectiveDriverType();34 DesiredCapabilities desiredCapabilities = selectedDriverType.getDesiredCapabilities(proxy);35 instantiateWebDriver(desiredCapabilities);36 }37 return webdriver;38 }39 public void quitDriver() {40 if (null != webdriver) {41 webdriver.quit();42 }43 }44 private void determineEffectiveDriverType() {45 DriverEnum driverType = defaultDriverType;46 try {47 driverType = valueOf(browser);48 } catch (IllegalArgumentException ignored) {49 System.err.println("Unknown driver specified, defaulting to '" + driverType + "'...");50 } catch (NullPointerException ignored) {51 System.err.println("No driver specified, defaulting to '" + driverType + "'...");52 }53 selectedDriverType = driverType;54 }55 private void instantiateWebDriver(DesiredCapabilities desiredCapabilities) throws MalformedURLException {56 System.out.println(" ");57 System.out.println("Current Operating System: " + operatingSystem);58 System.out.println("Current Architecture: " + systemArchitecture);59 System.out.println("Current Browser Selection: " + selectedDriverType);60 System.out.println(" ");61 if (useRemoteWebDriver) {62 URL seleniumGridURL = new URL(System.getProperty("gridURL"));63 String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");64 String desiredPlatform = System.getProperty("desiredPlatform");65 if (null != desiredPlatform && !desiredPlatform.isEmpty()) {66 desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));67 }68 if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {69 desiredCapabilities.setVersion(desiredBrowserVersion);70 }71 webdriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);72 } else {73 webdriver = selectedDriverType.getWebDriverObject(desiredCapabilities);74 }75 }76}...

Full Screen

Full Screen

valueOf

Using AI Code Generation

copy

Full Screen

1public enum ProxyType{2 DIRECT, MANUAL, PAC, AUTODETECT, SYSTEM, UNRECOGNIZED;3 public static ProxyType valueOf(String name) {4 try {5 return valueOf(name.toUpperCase());6 } catch (IllegalArgumentException e) {7 return UNRECOGNIZED;8 }9 }10}11public enum ProxyType{12 DIRECT, MANUAL, PAC, AUTODETECT, SYSTEM, UNRECOGNIZED;13 public static ProxyType valueOf(String name) {14 try {15 return valueOf(name.toUpperCase());16 } catch (IllegalArgumentException e) {17 return UNRECOGNIZED;18 }19 }20}21public enum ProxyType{22 DIRECT, MANUAL, PAC, AUTODETECT, SYSTEM, UNRECOGNIZED;23 public static ProxyType valueOf(String name) {24 try {25 return valueOf(name.toUpperCase());26 } catch (IllegalArgumentException e) {27 return UNRECOGNIZED;28 }29 }30}31public enum ProxyType{32 DIRECT, MANUAL, PAC, AUTODETECT, SYSTEM, UNRECOGNIZED;33 public static ProxyType valueOf(String name) {34 try {35 return valueOf(name.toUpperCase());36 } catch (IllegalArgumentException e) {37 return UNRECOGNIZED;38 }39 }40}41public enum ProxyType{42 DIRECT, MANUAL, PAC, AUTODETECT, SYSTEM, UNRECOGNIZED;43 public static ProxyType valueOf(String name) {44 try {45 return valueOf(name.toUpperCase());46 } catch (IllegalArgumentException e) {47 return UNRECOGNIZED;48 }49 }50}

Full Screen

Full Screen

valueOf

Using AI Code Generation

copy

Full Screen

1Proxy.ProxyType proxyType = Proxy.ProxyType.valueOf("DIRECT");2proxy.setProxyType(proxyType);3capabilities.setCapability(CapabilityType.PROXY, proxy);4proxy.setProxyType(Proxy.ProxyType.DIRECT);5capabilities.setCapability(CapabilityType.PROXY, proxy);6proxy.setProxyType(Proxy.ProxyType.DIRECT);7capabilities.setCapability(CapabilityType.PROXY, proxy);8proxy.setProxyType(Proxy.ProxyType.DIRECT);9capabilities.setCapability(CapabilityType.PROXY, proxy);10proxy.setProxyType(Proxy.ProxyType.DIRECT);11capabilities.setCapability(CapabilityType.PROXY, proxy);12proxy.setProxyType(Proxy.ProxyType.DIRECT);13capabilities.setCapability(CapabilityType.PROXY, proxy);14proxy.setProxyType(Proxy.ProxyType.DIRECT);15capabilities.setCapability(CapabilityType.PROXY, proxy);16proxy.setProxyType(Proxy.ProxyType.DIRECT);17capabilities.setCapability(CapabilityType.PROXY, proxy);18proxy.setProxyType(Proxy.ProxyType.DIRECT);

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.

Most used method in Enum-Proxy.ProxyType

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful