How to use addFirefoxOptions method of com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities.addFirefoxOptions

Source:AbstractCapabilities.java Github

copy

Full Screen

...94 } else {95 browser = Configuration.getBrowser();96 }97 if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) {98 capabilities = addFirefoxOptions(capabilities);99 } else if (BrowserType.CHROME.equalsIgnoreCase(browser)) {100 capabilities = addChromeOptions(capabilities);101 }102 if (Configuration.getBoolean(Parameter.HEADLESS)) {103 if (BrowserType.FIREFOX.equalsIgnoreCase(browser)104 || BrowserType.CHROME.equalsIgnoreCase(browser)105 && Configuration.getDriverType().equalsIgnoreCase(SpecialKeywords.DESKTOP)) {106 LOGGER.info("Browser will be started in headless mode. VNC and Video will be disabled.");107 capabilities.setCapability("enableVNC", false);108 capabilities.setCapability("enableVideo", false);109 } else {110 LOGGER.error(String.format("Headless mode isn't supported by %s browser / platform.", browser));111 }112 }113 return capabilities;114 }115 protected Proxy setupProxy() {116 ProxyPool.setupBrowserMobProxy();117 SystemProxy.setupProxy();118 String proxyHost = Configuration.get(Parameter.PROXY_HOST);119 String proxyPort = Configuration.get(Parameter.PROXY_PORT);120 String noProxy = Configuration.get(Parameter.NO_PROXY);121 122 if (Configuration.get(Parameter.BROWSERMOB_PROXY).equals("true")) {123 proxyPort = Integer.toString(ProxyPool.getProxyPortFromThread());124 }125 List<String> protocols = Arrays.asList(Configuration.get(Parameter.PROXY_PROTOCOLS).split("[\\s,]+"));126 //TODO: test removal comparing with null127 if (proxyHost != null && !proxyHost.isEmpty() && proxyPort != null && !proxyPort.isEmpty()) {128 org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();129 String proxyAddress = String.format("%s:%s", proxyHost, proxyPort);130 if (protocols.contains("http")) {131 LOGGER.info(String.format("Http proxy will be set: %s:%s", proxyHost, proxyPort));132 proxy.setHttpProxy(proxyAddress);133 }134 if (protocols.contains("https")) {135 LOGGER.info(String.format("Https proxy will be set: %s:%s", proxyHost, proxyPort));136 proxy.setSslProxy(proxyAddress);137 }138 if (protocols.contains("ftp")) {139 LOGGER.info(String.format("FTP proxy will be set: %s:%s", proxyHost, proxyPort));140 proxy.setFtpProxy(proxyAddress);141 }142 if (protocols.contains("socks")) {143 LOGGER.info(String.format("Socks proxy will be set: %s:%s", proxyHost, proxyPort));144 proxy.setSocksProxy(proxyAddress);145 }146 147 if (!noProxy.isEmpty()) {148 proxy.setNoProxy(noProxy);149 }150 return proxy;151 }152 return null;153 }154 155 private DesiredCapabilities addChromeOptions(DesiredCapabilities caps) {156 // add default carina options and arguments157 ChromeOptions options = new ChromeOptions();158 options.addArguments("test-type");159 160 //prefs 161 HashMap<String, Object> chromePrefs = new HashMap<String, Object>();162 boolean needsPrefs = false;163 164 //update browser language165 String browserLang = Configuration.get(Parameter.BROWSER_LANGUAGE); 166 if (!browserLang.isEmpty()) {167 LOGGER.info("Set Chrome language to: " + browserLang);168 options.addArguments("--lang=" + browserLang);169 chromePrefs.put("intl.accept_languages", browserLang);170 needsPrefs = true;171 }172 if (Configuration.getBoolean(Configuration.Parameter.AUTO_DOWNLOAD)) {173 chromePrefs.put("download.prompt_for_download", false);174 if (!"zebrunner".equalsIgnoreCase(R.CONFIG.get("capabilities.provider"))) {175 // don't override auto download dir for Zebrunner Selenium Grid (Selenoid)176 chromePrefs.put("download.default_directory", ReportContext.getArtifactsFolder().getAbsolutePath());177 }178 chromePrefs.put("plugins.always_open_pdf_externally", true);179 needsPrefs = true;180 }181 182 // [VD] no need to set proxy via options anymore!183 // moreover if below code is uncommented then we have double proxy start and mess in host:port values184 185 // setup default mobile chrome args and preferences186 String driverType = Configuration.getDriverType();187 if (SpecialKeywords.MOBILE.equals(driverType)) {188 options.addArguments("--no-first-run");189 options.addArguments("--disable-notifications");190 options.setExperimentalOption("w3c", false);191 }192 193 // add all custom chrome args194 for (String arg: Configuration.get(Parameter.CHROME_ARGS).split(",")) {195 if (arg.isEmpty()) {196 continue;197 }198 options.addArguments(arg.trim());199 }200 201 // add all custom chrome experimental options, w3c=false202 String experimentalOptions = Configuration.get(Parameter.CHROME_EXPERIMENTAL_OPTS);203 if(!experimentalOptions.isEmpty()) {204 needsPrefs = true;205 for (String option: experimentalOptions.split(",")) {206 if (option.isEmpty()) {207 continue;208 }209 //TODO: think about equal sign inside name or value later210 option = option.trim();211 String name = option.split("=")[0].trim();212 String value = option.split("=")[1].trim();213 if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) {214 chromePrefs.put(name, Boolean.valueOf(value));215 } else if (isNumber(value)) {216 chromePrefs.put(name, Long.valueOf(value));217 } else {218 chromePrefs.put(name, value);219 }220 }221 }222 if (needsPrefs) {223 options.setExperimentalOption("prefs", chromePrefs);224 }225 226 // add all custom chrome mobileEmulation options, deviceName=Nexus 5227 Map<String, String> mobileEmulation = new HashMap<>();228 for (String option: Configuration.get(Parameter.CHROME_MOBILE_EMULATION_OPTS).split(",")) {229 if (option.isEmpty()) {230 continue;231 }232 option = option.trim();233 String name = option.split("=")[0].trim();234 String value = option.split("=")[1].trim();235 mobileEmulation.put(name, value);236 }237 238 if (!mobileEmulation.isEmpty()) {239 options.setExperimentalOption("mobileEmulation", mobileEmulation);240 }241 if (Configuration.getBoolean(Parameter.HEADLESS)242 && driverType.equals(SpecialKeywords.DESKTOP)) {243 options.setHeadless(Configuration.getBoolean(Parameter.HEADLESS));244 }245 caps.setCapability(ChromeOptions.CAPABILITY, options);246 return caps;247 }248 private DesiredCapabilities addFirefoxOptions(DesiredCapabilities caps) {249 FirefoxProfile profile = getDefaultFirefoxProfile();250 FirefoxOptions options = new FirefoxOptions().setProfile(profile);251 caps.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);252 // add all custom firefox args253 for (String arg : Configuration.get(Parameter.FIREFOX_ARGS).split(",")) {254 if (arg.isEmpty()) {255 continue;256 }257 options.addArguments(arg.trim());258 }259 // add all custom firefox preferences260 for (String preference : Configuration.get(Parameter.FIREFOX_PREFERENCES).split(",")) {261 if (preference.isEmpty()) {262 continue;...

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities;2import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.desktop.DesktopCapabilities;3import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.MobileCapabilities;4import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.MobileEmulatorCapabilities;5import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.MobileRealDeviceCapabilities;6import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.android.AndroidCapabilities;7import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.android.AndroidEmulatorCapabilities;8import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.android.AndroidRealDeviceCapabilities;9import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSCapabilities;10import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSEmulatorCapabilities;11import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSRealDeviceCapabilities;12import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebCapabilities;13import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebEmulatorCapabilities;14import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebRealDeviceCapabilities;15import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorCapabilities;16import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorRealDeviceCapabilities;17import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorRealDeviceEmulatorCapabilities;18import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorRealDeviceEmulatorSafariCapabilities;19import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorRealDeviceSafariCapabilities;20import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSimulatorSafariCapabilities;21import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSafariCapabilities;22import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.mobile.ios.IOSWebSim

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo;2import org.openqa.selenium.firefox.FirefoxOptions;3import org.testng.annotations.Test;4import com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities;5import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;6import com.qaprosoft.carina.core.foundation.webdriver.decorator.HtmlElement;7import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageFactory;8import com.qaprosoft.carina.demo.gui.pages.HomePage;9public class FirefoxOptionsTest extends AbstractTest {10public void testAddFirefoxOptions() {11FirefoxOptions options = new FirefoxOptions();12options.addArguments("--lang=en-US");13options.addArguments("--width=800");14options.addArguments("--height=600");15AbstractCapabilities.addFirefoxOptions(options);16HomePage homePage = new HomePage(getDriver());17PageFactory.initElements(getDriver(), homePage);18ExtendedWebElement languageSelector = homePage.getLanguageSelector();19assert languageSelector.isElementPresent();20}21}22package com.qaprosoft.carina.demo;23import org.openqa.selenium.chrome.ChromeOptions;24import org.testng.annotations.Test;25import com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities;26import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;27import com.qaprosoft.carina.core.foundation.webdriver.decorator.HtmlElement;28import com.qaprosoft.carina.core.foundation.webdriver.decorator.PageFactory;29import com.qaprosoft.carina.demo.gui.pages.HomePage;30public class ChromeOptionsTest extends AbstractTest {31public void testAddChromeOptions() {32ChromeOptions options = new ChromeOptions();33options.addArguments("--lang=en-US");34options.addArguments("--window-size=800,600");35AbstractCapabilities.addChromeOptions(options);36HomePage homePage = new HomePage(getDriver());37PageFactory.initElements(getDriver(), homePage);38ExtendedWebElement languageSelector = homePage.getLanguageSelector();

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = new DesiredCapabilities();2capabilities.setCapability("platform", "Windows 10");3capabilities.setCapability("version", "latest");4capabilities.setCapability("browserName", "firefox");5capabilities.setCapability("browserVersion", "latest");6capabilities.setCapability("name", "Test");7capabilities.setCapability("build", "1.0");8capabilities.setCapability("screenResolution", "1280x1024");9capabilities.setCapability("record_video", "true");10capabilities.setCapability("record_network", "true");11capabilities.setCapability("record_snapshot", "true");12capabilities.setCapability("record_logs", "true");13capabilities.setCapability("record_screenshots", "true");14capabilities.setCapability("maxDuration", "3600");15capabilities.setCapability("idleTimeout", "100");16capabilities.setCapability("overwriteExistingSession", "true");17capabilities.setCapability("maxInstances", "1");18capabilities.setCapability("seleniumVersion", "3.141.59");19FirefoxOptions firefoxOptions = new FirefoxOptions();20firefoxOptions.setCapability("browserstack.video", "true");21firefoxOptions.setCapability("browserstack.networkLogs", "true");22firefoxOptions.setCapability("browserstack.networkProfile", "cable");23firefoxOptions.setCapability("browserstack.timezone", "Europe/London");24firefoxOptions.setCapability("browserstack.seleniumLogs", "true");25firefoxOptions.setCapability("browserstack.selenium_version", "3.141.59");26firefoxOptions.setCapability("browserstack.idleTimeout", "100");27firefoxOptions.setCapability("browserstack.maxDuration", "3600");28firefoxOptions.setCapability("browserstack.seleniumLogs", "true");29firefoxOptions.setCapability("browserstack.selenium_version", "3.141.59");30firefoxOptions.setCapability("browserstack.idleTimeout", "100");31firefoxOptions.setCapability("browserstack.maxDuration", "3600");32AbstractCapabilities.addFirefoxOptions(capabilities, firefoxOptions);33driver = new RemoteWebDriver(new URL(URL), capabilities);34DesiredCapabilities capabilities = new DesiredCapabilities();35capabilities.setCapability("platform", "Windows 10");36capabilities.setCapability("version", "latest");37capabilities.setCapability("browserName", "chrome");38capabilities.setCapability("browserVersion", "latest");39capabilities.setCapability("name", "Test");40capabilities.setCapability("build", "1.0");41capabilities.setCapability("screenResolution", "1280x102

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = new DesiredCapabilities();2FirefoxProfile profile = new FirefoxProfile();3profile.setPreference("browser.startup.homepage_override.mstone", "ignore");4profile.setPreference("browser.startup.page", 1);5profile.setPreference("browser.download.folderList", 2);6profile.setPreference("browser.download.dir", "C:\\Users\\user\\Downloads");7profile.setPreference("browser.download.useDownloadDir", true);8profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel");9profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-msexcel");10profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/excel");11profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-excel");12profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-dos_ms_excel");13profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xls");14profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-xls");15profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");16profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xlsx");17profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-xlsx");18profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf");19profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-pdf");20profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/acrobat");21profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "applications/vnd.pdf");22profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/pdf");23profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/x-pdf");24profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "image/png");25profile.setPreference("browser.helperApps.neverAsk.saveToDisk

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.desktop.FirefoxCapabilities;2import com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities;3import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.desktop.FirefoxCapabilities;4import com.qaprosoft.carina.core.foundation.webdriver.core.capability.AbstractCapabilities;5import org.openqa.selenium.remote.DesiredCapabilities;6import org.openqa.selenium.remote.DesiredCapabilities;7import org.openqa.selenium.firefox.FirefoxProfile;8import org.openqa.selenium.firefox.FirefoxProfile;9FirefoxCapabilities firefoxCapabilities = new FirefoxCapabilities();10FirefoxCapabilities firefoxCapabilities = new FirefoxCapabilities();11DesiredCapabilities capabilities = new DesiredCapabilities();12DesiredCapabilities capabilities = new DesiredCapabilities();13FirefoxProfile profile = new FirefoxProfile();14FirefoxProfile profile = new FirefoxProfile();

