How to use MutableCapabilities class of org.openqa.selenium package

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

Source:BrowserSelector.java Github

copy

Full Screen

1package OrangeHrmFeature;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5import org.openqa.selenium.edge.EdgeDriver;6import org.openqa.selenium.edge.EdgeOptions;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.firefox.FirefoxOptions;9import org.openqa.selenium.ie.InternetExplorerDriver;10import org.openqa.selenium.ie.InternetExplorerOptions;11import org.openqa.selenium.remote.DesiredCapabilities;12import org.openqa.selenium.remote.RemoteWebDriver;13import org.openqa.selenium.safari.SafariOptions;14import java.net.MalformedURLException;15import java.net.URL;16public class BrowserSelector extends Utils {17 public static LoadProps loadProps = new LoadProps();18 public static final String USERNAME = loadProps.getProperty("SAUCE_USERNAME");19 public static final String ACCESS_KEY = loadProps.getProperty("SAUCE_ACCESS_KEY");20 public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.eu-central-1.saucelabs.com:443/wd/hub";21 public static final boolean SAUCE_LAB = Boolean.parseBoolean(System.getProperty("Sauce"));22 String browser = System.getProperty("browser");23 public void setUpBrowser() {24 System.out.println(USERNAME);25 System.out.println(ACCESS_KEY);26 //if sauce lab is true in TestDataConfig.properties.............................................................27 if(SAUCE_LAB)28 {29 System.out.println("Running in Saucelab...........with browser "+browser);30 if(browser.equalsIgnoreCase("Chrome"))31 {32 MutableCapabilities sauceOptions = new MutableCapabilities();33 ChromeOptions caps = new ChromeOptions();34 caps.setExperimentalOption("w3c",true);35 caps.setCapability("platformName","Windows 10");36 caps.setCapability("browserVersion","77.0");37 caps.setCapability("sauce:options",sauceOptions);38 try39 {40 driver = new RemoteWebDriver(new URL(URL), caps);41 }42 catch (MalformedURLException e)43 {44 e.printStackTrace();45 }46 }47 else if(browser.equalsIgnoreCase("IE"))48 {49 DesiredCapabilities caps = DesiredCapabilities.internetExplorer();50 caps.setCapability("platform","Windows 10");51 caps.setCapability("version","11");52 try53 {54 driver = new RemoteWebDriver(new URL(URL), caps);55 }56 catch (MalformedURLException e)57 {58 e.printStackTrace();59 }60 }61 else if (browser.equalsIgnoreCase("FireFox"))62 {63 DesiredCapabilities caps = DesiredCapabilities.firefox();64 caps.setCapability("platform","Windows 7");65 caps.setCapability("version","56");66 caps.setCapability("name","Testing on Firefox 56");67 try68 {69 driver = new RemoteWebDriver(new URL(URL),caps);70 }71 catch (MalformedURLException e)72 {73 e.printStackTrace();74 }75 }76 else if(browser.equalsIgnoreCase("Safari"))77 {78 DesiredCapabilities caps=DesiredCapabilities.safari();79 caps.setCapability("platform","os x 10.10");80 caps.setCapability("version","8.0");81 try82 {83 driver = new RemoteWebDriver(new URL(URL), caps);84 }85 catch (MalformedURLException e)86 {87 e.printStackTrace();88 }89 }90 else if(browser.equalsIgnoreCase("edge"))91 {92 DesiredCapabilities caps = DesiredCapabilities.edge();93 caps.setCapability("platform", "window 10");94 caps.setCapability("version", "16.16299");95 try96 {97 driver = new RemoteWebDriver(new URL(URL), caps);98 }99 catch (MalformedURLException e)100 {101 e.printStackTrace();102 }103 }104 else105 {106 System.out.println("wrong browser name or empty:"+browser);107 }108 }109 else110 {111 String browser = loadProps.getProperty("browser");112 if(browser.equalsIgnoreCase("chrome")){113 System.setProperty("webdriver.chrome.driver","src\\test\\Resources\\BrowserDriver\\chromedriver77.exe");114 driver = new ChromeDriver();115 }else if(browser.equalsIgnoreCase("firefox")){116 System.setProperty("webdriver.gecko.driver","src\\test\\Resources\\BrowserDriver\\geckodriver.exe");117 driver = new FirefoxDriver();118 }else if(browser.equalsIgnoreCase("edge")){119 System.setProperty("webdriver.edge.driver","src\\test\\Resources\\BrowserDriver\\IEDriverServer.exe");120 driver = new EdgeDriver();121 }122 }123 }124}125 /*If Sauce Lab is true...126 if (SAUCE_LAB) {127 System.out.println("Running in SauceLab......... with browser" + browser);128 if (browser.equalsIgnoreCase("Chrome"))129 {130 MutableCapabilities sauceOptions = new MutableCapabilities();131 ChromeOptions browserOptions = new ChromeOptions();132 browserOptions.setExperimentalOption("w3c", true);133 browserOptions.setCapability("platformName", "Windows 10");134 browserOptions.setCapability("browserVersion", "76.0");135 browserOptions.setCapability("sauce:options", sauceOptions);136 /*DesiredCapabilities caps = DesiredCapabilities.chrome();137 caps.setCapability("platform", "Windows 10");138 caps.setCapability("version", "76.0");*/139 /*try {140 driver = new RemoteWebDriver(new URL(URL), browserOptions);141 } catch (MalformedURLException e) {142 e.printStackTrace();143 }144 }145 else if (browser.equalsIgnoreCase("IE"))146 {147 MutableCapabilities sauceOptions = new MutableCapabilities();148 InternetExplorerOptions browserOptions = new InternetExplorerOptions();149 browserOptions.setCapability("platformName", "Windows 10");150 browserOptions.setCapability("browserVersion", "11.285");151 browserOptions.setCapability("sauce:options", sauceOptions);152 /*DesiredCapabilities caps = DesiredCapabilities.internetExplorer();153 caps.setCapability("platform", "Windows 10");154 caps.setCapability("Version", "11.285");*/155 /*try {156 driver = new RemoteWebDriver(new URL(URL),browserOptions);157 } catch (MalformedURLException e) {158 e.printStackTrace();159 }160 }161 else if (browser.equalsIgnoreCase("FireFox"))162 {163 MutableCapabilities sauceOptions = new MutableCapabilities();164 FirefoxOptions browserOptions = new FirefoxOptions();165 browserOptions.setCapability("platformName", "Windows 10");166 browserOptions.setCapability("browserVersion", "69.0");167 browserOptions.setCapability("sauce:options", sauceOptions);168 /*DesiredCapabilities caps = DesiredCapabilities.firefox();169 caps.setCapability("platform","Windows 10");170 caps.setCapability("version","69.0");171 caps.setCapability("name","Testing on FireFox 69.0");*/172 /*try {173 driver = new RemoteWebDriver(new URL(URL),browserOptions);174 } catch (MalformedURLException e) {175 e.printStackTrace();176 }177 }178 else if (browser.equalsIgnoreCase("safari"))179 {180 MutableCapabilities sauceOptions = new MutableCapabilities();181 SafariOptions browserOptions = new SafariOptions();182 browserOptions.setCapability("platformName", "macOS 10.14");183 browserOptions.setCapability("browserVersion", "12.0");184 browserOptions.setCapability("sauce:options", sauceOptions);185 /*DesiredCapabilities caps = DesiredCapabilities.safari();186 caps.setCapability("platform","macOS 10.14");187 caps.setCapability("version","12.0");*/188 /*try {189 driver = new RemoteWebDriver(new URL(URL),browserOptions);190 } catch (MalformedURLException e) {191 e.printStackTrace();192 }193 }194 else if (browser.equalsIgnoreCase("edge"))195 {196 MutableCapabilities sauceOptions = new MutableCapabilities();197 EdgeOptions browserOptions = new EdgeOptions();198 browserOptions.setCapability("platformName", "Windows 10");199 browserOptions.setCapability("browserVersion", "16.16299");200 browserOptions.setCapability("sauce:options", sauceOptions);201 /*DesiredCapabilities caps = DesiredCapabilities.edge();202 caps.setCapability("platform","Windows 10");203 caps.setCapability("version", "16.16299");*/204 /*try {205 driver = new RemoteWebDriver(new URL(URL),browserOptions);206 } catch (MalformedURLException e) {207 e.printStackTrace();208 }209 }210 else...

Full Screen

Full Screen

Source:DriverType.java Github

copy

Full Screen

1package ua.hotline.tests.seleniumTests.driver;2import io.github.bonigarcia.wdm.WebDriverManager;3import org.openqa.selenium.MutableCapabilities;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.firefox.FirefoxOptions;9import org.openqa.selenium.ie.InternetExplorerDriver;10import org.openqa.selenium.ie.InternetExplorerOptions;11import org.openqa.selenium.opera.OperaDriver;12import org.openqa.selenium.opera.OperaOptions;13import org.openqa.selenium.remote.CapabilityType;14import org.openqa.selenium.safari.SafariDriver;15import org.openqa.selenium.safari.SafariOptions;16import java.util.Arrays;17import java.util.HashMap;18public enum DriverType implements DriverSetup {19 FIREFOX {20 @Override21 public MutableCapabilities getDesiredCapabilities() {22 FirefoxOptions firefoxOptions = new FirefoxOptions();23 firefoxOptions.setCapability("marionette", true);24 return firefoxOptions;25 }26 @Override27 public WebDriver getWebDriverObject(MutableCapabilities capabilities) {28 WebDriverManager.firefoxdriver().setup();29 return new FirefoxDriver((FirefoxOptions) capabilities);30 }31 },32 CHROME {33 @Override34 public MutableCapabilities getDesiredCapabilities() {35 ChromeOptions chromeOptions = new ChromeOptions();36 chromeOptions.setCapability("chrome.switches",37 Arrays.asList("--no-default-browser-check",38 "--disable-extensions",39 "--disable-notifications",40 "--disable-translate",41 "--disable-infobars",42 "--disable-web-security",43 "--disable-save-password-bubble"));44 HashMap<String, String> chromePreferences = new HashMap<>();45 chromePreferences.put("profile.password_manager_enabled", "false");46 chromeOptions.setCapability("chrome.prefs", chromePreferences);47 return chromeOptions;48 }49 @Override50 public WebDriver getWebDriverObject(MutableCapabilities capabilities) {51 WebDriverManager.chromedriver().setup();52 return new ChromeDriver((ChromeOptions) capabilities);53 }54 },55 IE {56 @Override57 public MutableCapabilities getDesiredCapabilities() {58 MutableCapabilities capabilities = new InternetExplorerOptions();59 capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);60 capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true);61 capabilities.setCapability("requireWindowFocus", true);62 return capabilities;63 }64 @Override65 public WebDriver getWebDriverObject(MutableCapabilities capabilities) {66 WebDriverManager.iedriver().setup();67 return new InternetExplorerDriver((InternetExplorerOptions) capabilities);68 }69 },70 SAFARI {71 @Override72 public MutableCapabilities getDesiredCapabilities() {73 MutableCapabilities capabilities = new SafariOptions();74 capabilities.setCapability("safari.cleanSession", true);75 return capabilities;76 }77 @Override78 public WebDriver getWebDriverObject(MutableCapabilities capabilities) {79 return new SafariDriver((SafariOptions) capabilities);80 }81 },82 OPERA {83 @Override84 public MutableCapabilities getDesiredCapabilities() {85 return new OperaOptions();86 }87 @Override88 public WebDriver getWebDriverObject(MutableCapabilities capabilities) {89 WebDriverManager.operadriver().setup();90 return new OperaDriver((OperaOptions) capabilities);91 }92 }93}...

