How to use DesiredCapabilities class of org.openqa.selenium.remote package

Best Selenium code snippet using org.openqa.selenium.remote.DesiredCapabilities

Source:DefaultDriverSessions.java Github

copy

Full Screen

...13package shaded.org.openqa.selenium.remote.server;14import org.openqa.selenium.Capabilities;15import org.openqa.selenium.Platform;16import org.openqa.selenium.WebDriver;17import org.openqa.selenium.remote.DesiredCapabilities;18import org.openqa.selenium.remote.SessionId;19import java.util.Collections;20import java.util.HashMap;21import java.util.Map;22import java.util.ServiceLoader;23import java.util.Set;24import java.util.UUID;25import java.util.concurrent.ConcurrentHashMap;26import java.util.logging.Level;27import java.util.logging.Logger;28public class DefaultDriverSessions implements DriverSessions {29 private static final Logger log = Logger.getLogger(DefaultDriverSessions.class.getName());30 private final shaded.org.openqa.selenium.remote.server.DriverFactory factory;31 private final Map<SessionId, shaded.org.openqa.selenium.remote.server.Session> sessionIdToDriver =32 new ConcurrentHashMap<SessionId, shaded.org.openqa.selenium.remote.server.Session>();33 private static Map<Capabilities, String> defaultDrivers = new HashMap<Capabilities, String>() {{34 put(DesiredCapabilities.chrome(), "org.openqa.selenium.chrome.ChromeDriver");35 put(DesiredCapabilities.firefox(), "org.openqa.selenium.firefox.FirefoxDriver");36 put(DesiredCapabilities.htmlUnit(), "org.openqa.selenium.htmlunit.HtmlUnitDriver");37 put(DesiredCapabilities.internetExplorer(), "org.openqa.selenium.ie.InternetExplorerDriver");38 put(DesiredCapabilities.opera(), "com.opera.core.systems.OperaDriver");39 put(DesiredCapabilities.safari(), "org.openqa.selenium.safari.SafariDriver");40 put(DesiredCapabilities.phantomjs(), "org.openqa.selenium.phantomjs.PhantomJSDriver");41 }};42 public DefaultDriverSessions() {43 this(Platform.getCurrent(), new shaded.org.openqa.selenium.remote.server.DefaultDriverFactory());44 }45 public DefaultDriverSessions(46 shaded.org.openqa.selenium.remote.server.DriverFactory factory, Map<Capabilities, Class<? extends WebDriver>> drivers) {47 this.factory = factory;48 for (Map.Entry<Capabilities, Class<? extends WebDriver>> entry : drivers.entrySet()) {49 registerDriver(entry.getKey(), entry.getValue());50 }51 }52 protected DefaultDriverSessions(Platform runningOn, shaded.org.openqa.selenium.remote.server.DriverFactory factory) {53 this.factory = factory;54 registerDefaults(runningOn);...

Full Screen

Full Screen

Source:ExistingRemoteWebDriver.java Github

copy

Full Screen

...5import java.net.URL;6import java.util.Map;7import org.openqa.selenium.Capabilities;8import org.openqa.selenium.remote.CommandExecutor;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.openqa.selenium.remote.DriverCommand;11import org.openqa.selenium.remote.HttpCommandExecutor;12import org.openqa.selenium.remote.RemoteWebDriver;13import org.openqa.selenium.remote.Response;14import org.openqa.selenium.remote.http.JsonHttpCommandCodec;15import org.openqa.selenium.remote.http.JsonHttpResponseCodec;16import org.openqa.selenium.remote.http.W3CHttpCommandCodec;17import org.openqa.selenium.remote.http.W3CHttpResponseCodec;18import com.kms.katalon.selenium.driver.IExistingRemoteWebDriver;19public class ExistingRemoteWebDriver extends RemoteWebDriver implements IExistingRemoteWebDriver {20 private static final int REMOTE_BROWSER_CONNECT_TIMEOUT = 60000;21 22 private static Field EXECUTOR_COMMAND_CODEC_FIELD;23 24 private static Field EXECUTOR_RESPONSE_CODEC_FIELD;25 26 static {27 try {28 EXECUTOR_COMMAND_CODEC_FIELD = HttpCommandExecutor.class.getDeclaredField("commandCodec");29 EXECUTOR_COMMAND_CODEC_FIELD.setAccessible(true);30 31 EXECUTOR_RESPONSE_CODEC_FIELD = HttpCommandExecutor.class.getDeclaredField("responseCodec");32 EXECUTOR_RESPONSE_CODEC_FIELD.setAccessible(true);33 } catch (NoSuchFieldException e) {34 //ignore35 } catch (SecurityException e) {36 //ignore37 }38 39 }40 private String oldSessionId;41 public ExistingRemoteWebDriver(URL remoteAddress, String oldSessionId) throws ConnectException {42 super(remoteAddress, new DesiredCapabilities());43 waitForRemoteBrowserReady(remoteAddress);44 setSessionId(oldSessionId);45 this.oldSessionId = oldSessionId;46 47 if (getCommandExecutor() instanceof HttpCommandExecutor) {48 try {49 initCodecForHttpCommandExecutor();50 } catch (IllegalArgumentException e) {51 //ignore52 } catch (IllegalAccessException e) {53 //ignore54 }55 }56 startClient();57 startSession(new DesiredCapabilities());58 }59 60 private void initCodecForHttpCommandExecutor() throws IllegalArgumentException, IllegalAccessException {61 HttpCommandExecutor executor = (HttpCommandExecutor) getCommandExecutor();62 63 // try to execute a test command for each kind of codec and verify the response status to find which one works64 EXECUTOR_COMMAND_CODEC_FIELD.set(executor, new JsonHttpCommandCodec());65 EXECUTOR_RESPONSE_CODEC_FIELD.set(executor, new JsonHttpResponseCodec());66 67 // Fix action in test case does not work when executing test case by Debug active session function (KAT-2954),68 // due to wrong command and response codec69 Response response = this.execute("status");70 if (!(response.getStatus() != null && response.getStatus() == 0)) {71 EXECUTOR_COMMAND_CODEC_FIELD.set(executor, new W3CHttpCommandCodec());...

Full Screen

Full Screen

Source:DesiredCapabilities.java Github

copy

Full Screen

...25import org.openqa.selenium.MutableCapabilities;26import org.openqa.selenium.Platform;27import java.util.Map;28import java.util.logging.Logger;29public class DesiredCapabilities extends MutableCapabilities {30 private static final Logger LOG = Logger.getLogger(Capabilities.class.getName());31 public DesiredCapabilities(String browser, String version, Platform platform) {32 setCapability(BROWSER_NAME, browser);33 setCapability(VERSION, version);34 setCapability(PLATFORM, platform);35 }36 public DesiredCapabilities() {37 // no-arg constructor38 }39 public DesiredCapabilities(Map<String, ?> rawMap) {40 if (rawMap == null) {41 return;42 }43 rawMap.forEach(this::setCapability);44 }45 public DesiredCapabilities(Capabilities other) {46 merge(other);47 }48 public DesiredCapabilities(Capabilities... others) {49 for (Capabilities caps : others) {50 merge(caps);51 }52 }53 public void setBrowserName(String browserName) {54 setCapability(BROWSER_NAME, browserName);55 }56 public void setVersion(String version) {57 setCapability(VERSION, version);58 }59 public void setPlatform(Platform platform) {60 setCapability(PLATFORM, platform);61 }62 public void setJavascriptEnabled(boolean javascriptEnabled) {63 setCapability(SUPPORTS_JAVASCRIPT, javascriptEnabled);64 }65 public boolean acceptInsecureCerts() {66 if (getCapability(ACCEPT_INSECURE_CERTS) != null) {67 Object raw = getCapability(ACCEPT_INSECURE_CERTS);68 if (raw instanceof String) {69 return Boolean.parseBoolean((String) raw);70 } else if (raw instanceof Boolean) {71 return ((Boolean) raw).booleanValue();72 }73 }74 return true;75 }76 public void setAcceptInsecureCerts(boolean acceptInsecureCerts) {77 setCapability(ACCEPT_INSECURE_CERTS, acceptInsecureCerts);78 }79 /**80 * Merges the extra capabilities provided into this DesiredCapabilities instance. If capabilities81 * with the same name exist in this instance, they will be overridden by the values from the82 * extraCapabilities object.83 *84 * @param extraCapabilities Additional capabilities to be added.85 * @return DesiredCapabilities after the merge86 */87 @Override88 public DesiredCapabilities merge(Capabilities extraCapabilities) {89 super.merge(extraCapabilities);90 return this;91 }92 @Deprecated93 @VisibleForTesting94 public static DesiredCapabilities htmlUnit() {95 return new DesiredCapabilities(BrowserType.HTMLUNIT, "", Platform.ANY);96 }97}...

Full Screen

Full Screen

Source:NewSession.java Github

copy

Full Screen

...14import com.google.common.collect.Maps;15import org.openqa.selenium.Capabilities;16import org.openqa.selenium.logging.LoggingPreferences;17import org.openqa.selenium.remote.CapabilityType;18import org.openqa.selenium.remote.DesiredCapabilities;19import org.openqa.selenium.remote.Response;20import org.openqa.selenium.remote.SessionId;21import shaded.org.openqa.selenium.remote.server.DriverSessions;22import shaded.org.openqa.selenium.remote.server.JsonParametersAware;23import shaded.org.openqa.selenium.remote.server.log.LoggingManager;24import shaded.org.openqa.selenium.remote.server.rest.RestishHandler;25import java.util.Map;26public class NewSession implements RestishHandler<Response>, JsonParametersAware {27 private volatile DriverSessions allSessions;28 private volatile Capabilities desiredCapabilities;29 private volatile SessionId sessionId;30 public NewSession(DriverSessions allSession) {31 this.allSessions = allSession;32 }33 public Capabilities getCapabilities() {34 return desiredCapabilities;35 }36 37 @SuppressWarnings({"unchecked"})38 public void setJsonParameters(Map<String, Object> allParameters)39 throws Exception {40 desiredCapabilities = new DesiredCapabilities(41 (Map<String, Object>) allParameters.get("desiredCapabilities"));42 }43 @Override44 public Response handle() throws Exception {45 // Handle the case where the client does not send any desired capabilities.46 sessionId = allSessions.newSession(desiredCapabilities != null47 ? desiredCapabilities : new DesiredCapabilities());48 Map<String, Object> capabilities =49 Maps.newHashMap(allSessions.get(sessionId).getCapabilities().asMap());50 // Only servers implementing the server-side webdriver-backed selenium need51 // to return this particular value52 capabilities.put("webdriver.remote.sessionid", sessionId.toString());53 if (desiredCapabilities != null) {54 LoggingManager.perSessionLogHandler().configureLogging(55 (LoggingPreferences)desiredCapabilities.getCapability(CapabilityType.LOGGING_PREFS));56 }57 LoggingManager.perSessionLogHandler().attachToCurrentThread(sessionId);58 Response response = new Response();59 response.setSessionId(sessionId.toString());60 response.setValue(capabilities);61 return response;...

Full Screen

Full Screen

Source:SauceCapabilities.java Github

copy

Full Screen

1package com.saucelabs;2import org.apache.commons.lang3.ArrayUtils;3import org.openqa.selenium.remote.DesiredCapabilities;4import static org.openqa.selenium.remote.DesiredCapabilities.android;5import static org.openqa.selenium.remote.DesiredCapabilities.firefox;6import static org.openqa.selenium.remote.DesiredCapabilities.internetExplorer;7import static org.openqa.selenium.remote.DesiredCapabilities.ipad;8import static org.openqa.selenium.remote.DesiredCapabilities.iphone;9public class SauceCapabilities {10 public static final DesiredCapabilities[] IPAD_ON_IOS_8 = iOS(ipad(), "8.0");11 public static final DesiredCapabilities[] IPAD_ON_IOS_7_1 = iOS(ipad(), "7.1");12 public static final DesiredCapabilities[] IPHONE_ON_IOS_8 = iOS(iphone(), "8.0");13 public static final DesiredCapabilities[] IPHONE_ON_IOS_7_1 = iOS(iphone(), "7.1");14 public static final DesiredCapabilities[] ANDROID_4_4 = droid("4.4");15 public static final DesiredCapabilities[] ANDROID_4_3 = droid("4.3");16 public static final DesiredCapabilities[] ANDROID_4_2 = droid("4.2");17 public static final DesiredCapabilities[] FF_WIN_8_1 = generic(firefox(), "32", "Windows 8.1");18 public static final DesiredCapabilities[] FF_WIN_8 = generic(firefox(), "32", "Windows 8");19 public static final DesiredCapabilities[] IE_11 = ie("11", "Windows 8.1");20 public static final DesiredCapabilities[] IE_10 = ie("10", "Windows 8");21 private static DesiredCapabilities[] iOS(DesiredCapabilities caps, String version) {22 return genericMobile(caps, version, "OS X 10.9");23 }24 private static DesiredCapabilities[] droid(String version) {25 return genericMobile(android(), version, "Linux");26 }27 private static DesiredCapabilities[] ie(String version, String os) {28 return generic(internetExplorer(), version, os);29 }30 private static DesiredCapabilities[] genericMobile(DesiredCapabilities caps, String version,31 String os) {32 caps.setCapability("device-orientation", "portrait");33 return generic(caps, version, os);34 }35 private static DesiredCapabilities[] generic(DesiredCapabilities caps, String version,36 String os) {37 caps.setCapability("platform", os);38 caps.setCapability("version", version);39 return ArrayUtils.toArray(caps);40 }41}...

Full Screen

Full Screen

Source:AddConfig.java Github

copy

Full Screen

...15import java.util.List;16import java.util.Map;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.remote.Capabilities;19import org.openqa.selenium.remote.DesiredCapabilities;20import org.openqa.selenium.remote.server.DriverSessions;21import org.openqa.selenium.remote.server.JsonParametersAware;22import org.openqa.selenium.remote.server.rest.Handler;23import org.openqa.selenium.remote.server.rest.ResultType;24import static org.openqa.selenium.remote.server.rest.ResultType.SUCCESS;25public class AddConfig implements Handler, JsonParametersAware {26 private final DriverSessions allSessions;27 private Capabilities desiredCapabilities;28 private String className;29 public AddConfig(DriverSessions allSessions) {30 this.allSessions = allSessions;31 }32 public void setJsonParameters(List<Object> allParameters) throws Exception {33 desiredCapabilities = new DesiredCapabilities((Map<String, Object>) allParameters.get(0));34 className = (String) allParameters.get(1);35 }36 public ResultType handle() throws Exception {37 // We'll let errors bubble up38 Class<? extends WebDriver> clazz = Class.forName(className).asSubclass(WebDriver.class);39 allSessions.registerDriver(desiredCapabilities, clazz);40 return SUCCESS;41 }42}...

Full Screen

Full Screen

Source:DesiredCapabilityFactory.java Github

copy

Full Screen

1package darr.mirr.utils;2import org.openqa.selenium.remote.DesiredCapabilities;3import static org.openqa.selenium.remote.BrowserType.CHROME;4import static org.openqa.selenium.remote.BrowserType.FIREFOX;5/**6 * Created by Darr Mirr on 21.07.17.7 *8 * Class creates DesiredCapabilities for required browser9 */10public class DesiredCapabilityFactory {11 private static DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();12 private static DesiredCapabilities firefoxCapabilities = DesiredCapabilities.firefox();13 private DesiredCapabilityFactory(){14 }15 public static DesiredCapabilities get(String browserName) {16 if (browserName == null) {17 throw new IllegalArgumentException("Browser name is null");18 }19 if (browserName.equalsIgnoreCase(CHROME)) {20 return chromeCapabilities;21 }22 if (browserName.equalsIgnoreCase(FIREFOX)) {23 return firefoxCapabilities;24 }25 throw new IllegalArgumentException("Can't find DesiredCapabilities for browser " + browserName);26 }27}...

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities caps = new DesiredCapabilities();2caps.setCapability("browser", "Chrome");3caps.setCapability("browser_version", "62.0");4caps.setCapability("os", "Windows");5caps.setCapability("os_version", "10");6caps.setCapability("resolution", "1024x768");7caps.setCapability("browserstack.debug", "true");8WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = new DesiredCapabilities();2capabilities.setCapability("browserName", "chrome");3capabilities.setCapability("platform", "Windows 10");4capabilities.setCapability("version", "latest");5driver.quit();6BrowserStackOptions browserStackOptions = new BrowserStackOptions();7browserStackOptions.setCapability("browserName", "chrome");8browserStackOptions.setCapability("platform", "Windows 10");9browserStackOptions.setCapability("version", "latest");10driver.quit();11BrowserStackOptions browserStackOptions = new BrowserStackOptions();12browserStackOptions.setCapability("browserName", "chrome");13browserStackOptions.setCapability("platform", "Windows 10");14browserStackOptions.setCapability("version", "latest");15WebDriver driver = new BrowserStack().createDriver(browserStackOptions);16driver.quit();17BrowserStackOptions browserStackOptions = new BrowserStackOptions();18browserStackOptions.setCapability("browserName", "chrome");19browserStackOptions.setCapability("platform", "Windows 10");20browserStackOptions.setCapability("version", "latest");21WebDriver driver = new BrowserStack().createDriver(browserStackOptions);22driver.quit();23DesiredCapabilities capabilities = new DesiredCapabilities();24capabilities.setCapability("browserName", "chrome");25capabilities.setCapability("platform", "Windows 10");26capabilities.setCapability("version", "latest");27WebDriver driver = new BrowserStack().createDriver(capabilities);28driver.quit();29DesiredCapabilities capabilities = new DesiredCapabilities();30capabilities.setCapability("browserName", "chrome");31capabilities.setCapability("platform", "Windows 10");32capabilities.setCapability("version", "latest");

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities cap = new DesiredCapabilities();2cap.setCapability("platformName", "Android");3cap.setCapability("deviceName", "Android Emulator");4cap.setCapability("browserName", "Chrome");5cap.setCapability("chromedriverExecutable", "C:\\Users\\Selenium\\Desktop\\chromedriver_win32\\chromedriver.exe");6cap.setCapability("noReset", true);7cap.setCapability("fullReset", false);8cap.setCapability("appPackage", "com.android.chrome");9cap.setCapability("appActivity", "com.google.android.apps.chrome.Main");10cap.setCapability("newCommandTimeout", 120);11cap.setCapability("unicodeKeyboard", true);12cap.setCapability("resetKeyboard", true);13cap.setCapability("autoGrantPermissions", true);14cap.setCapability("disable-popup-blocking", true);15cap.setCapability("disable-restore-session-state", true);16cap.setCapability("enable-automation", true);17cap.setCapability("start-maximized", true);

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities caps = DesiredCapabilities.chrome();2caps.setCapability("platform", "Windows 7");3caps.setCapability("version", "47.0");4WebDriver driver = new RemoteWebDriver(new URL(URL), caps);5driver.quit();6DesiredCapabilities caps = DesiredCapabilities.chrome();7caps.setCapability("platform", "Windows 7");8caps.setCapability("version", "47.0");9WebDriver driver = new RemoteWebDriver(new URL(URL), caps);10driver.quit();11ChromeOptions options = new ChromeOptions();12options.addArguments("test-type");13DesiredCapabilities caps = DesiredCapabilities.chrome();14caps.setCapability(ChromeOptions.CAPABILITY, options);15caps.setCapability("platform", "Windows 7");16caps.setCapability("version", "47.0");17WebDriver driver = new RemoteWebDriver(new URL(URL), caps);18driver.quit();19ChromeOptions options = new ChromeOptions();20options.addArguments("test-type");21DesiredCapabilities caps = DesiredCapabilities.chrome();22caps.setCapability(ChromeOptions.CAPABILITY, options);23caps.setCapability("platform", "Windows 7");24caps.setCapability("version", "47.0");25WebDriver driver = new RemoteWebDriver(new URL(URL), caps);26driver.quit();27ChromeOptions options = new ChromeOptions();28options.addArguments("test-type");29DesiredCapabilities caps = DesiredCapabilities.chrome();30caps.setCapability(ChromeOptions.CAPABILITY, options);31caps.setCapability("platform", "Windows 7");32caps.setCapability("version", "47.0");33WebDriver driver = new RemoteWebDriver(new URL(URL), caps);34driver.quit();35ChromeOptions options = new ChromeOptions();36options.addArguments("test-type");37DesiredCapabilities caps = DesiredCapabilities.chrome();38caps.setCapability(ChromeOptions.CAPABILITY, options);39caps.setCapability("platform", "Windows 7");40caps.setCapability("version", "47.0");41WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = DesiredCapabilities.chrome();2capabilities.setCapability("platform", "Windows 10");3capabilities.setCapability("version", "61.0");4RemoteWebDriver driver = new RemoteWebDriver(new URL(URL), capabilities);5By by = By.name("q");6WebElement element = driver.findElement(by);7Actions actions = new Actions(driver);8actions.sendKeys(element, "Selenium").sendKeys(Keys.ENTER).perform();9WebDriverWait wait = new WebDriverWait(driver, 10);10wait.until(ExpectedConditions.titleContains("Selenium"));11Assert.assertEquals(driver.getTitle(), "Selenium - Google Search");12JavascriptExecutor js = (JavascriptExecutor) driver;13WebElement element = (WebElement) js.executeScript("return document.activeElement");14Assert.assertEquals(element.getAttribute("name"), "q");15WebElement element = driver.findElement(By.name("q"));16((JavascriptExecutor) driver).executeScript("arguments[0].value='Selenium';", element);17Actions actions = new Actions(driver);18actions.sendKeys(element, Keys.ENTER).perform();19WebDriverWait wait = new WebDriverWait(driver, 10);20wait.until(ExpectedConditions.titleContains("Selenium"));21Assert.assertEquals(driver.getTitle(), "Selenium - Google Search");22WebElement element = driver.findElement(By.cssSelector("div.rc"));

Full Screen

Full Screen

DesiredCapabilities

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = DesiredCapabilities.chrome();2capabilities.setCapability("platform", "Windows 10");3capabilities.setCapability("version", "latest");4capabilities.setCapability("browserName", "chrome");5capabilities.setCapability("name", "Bstack-[Java] Sample Test");6capabilities.setCapability("build", "Bstack Build Number 1");7driver = new RemoteWebDriver(new URL(URL), capabilities);8driver.findElement(By.name("q")).sendKeys("BrowserStack");9driver.findElement(By.name("btnK")).click();10driver.quit();11ChromeOptions options = new ChromeOptions();12options.addArguments("--disable-notifications");13options.setCapability("platform", "Windows 10");14options.setCapability("version", "latest");15options.setCapability("browserName", "chrome");16options.setCapability("name", "Bstack-[Java] Sample Test");17options.setCapability("build", "Bstack Build Number 1");18driver = new RemoteWebDriver(new URL(URL), options);19driver.findElement(By.name("q")).sendKeys("BrowserStack");20driver.findElement(By.name("btnK")).click();21driver.quit();22FirefoxOptions options = new FirefoxOptions();23options.setCapability("platform", "Windows 10");24options.setCapability("version", "latest");25options.setCapability("browserName", "firefox");26options.setCapability("name", "Bstack-[Java] Sample Test");27options.setCapability("build", "Bstack Build Number 1");28driver = new RemoteWebDriver(new URL(URL), options);29driver.findElement(By.name("q")).sendKeys("BrowserStack");30driver.findElement(By.name("btnK")).click();31driver.quit();32InternetExplorerOptions options = new InternetExplorerOptions();33options.setCapability("platform", "Windows 10");34options.setCapability("version", "latest");35options.setCapability("browserName", "internet explorer");36options.setCapability("name", "Bstack-[Java] Sample Test");37options.setCapability("build", "Bstack Build Number 1");38driver = new RemoteWebDriver(new URL(URL), options);39driver.findElement(By.name("q")).sendKeys("BrowserStack");40driver.findElement(By.name("btnK

Full Screen

Full Screen
copy
1public class Example {23 public static void main(String[] args) {4 Object obj = null;5 obj.hashCode();6 }78}9
Full Screen
copy
1public class Printer {2 private String name;34 public void setName(String name) {5 this.name = name;6 }78 public void print() {9 printString(name);10 }1112 private void printString(String s) {13 System.out.println(s + " (" + s.length() + ")");14 }1516 public static void main(String[] args) {17 Printer printer = new Printer();18 printer.print();19 }20}21
Full Screen
copy
1public class Test {2 public static void main(String[] args) {3 String foo = null;4 int length = foo.length(); // HERE5 }6}7
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.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful