Best Selenium code snippet using org.openqa.selenium.firefox.FirefoxProfile.getStringPreference
Source:TestMarionetteCapabilitiesFactory.java
...181 182 // check profile183 Assert.assertTrue(profile.getBooleanPreference("webdriver_accept_untrusted_certs", false));184 Assert.assertTrue(profile.getBooleanPreference("webdriver_assume_untrusted_issuer", false));185 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.QueryInterface", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);186 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.frameElement.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);187 Assert.assertEquals(profile.getStringPreference("capability.policy.default.HTMLDocument.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);188 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Document.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);189 Assert.assertEquals(profile.getIntegerPreference("dom.max_chrome_script_run_time", 100), 0);190 Assert.assertEquals(profile.getIntegerPreference("dom.max_script_run_time", 100), 0);191 }192 193 @Test(groups={"ut"})194 public void testCreateMarionetteCapabilitiesOverrideUserAgent() {195 196 Mockito.when(config.getUserAgentOverride()).thenReturn("FIREFOX 55");197 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);198 199 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();200 201 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);202 203 // check profile204 Assert.assertEquals(profile.getStringPreference("general.useragent.override", ""), "FIREFOX 55");205 }206 207 @Test(groups={"ut"})208 public void testCreateMarionetteCapabilitiesOverrideBinPath() {209 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);210 Mockito.when(config.getFirefoxBinPath()).thenReturn("/opt/firefox/bin/firefox");211 212 // SeleniumTestsContext class adds a browserInfo when binary path is set213 Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();214 updatedBrowserInfos.put(BrowserType.FIREFOX, Arrays.asList(new BrowserInfo(BrowserType.FIREFOX, "57.0", "", false), 215 new BrowserInfo(BrowserType.FIREFOX, "58.0", "/opt/firefox/bin/firefox", false)));216217 PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);218 219 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();220 221 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/opt/firefox/bin/firefox");222 }223 224 @Test(groups={"ut"})225 public void testCreateMarionetteCapabilitiesStandardBinPath() {226 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);227 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();228229 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/usr/bin/firefox");230 }231 232 @Test(groups={"ut"})233 public void testCreateMarionetteCapabilitiesOverrideNtlmAuth() {234 235 Mockito.when(config.getNtlmAuthTrustedUris()).thenReturn("uri://uri.ntlm");236 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);237 238 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();239 240 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);241 242 // check profile243 Assert.assertEquals(profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris", ""), "uri://uri.ntlm");244 }245 246 @Test(groups={"ut"})247 public void testCreateMarionetteCapabilitiesOverrideDownloadDir() {248 249 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");250 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);251 252 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();253 254 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);255 256 // check profile257 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "/home/download");258 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 2);259 Assert.assertEquals(profile.getBooleanPreference("browser.download.manager.showWhenStarting", true), false);260 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");261 }262 263 /**264 * issue #365: Check DownloadDir is not set in remote265 */266 @Test(groups={"ut"})267 public void testCreateMarionetteCapabilitiesNoOverrideDownloadDirRemote() {268 269 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");270 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);271 272 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();273 274 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);275 276 // check profile277 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "");278 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 0);279 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "");280 }281 282 @Test(groups={"ut"})283 public void testCreateMarionetteCapabilitiesStandardDriverPathLocal() {284 System.clearProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY);285 try {286 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);287 288 new FirefoxCapabilitiesFactory(config).createCapabilities();289 290 Assert.assertTrue(System.getProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY).replace(File.separator, "/").contains("/drivers/geckodriver"));291 } finally {292 System.clearProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY);293 }
...
Source:TestFirefoxCapabilitiesFactory.java
...197 198 // check profile199 Assert.assertTrue(profile.getBooleanPreference("webdriver_accept_untrusted_certs", false));200 Assert.assertTrue(profile.getBooleanPreference("webdriver_assume_untrusted_issuer", false));201 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.QueryInterface", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);202 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.frameElement.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);203 Assert.assertEquals(profile.getStringPreference("capability.policy.default.HTMLDocument.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);204 Assert.assertEquals(profile.getStringPreference("capability.policy.default.Document.compatMode.get", ""), FirefoxCapabilitiesFactory.ALL_ACCESS);205 Assert.assertEquals(profile.getIntegerPreference("dom.max_chrome_script_run_time", 100), 0);206 Assert.assertEquals(profile.getIntegerPreference("dom.max_script_run_time", 100), 0);207 }208 209 @Test(groups={"ut"})210 public void testCreateFirefoxCapabilitiesOverrideUserAgent() {211 212 Mockito.when(config.getUserAgentOverride()).thenReturn("FIREFOX 55");213 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);214 215 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();216 217 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);218 219 // check profile220 Assert.assertEquals(profile.getStringPreference("general.useragent.override", ""), "FIREFOX 55");221 }222 223 @Test(groups={"ut"})224 public void testCreateFirefoxCapabilitiesOverrideBinPath() {225 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);226 Mockito.when(config.getFirefoxBinPath()).thenReturn("/opt/firefox/bin/firefox");227 228 // SeleniumTestsContext class adds a browserInfo when binary path is set229 Map<BrowserType, List<BrowserInfo>> updatedBrowserInfos = new HashMap<>();230 updatedBrowserInfos.put(BrowserType.FIREFOX, Arrays.asList(new BrowserInfo(BrowserType.FIREFOX, "47.0", "", false), 231 new BrowserInfo(BrowserType.FIREFOX, "44.0", "/opt/firefox/bin/firefox", false)));232233 PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion(false)).thenReturn(updatedBrowserInfos);234 235 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();236 237 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/opt/firefox/bin/firefox");238 }239 240 @Test(groups={"ut"})241 public void testCreateFirefoxCapabilitiesStandardBinPath() {242 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);243 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();244245 Assert.assertEquals(capa.getCapability(FirefoxDriver.BINARY), "/usr/bin/firefox");246 }247 248 @Test(groups={"ut"})249 public void testCreateFirefoxCapabilitiesOverrideNtlmAuth() {250 251 Mockito.when(config.getNtlmAuthTrustedUris()).thenReturn("uri://uri.ntlm");252 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);253 254 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();255 256 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);257 258 // check profile259 Assert.assertEquals(profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris", ""), "uri://uri.ntlm");260 }261 262 @Test(groups={"ut"})263 public void testCreateFirefoxCapabilitiesOverrideDownloadDir() {264 265 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");266 Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);267 268 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();269 270 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);271 272 // check profile273 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "/home/download");274 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 2);275 Assert.assertEquals(profile.getBooleanPreference("browser.download.manager.showWhenStarting", true), false);276 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");277 }278 279 /**280 * issue #365: Check DownloadDir is not set in remote281 */282 @Test(groups={"ut"})283 public void testCreateFirefoxCapabilitiesNoOverrideDownloadDirRemote() {284 285 Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");286 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);287 288 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();289 290 FirefoxProfile profile = (FirefoxProfile)capa.getCapability(FirefoxDriver.PROFILE);291 292 // check profile293 Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "");294 Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 0);295 Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""), "");296 }297 298 @Test(groups={"ut"})299 public void testCreateFirefoxCapabilitiesWithDefaultProfile() {300 301 Mockito.when(config.getMode()).thenReturn(DriverMode.GRID);302 Mockito.when(config.getFirefoxProfilePath()).thenReturn(BrowserInfo.DEFAULT_BROWSER_PRODFILE);303 304 MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();305 306 // check 'firefoxProfile' is set to 'default'307 Assert.assertEquals(capa.getCapability("firefoxProfile"), BrowserInfo.DEFAULT_BROWSER_PRODFILE);308 }309
...
Source:FirefoxProfile.java
...97 98 throw new WebDriverException("Expected boolean value is not a boolean. It is: " + value);99 }100 101 public String getStringPreference(String key, String defaultValue) {102 Object preference = additionalPrefs.getPreference(key);103 if ((preference != null) && ((preference instanceof String))) {104 return (String)preference;105 }106 return defaultValue;107 }108 109 public int getIntegerPreference(String key, int defaultValue) {110 Object preference = additionalPrefs.getPreference(key);111 if ((preference != null) && ((preference instanceof Integer))) {112 return ((Integer)preference).intValue();113 }114 return defaultValue;115 }...
Source:FirefoxProfileTest.java
...50 profile.setPreference("cheese", "brie");51 assertPreferenceValueEquals("cheese", "\"brie\"");52 }53 @Test54 public void getStringPreferenceShouldReturnUserSuppliedValueWhenSet() {55 String key = "cheese";56 String value = "brie";57 profile.setPreference(key, value);58 String defaultValue = "edam";59 assertThat(profile.getStringPreference(key, defaultValue)).isEqualTo(value);60 }61 @Test62 public void getStringPreferenceShouldReturnDefaultValueWhenSet() {63 String key = "cheese";64 String defaultValue = "brie";65 assertThat(profile.getStringPreference(key, defaultValue)).isEqualTo(defaultValue);66 }67 @Test68 public void shouldSetIntegerPreferences() throws Exception {69 profile.setPreference("cheese", 1234);70 assertPreferenceValueEquals("cheese", 1234);71 }72 @Test73 public void getIntegerPreferenceShouldReturnUserSuppliedValueWhenSet() {74 String key = "cheese";75 int value = 1234;76 profile.setPreference(key, value);77 int defaultValue = -42;78 assertThat(profile.getIntegerPreference(key, defaultValue)).isEqualTo(1234);79 }...
Source:CapabilitiesTests.java
...55 .PROFILE);56 Assert.assertTrue(capabilities.getBrowserName().equals("firefox"),57 "The browser name expected was " + capabilities.getBrowserName()58 + " but was expected to be: firefox");59 Assert.assertTrue(profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris",60 "http://, https//").equals("http://, https//"),61 "The capability for network automatic-ntln-auth trusted uris was "62 + profile.getStringPreference("network.automatic-ntlm-auth.trusted-uris",63 "http://, https//") + " and was expected to be: http://, https//");64 Assert.assertFalse(profile.getBooleanPreference("browser.helperApps.alwaysAsk.force",65 false),66 "The capability for browser helperApps alwaysAsk force was "67 + profile.getBooleanPreference("browser.helperApps.alwaysAsk.force",68 false)69 + " and was expected to be: false");70 }71 @Test72 public void testIECapabilities() {73 capabilities = Capabilities.getBrowserCapabilities(BrowserType.IE);74 Assert.assertTrue(capabilities.getBrowserName().equals("internet explorer"),75 "The browser name expected was " + capabilities.getBrowserName()76 + " but was expected to be: internet explorer");...
Source:FirefoxDriverFactoryTest.java
...63 @Test64 void transferStringFirefoxProfilePreferencesFromSystemPropsToDriver() {65 System.setProperty("firefoxprofile.some.cap", "abdd");66 FirefoxProfile profile = driverFactory.createFirefoxOptions(config, proxy).getProfile();67 assertThat(profile.getStringPreference("some.cap", "sjlj")).isEqualTo("abdd");68 }69 @Test70 void browserBinaryCanBeSet() {71 config.browserBinary("c:/browser.exe");72 Capabilities caps = driverFactory.createFirefoxOptions(config, proxy);73 Map options = (Map) caps.asMap().get(FirefoxOptions.FIREFOX_OPTIONS);74 assertThat(options.get("binary")).isEqualTo("c:/browser.exe");75 }76 @Test77 void headlessCanBeSet() {78 config.headless(true);79 FirefoxOptions options = driverFactory.createFirefoxOptions(config, proxy);80 List<String> optionArguments = getBrowserLaunchArgs(FirefoxOptions.FIREFOX_OPTIONS, options);81 assertThat(optionArguments).contains("-headless");82 }83 @Test84 void enablesProxyForLocalAddresses() {85 FirefoxOptions options = driverFactory.createFirefoxOptions(config, proxy);86 FirefoxProfile firefoxProfile = (FirefoxProfile) options.asMap().get("firefox_profile");87 assertThat(firefoxProfile.getStringPreference("network.proxy.no_proxies_on", "localhost")).isEqualTo("");88 }89}...
Source:BrowserManagementTest.java
...37 String browserOptions = "{\"preferences\": {\"network.proxy.type\": 1, \"network.proxy.http\": \"localhost\", \"network.proxy.http_port\": 73571}}";38 Capabilities dc = bm.createCapabilities("firefox", desired, browserOptions);39 FirefoxProfile profile = (FirefoxProfile) dc.getCapability("firefox_profile");40 assertTrue(dc.getCapability("platform").toString().equals("WINDOWS"));41 assertTrue(profile.getStringPreference("network.proxy.http", "wrong") != "wrong");42 }43 44 @Test45 public void testCreateDesiredCapabilitiesWithoutBrowserOptions() {46 String desired = "{\"platform\":\"WINDOWS\",\"browserName\":\"firefox\",\"version\":\"\"}";47 Capabilities dc = bm.createCapabilities("firefox", desired, null);48 FirefoxProfile profile = (FirefoxProfile) dc.getCapability("firefox_profile");49 assertTrue(dc.getCapability("platform").toString().equals("WINDOWS"));50 }51 52 @Test53 public void testCreateDesiredCapabilitiesWithOnlyBrowserOptions() {54 String browserOptions = "{\"preferences\": {\"network.proxy.type\": 1, \"network.proxy.http\": \"localhost\", \"network.proxy.http_port\": 73571}}";55 Capabilities dc = bm.createCapabilities("firefox", null, browserOptions);56 FirefoxProfile profile = (FirefoxProfile) dc.getCapability("firefox_profile");57 assertTrue(profile.getStringPreference("network.proxy.http", "wrong") != "wrong");58 }59 60 @Test61 public void testCreateDesiredCapabilitiesForHtmlUnit() {62 Capabilities dc = bm.createCapabilities("htmlunitwithjs", null, "");63 assertTrue(dc.getBrowserName().equals("htmlunit"));64 }65 66 @Test67 public void parseChromeBrowserOptions() {68 ChromeOptions chromeOptions = new ChromeOptions();69 String browserOptions = "{\"args\":[\"start-maximized\"],\"extensions\":[],\"prefs\":{\"intl.accept_languages\":\"de-AT\", \"intl.charset_default\":\"UTF-8\"}}";70 bm.parseBrowserOptionsChrome(browserOptions, chromeOptions);71 assertTrue(chromeOptions.asMap().toString().contains("--start-maximized"));...
Source:FirefoxSettings.java
...36 getDesiredCapabilities().setCapability("binary", "src/test/resources/drivers/firefox-sdk/bin/firefox.exe");37 initializeFirefoxOptions(getDesiredCapabilities());38 Map<String, Object> props = new HashMap<String, Object>();39 props.put("browser.download.dir", Utils.PATH_TO_DOWNLOAD);40 if (!getFirefoxProfile().getStringPreference("browser.download.dir", "browser.download.dir")41 .equals(new DirectoryUtil("temp").produceDirAndPath())) {42 getFirefoxProfile().setPreference("browser.download.dir", Utils.PATH_TO_DOWNLOAD);43 }44 getFirefoxOptions().setProfile(getFirefoxProfile());45 return getFirefoxOptions();46 }47 @Override48 public WebDriver getDriver() {49 WebDriverManager.firefoxdriver().setup();50 System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");51 return new FirefoxDriver(addAll());52 }53}...
getStringPreference
Using AI Code Generation
1FirefoxProfile profile = new FirefoxProfile();2profile.setPreference("browser.startup.homepage_override.mstone","ignore");3profile.setPreference("startup.homepage_welcome_url.additional","about:blank");4profile.setPreference("startup.homepage_welcome_url","about:blank");5profile.setPreference("startup.homepage_welcome_url.additional","about:blank");6profile.setPreference("startup.homepage_welcome_url","about:blank");7profile.setPreference("startup.homepage_welcome_url.additional","about:blank");8System.out.println(profile.getStringPreference("browser.startup.homepage"));9System.out.println(profile.getStringPreference("browser.startup.homepage"));10profile.setPreference("browser.startup.homepage",null);11System.out.println(profile.getStringPreference("browser.startup.homepage"));12System.out.println(profile.hasPreference("browser.startup.homepage"));13System.out.println(profile.getStringPreference("browser.startup.homepage"));14System.out.println(profile.getStringPreference("browser.startup.homepage"));15System.out.println(profile.getStringPreference("browser.startup.homepage"));16System.out.println(profile.getStringPreference("browser.startup.homepage"));17System.out.println(profile.getStringPreference("browser.startup.homepage"));18System.out.println(profile.getStringPreference("browser.startup.homepage"));
getStringPreference
Using AI Code Generation
1FirefoxProfile profile = new FirefoxProfile();2profile.setPreference("intl.accept_languages", "fr");3driver = new FirefoxDriver(profile);4FirefoxProfile profile = new FirefoxProfile();5profile.setPreference("intl.accept_languages", "fr");6driver = new FirefoxDriver(profile);7FirefoxProfile profile = new FirefoxProfile();8profile.addExtension(new File("path/to/extension.xpi"));9driver = new FirefoxDriver(profile);10FirefoxProfile profile = new FirefoxProfile();11profile.setProxyPreferences(new Proxy());12driver = new FirefoxDriver(profile);13FirefoxProfile profile = new FirefoxProfile();14profile.setEnableNativeEvents(false);15driver = new FirefoxDriver(profile);16FirefoxProfile profile = new FirefoxProfile();17profile.setAlwaysLoadNoFocusLib(true);18driver = new FirefoxDriver(profile);19FirefoxProfile profile = new FirefoxProfile();20profile.setEnableNativeEvents(false);21driver = new FirefoxDriver(profile);22FirefoxProfile profile = new FirefoxProfile();23profile.setAlwaysLoadNoFocusLib(true);24driver = new FirefoxDriver(profile);25FirefoxProfile profile = new FirefoxProfile();26profile.setEnableNativeEvents(false);27driver = new FirefoxDriver(profile);28FirefoxProfile profile = new FirefoxProfile();29profile.setAlwaysLoadNoFocusLib(true);30driver = new FirefoxDriver(profile);31FirefoxProfile profile = new FirefoxProfile();32profile.setEnableNativeEvents(false);33driver = new FirefoxDriver(profile);
getStringPreference
Using AI Code Generation
1FirefoxProfile profile = new FirefoxProfile();2String prefValue = profile.getStringPreference("browser.startup.homepage");3System.out.println("Value of the preference is: " + prefValue);4profile.cleanTemporaryModel();5package org.openqa.selenium.firefox;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.firefox.FirefoxProfile;9public class FirefoxProfileExample {10 public static void main(String[] args) {11 WebDriver driver = new FirefoxDriver();12 FirefoxProfile profile = new FirefoxProfile();13 profile.setPreference("browser.download.dir", "D:\\Download");14 profile.setPreference("browser.download.folderList", 2);15 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 16 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 17 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 18 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 19 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 20 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 21 profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
getStringPreference
Using AI Code Generation
1public FirefoxProfile setDownloadDirectory() {2 FirefoxProfile profile = new FirefoxProfile();3 profile.setPreference("browser.download.dir", "C:\\Users\\Public\\Downloads");4 profile.setPreference("browser.download.folderList", 2);5 profile.setPreference("browser.download.manager.showWhenStarting", false);6 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream");7 return profile;8}9FirefoxDriver driver = new FirefoxDriver(setDownloadDirectory());10driver.findElement(By.linkText("32 bit Windows IE")).click();11Thread.sleep(5000);12driver.close();13driver.quit();14File[] files = new File("C:\\Users\\Public\\Downloads").listFiles();15for (File file : files) {16 if (file.isFile()) {17 System.out.println(file.getName());18 }19}20files[0].delete();21files[0].getParentFile().delete();22files[0].getParentFile().getParentFile().delete();23files[0].getParentFile().getParentFile().getParentFile().delete();24files[0].getParentFile().getParentFile().getParentFile().getParentFile().delete();
getStringPreference
Using AI Code Generation
1profile.setPreference("browser.download.manager.showWhenStarting", "true");2profile.setPreference("browser.download.manager.showWhenStarting", "false");3profile.setPreference("browser.download.manager.showWhenStarting", true);4profile.setPreference("browser.download.manager.showWhenStarting", false);5profile.setPreference("browser.download.manager.showWhenStarting", Boolean.TRUE);6profile.setPreference("browser.download.manager.showWhenStarting", Boolean.FALSE);7profile.setPreference("browser.download.manager.showWhenStarting", new Boolean("true"));8profile.setPreference("browser.download.manager.showWhenStarting", new Boolean("false"));
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.
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.
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.
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.
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.
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.
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.
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.
LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.
Get 100 minutes of automation test minutes FREE!!