Full Screen

Full Screen

Source:RemoteDriverManager.java Github

copy

Full Screen

...3import driver.IDriver;4import io.github.bonigarcia.wdm.DriverManagerType;5import lombok.extern.log4j.Log4j2;6import org.aeonbits.owner.ConfigCache;7import org.openqa.selenium.MutableCapabilities;8import org.openqa.selenium.WebDriver;9import org.openqa.selenium.chrome.ChromeOptions;10import org.openqa.selenium.edge.EdgeOptions;11import org.openqa.selenium.firefox.FirefoxOptions;12import org.openqa.selenium.ie.InternetExplorerOptions;13import org.openqa.selenium.opera.OperaOptions;14import org.openqa.selenium.remote.RemoteWebDriver;15import java.net.MalformedURLException;16import java.net.URL;17@Log4j218public class RemoteDriverManager implements IDriver {19 @Override20 public WebDriver createInstance(String browser) {21 RemoteWebDriver remoteWebDriver = null;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();50 break;51 case IEXPLORER:52 mutableCapabilities = new InternetExplorerOptions();53 break;54 case PHANTOMJS:55 case SELENIUM_SERVER_STANDALONE:56 throw new IllegalStateException("Not supported: " + driverManagerType);57 default:58 throw new IllegalStateException("Unexpected value: " + driverManagerType);59 }60 return mutableCapabilities;61 }62 private static MutableCapabilities defaultChromeOptions() {63 ChromeOptions capabilities = new ChromeOptions();64 capabilities.addArguments("start-maximized");65 return capabilities;66 }67}...