Full Screen

Full Screen

addFirefoxOptions

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.gui;2import java.lang.invoke.MethodHandles;3import java.util.HashMap;4import java.util.Map;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.firefox.FirefoxOptions;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.slf4j.Logger;9import org.slf4j.LoggerFactory;10import org.testng.Assert;11import org.testng.annotations.Test;12import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;13import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;14import com.qaprosoft.carina.core.foundation.webdriver.core.capability.impl.desktop.DesktopCapabilities;15import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;16import com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener;17import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringWebDriverFactory;18import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringWebDriverFactory.EventFiringWebDriverWrapper;19import com.qaprosoft.carina.core.foundation.webdriver.listener.MobileDriverListener;20import com.qaprosoft.carina.core.foundation.webdriver.listener.RetryAnalyzer;21import com.qaprosoft.carina.core.foundation.webdriver.listener.RetryAnalyzerImpl;22import com.qaprosoft.carina.core.foundation.webdriver.listener.TestPhaseListener;23import com.qaprosoft.carina.core.foundation.webdriver.listener.TestPhaseListenerImpl;24import com.qaprosoft.carina.core.foundation.webdriver.listener.VideoRecorder;25import com.qaprosoft.carina.core.foundation.webdriver.listener.VideoRecorderImpl;26import com.qaprosoft.carina.core.foundation.webdriver.report.DriverPoolInfo;27import com.qaprosoft.carina.core.foundation.webdriver.report.DriverPoolInfo.DriverInfo;28import com.qaprosoft.carina.core.foundation.webdriver.report.DriverPoolInfo.DriverType;29import com.qaprosoft.carina.core.foundation.webdriver.report.DriverPoolInfo.Platform;30import com.qaprosoft.carina.core.foundation.webdriver.report.MobileDriverInfo;31import com.qaprosoft.carina.core.foundation.webdriver.report.MobileDriverInfo.MobileDriverType;32import com.qaprosoft.carina.core.foundation.webdriver.report.MobileDriverInfo.MobilePlatform;33import com.qaprosoft.carina.core.foundation.webdriver.report.MobileDriverInfo.MobileTestPhase;34import com.qaprosoft.carina.core.foundation.webdriver.report.MobileDriverInfo.MobileTestType;35import com.qaprosoft.carina.core.foundation.webdriver.testrail.TestRail

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Carina 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