Full Screen

Full Screen

Source:DriverFactory.java Github

copy

Full Screen

1package com.google.search.SearchEngine.Base;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.concurrent.TimeUnit;5import org.openqa.selenium.MutableCapabilities;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.chrome.ChromeOptions;9import org.openqa.selenium.edge.EdgeDriver;10import org.openqa.selenium.edge.EdgeOptions;11import org.openqa.selenium.firefox.FirefoxDriver;12import org.openqa.selenium.firefox.FirefoxOptions;13import org.openqa.selenium.remote.DesiredCapabilities;14import org.openqa.selenium.remote.RemoteWebDriver;15import com.google.searchEngine.Configuration.WebConfiguration;16import io.github.bonigarcia.wdm.WebDriverManager;17public class DriverFactory {18 public static WebDriver driver;19 public DriverFactory() {20 }21 public static MutableCapabilities setup(String env) {22 switch (env) {23 case "local":24 return setupLocal();25 case "remote":26 return setupRemote();27 default:28 return null;29 }30 }31 public static WebDriver build(String env, MutableCapabilities caps) throws MalformedURLException {32 switch (env) {33 case "local":34 return buildLocal(caps);35 case "remote":36 return buildRemote(caps);37 default:38 return null;39 }40 }41 public static MutableCapabilities setupLocal() {42 String browser = WebConfiguration.getBrowserName();43 MutableCapabilities caps = null;44 switch (browser.toLowerCase()) {45 case "chrome":46 ChromeOptions chromeOptions = new ChromeOptions();47 chromeOptions.addArguments("--start-maximized");48 caps = chromeOptions;49 break;50 case "edge":51 caps = new EdgeOptions();52 break;53 case "firefox":54 caps = new FirefoxOptions();55 break;56 default:57 break;58 }59 return caps;60 }61 public static MutableCapabilities setupRemote() {62 return new DesiredCapabilities();63 }64 public static WebDriver buildLocal(MutableCapabilities caps) {65 String browser = WebConfiguration.getBrowserName();66 switch (browser.toLowerCase()) {67 case "chrome":68 WebDriverManager.chromedriver().setup();69 driver = new ChromeDriver((ChromeOptions) caps);70 driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);71 break;72 case "edge":73 WebDriverManager.edgedriver().setup();74 driver = new EdgeDriver((EdgeOptions) caps);75 break;76 case "firefox":77 WebDriverManager.firefoxdriver().setup();78 driver = new FirefoxDriver((FirefoxOptions) caps);79 break;80 default:81 throw new IllegalArgumentException("Provided browser '" + browser + "' is not supported.");82 }83 return driver;84 }85 public static WebDriver buildRemote(MutableCapabilities caps) throws MalformedURLException {86 return new RemoteWebDriver(new URL(WebConfiguration.getRemoteURL()), caps);87 }88 public static void DestroyDriver() {89 driver.quit();90 }91}...

Full Screen

Full Screen

Source:RemoteDriver.java Github

copy

Full Screen

1package driverFactory;2import io.github.bonigarcia.wdm.config.DriverManagerType;3import org.openqa.selenium.MutableCapabilities;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeOptions;6import org.openqa.selenium.edge.EdgeOptions;7import org.openqa.selenium.firefox.FirefoxOptions;8import org.openqa.selenium.ie.InternetExplorerOptions;9import org.openqa.selenium.opera.OperaOptions;10import org.openqa.selenium.remote.RemoteWebDriver;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:DriverManagerFw.java Github

copy

Full Screen

1package com.fundatec.automacao.GroceryCrud;2import io.github.bonigarcia.wdm.WebDriverManager;3import org.openqa.selenium.MutableCapabilities;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.ie.InternetExplorerDriver;9import org.openqa.selenium.remote.BrowserType;10import org.openqa.selenium.remote.CapabilityType;11public class DriverManagerFw {12 private static WebDriver driver;13 private static WebDriver getManager (DriverTypeFw type){14 switch (type) {15 case CHROME:16 WebDriverManager.chromedriver().setup();17 ChromeOptions option = new ChromeOptions();18 option.addArguments("--start-maximized");19 driver = new ChromeDriver(option);20 break;21 case FIREFOX:22 WebDriverManager.firefoxdriver().setup();23 driver = new FirefoxDriver();24 break;25 case IE:26 WebDriverManager.iedriver().setup();27 MutableCapabilities caps = new MutableCapabilities();28 caps.setCapability(CapabilityType.BROWSER_NAME, BrowserType.IE);29 caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);30 driver = new InternetExplorerDriver();31 break;32 case CHROME_HEADLESS:33 WebDriverManager.chromedriver().setup();34 ChromeOptions option_headless = new ChromeOptions();35 option_headless.addArguments("--headless");36 option_headless.addArguments("--window-size(1200,600)");37 driver = new ChromeDriver(option_headless);38 break;39 default:40 break;41 }...

Full Screen

Full Screen

Source:DriverManager.java Github

copy

Full Screen

1package formWeb;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6import org.openqa.selenium.firefox.FirefoxDriver;7import org.openqa.selenium.ie.InternetExplorerDriver;8import org.openqa.selenium.remote.BrowserType;9import org.openqa.selenium.remote.CapabilityType;10import io.github.bonigarcia.wdm.WebDriverManager;11public class DriverManager {12 13 private static WebDriver driver;14 15 private static WebDriver getManager(DriverType type) {16 switch(type) {17 case CHROME:18 WebDriverManager.chromedriver().setup();19 ChromeOptions options = new ChromeOptions();20 options.addArguments("--start-maximizad");21 driver =new ChromeDriver(options);22 break;23 24 case HEADLESS:25 WebDriverManager.chromedriver().setup();26 ChromeOptions options_headless = new ChromeOptions();27 options_headless.addArguments("--headless");28 options_headless.addArguments("--window-size(1200,600)");29 driver=new ChromeDriver(options_headless);30 break;31 32 case IE:33 WebDriverManager.chromedriver().setup();34 MutableCapabilities mutableCapabilities = new MutableCapabilities();35 mutableCapabilities.setCapability(CapabilityType.BROWSER_NAME, BrowserType.IE);36 mutableCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);37 driver = new InternetExplorerDriver();38 break;39 40 case FIREFOX:41 WebDriverManager.firefoxdriver().setup();42 driver =new FirefoxDriver();43 break;44 default:45 break;46 }47 48 return driver;...

Full Screen

Full Screen

Source:DriverEnum.java Github

copy

Full Screen

1package com.shail.utility;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.Proxy;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.firefox.FirefoxOptions;9import org.openqa.selenium.remote.DesiredCapabilities;10public enum DriverEnum implements WebDriverInterface {11 CHROME {12 public WebDriver getWebDriver(MutableCapabilities capabilities) {13 ChromeOptions options = (ChromeOptions) capabilities;14 return new ChromeDriver(options);15 }16 @Deprecated17 public DesiredCapabilities getDesiredCapabilities(Proxy proxySettings) {18 ChromeOptions options = new ChromeOptions();19 DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();20 desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);21 return desiredCapabilities;22 }23 public MutableCapabilities getBrowserOptions() {24 ChromeOptions options = new ChromeOptions();25 return options;26 }27 },28 FIREFOX {29 public WebDriver getWebDriver(MutableCapabilities capabilities) {30 FirefoxOptions options = (FirefoxOptions) capabilities;31 return new FirefoxDriver(options);32 }33 @Deprecated34 public DesiredCapabilities getDesiredCapabilities() {35 DesiredCapabilities capabilities = DesiredCapabilities.firefox();36 return capabilities;37 }38 public MutableCapabilities getBrowserOptions() {39 FirefoxOptions options = new FirefoxOptions();40 return options;41 }42 };43}...

Full Screen

Full Screen

MutableCapabilities

Using AI Code Generation

copy

Full Screen

1package com.automation;2import org.openqa.selenium.MutableCapabilities;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6import org.openqa.selenium.firefox.FirefoxDriver;7import org.openqa.selenium.firefox.FirefoxOptions;8import org.openqa.selenium.remote.BrowserType;9import org.openqa.selenium.remote.DesiredCapabilities;10public class BrowserCapabilities {11 public static void main(String[] args) {12 DesiredCapabilities capabilities = new DesiredCapabilities();13 capabilities.setCapability("browserName", BrowserType.CHROME);14 capabilities.setCapability("browserVersion", "89.0");15 capabilities.setCapability("enableVNC", true);16 capabilities.setCapability("enableVideo", false);17 MutableCapabilities options = new MutableCapabilities();18 options.setCapability("browserName", BrowserType.CHROME);19 options.setCapability("browserVersion", "89.0");20 options.setCapability("enableVNC", true);21 options.setCapability("enableVideo", false);22 ChromeOptions chromeOptions = new ChromeOptions();23 chromeOptions.setCapability("browserName", BrowserType.CHROME);24 chromeOptions.setCapability("browserVersion", "89.0");25 chromeOptions.setCapability("enableVNC", true);26 chromeOptions.setCapability("enableVideo", false);27 FirefoxOptions firefoxOptions = new FirefoxOptions();28 firefoxOptions.setCapability("browserName", BrowserType.FIREFOX);29 firefoxOptions.setCapability("browserVersion", "87.0");30 firefoxOptions.setCapability("enableVNC", true);31 firefoxOptions.setCapability("enableVideo", false);32 WebDriver driver = new ChromeDriver(chromeOptions);33 System.out.println(driver.getTitle());34 driver.quit();35 WebDriver driver1 = new FirefoxDriver(firefoxOptions);36 System.out.println(driver1.getTitle());37 driver1.quit();38 }39}

Full Screen

Full Screen

MutableCapabilities

Using AI Code Generation

copy

Full Screen

1 MutableCapabilities caps = new MutableCapabilities();2 caps.setCapability("browserName", "chrome");3 caps.setCapability("browserVersion", "latest");4 caps.setCapability("platformName", "windows 10");5 caps.setCapability("sauce:options", sauceOptions);6 driver.quit();

Full Screen

Full Screen

MutableCapabilities

Using AI Code Generation

copy

Full Screen

1MutableCapabilities capabilities = new MutableCapabilities();2capabilities.setCapability("browserName", "chrome");3capabilities.setCapability("browserVersion", "89.0");4capabilities.setCapability("sauce:options", sauceOptions);5DesiredCapabilities capabilities = new DesiredCapabilities();6capabilities.setCapability("browserName", "chrome");7capabilities.setCapability("browserVersion", "89.0");8capabilities.setCapability("sauce:options", sauceOptions);9Capabilities capabilities = new Capabilities() {10 public Map<String, ?> asMap() {11 Map<String, Object> capabilities = new HashMap<>();12 capabilities.put("browserName", "chrome");13 capabilities.put("browserVersion", "89.0");14 capabilities.put("sauce:options", sauceOptions);15 return capabilities;16 }17};18MutableCapabilities capabilities = new MutableCapabilities();19capabilities.setCapability("browserName", "chrome");20capabilities.setCapability("browserVersion", "89.0");21capabilities.setCapability("sauce:options", sauceOptions);22DesiredCapabilities capabilities = new DesiredCapabilities();23capabilities.setCapability("browserName", "chrome");24capabilities.setCapability("browserVersion", "89.0");25capabilities.setCapability("sauce:options", sauceOptions);26Capabilities capabilities = new Capabilities() {27 public Map<String, ?> asMap() {28 Map<String, Object> capabilities = new HashMap<>();29 capabilities.put("browserName", "chrome");30 capabilities.put("browserVersion", "89.0");31 capabilities.put("sauce:options", sauceOptions);32 return capabilities;33 }34};35MutableCapabilities capabilities = new MutableCapabilities();36capabilities.setCapability("browserName", "chrome");37capabilities.setCapability("browserVersion", "89.0");38capabilities.setCapability("sauce:options", sauceOptions);39DesiredCapabilities capabilities = new DesiredCapabilities();40capabilities.setCapability("browserName", "chrome");41capabilities.setCapability("browserVersion", "89.0");42capabilities.setCapability("sauce:options", sauceOptions

Full Screen

Full Screen

MutableCapabilities

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.MutableCapabilities;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5import org.openqa.selenium.remote.RemoteWebDriver;6public class Selenium4ChromeOptions {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Pranav\\Desktop\\chromedriver.exe");9 MutableCapabilities options = new ChromeOptions();10 options.setCapability("browserName", "chrome");11 options.setCapability("platformName", "windows");12 options.setCapability("version", "latest");13 options.setCapability("enableVNC", true);14 WebDriver driver = new RemoteWebDriver(options);15 System.out.println(driver.getTitle());16 driver.quit();17 }18}19package com.selenium4;20import org.openqa.selenium.MutableCapabilities;21import org.openqa.selenium.WebDriver;22import org.openqa.selenium.firefox.FirefoxDriver;23import org.openqa.selenium.firefox.FirefoxOptions;24import org.openqa.selenium.remote.RemoteWebDriver;25public class Selenium4FirefoxOptions {26 public static void main(String[] args) {27 System.setProperty("webdriver.gecko.driver", "C:\\Users\\Pranav\\Desktop\\geckodriver.exe");28 MutableCapabilities options = new FirefoxOptions();29 options.setCapability("browserName", "firefox");30 options.setCapability("platformName", "windows");31 options.setCapability("version", "latest");32 options.setCapability("enableVNC", true);33 WebDriver driver = new RemoteWebDriver(options);34 System.out.println(driver.getTitle());35 driver.quit();36 }37}38package com.selenium4;39import org.openqa.selenium.MutableCapabilities;40import org.openqa.selenium.WebDriver;41import org.openqa.selenium.remote.RemoteWebDriver;42import

Full Screen

Full Screen

MutableCapabilities

Using AI Code Generation

copy

Full Screen

1package com.qa.selenium;2import org.openqa.selenium.MutableCapabilities;3public class MutableCapabilitiesDemo {4 public static void main(String[] args) {5 MutableCapabilities mutableCapabilities = new MutableCapabilities();6 mutableCapabilities.setCapability("key1", "value1");7 mutableCapabilities.setCapability("key2", "value2");8 System.out.println(mutableCapabilities);9 }10}11{key2=value2, key1=value1}12package com.qa.selenium;13import org.openqa.selenium.MutableCapabilities;14public class MutableCapabilitiesDemo {15 public static void main(String[] args) {16 MutableCapabilities mutableCapabilities = new MutableCapabilities();17 mutableCapabilities.setCapability("key1", "value1");18 mutableCapabilities.setCapability("key2", "value2");19 System.out.println(mutableCapabilities.getCapability("key1"));20 }21}22package com.qa.selenium;23import org.openqa.selenium.MutableCapabilities;24public class MutableCapabilitiesDemo {25 public static void main(String[] args) {26 MutableCapabilities mutableCapabilities = new MutableCapabilities();27 mutableCapabilities.setCapability("key1", "value1");28 mutableCapabilities.setCapability("key2", "value2");29 System.out.println(mutableCapabilities);30 }31}32{

Full Screen

Full Screen
copy
1<dependency>2 <groupId>org.slf4j</groupId>3 <artifactId>slf4j-api</artifactId>4 <version>${slf4j.version}</version>5</dependency>6<dependency>7 <groupId>org.slf4j</groupId>8 <artifactId>slf4j-simple</artifactId>9 <version>${slf4j.version}</version>10</dependency>11
Full Screen
copy
1 <dependency>2 <groupId>org.slf4j</groupId>3 <artifactId>slf4j-api</artifactId>4 <version>1.7.5</version>5 </dependency>6 <dependency>7 <groupId>org.slf4j</groupId>8 <artifactId>slf4j-log4j12</artifactId>9 <version>1.7.5</version>10 </dependency>11
Full Screen
copy
1<dependency>2 <groupId>org.slf4j</groupId>3 <artifactId>slf4j-simple</artifactId>4 <version>1.7.21</version>5</dependency>6
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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful