There are many advantages by using FirefoxProfile preferences in selenium. You have to update the preferences within Firefox. We can do this by instantiating a Firefox Profile object and then update the settings.We will then need to pass this object into FirefoxDriver which will load the profile with your defined settings.
1. How to setup the startup page in Firefox browser
FirefoxProfile profile= new FirefoxProfile();
profile.setPreference(“browser.startup.homepage”,”https://seleniumbycharan.wordpress.com”);
WebDriver driver = new FirefoxDriver(profile);
2. How to set language in profile ?
FirefoxProfile profile= new FirefoxProfile();
profile.setPreference( “intl.accept_languages”, “no,en-us,en” );
WebDriver driver = new FirefoxDriver(profile);
3. How to Change the user agent ?
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(“general.useragent.override”, “Any UserAgent String”);
WebDriver driver = new FirefoxDriver(profile);
4. How to Download the files using firefox profile ?
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(“browser.download.folderList”,2); profile.setPreference(“browser.download.manager.showWhenStarting”, false); profile.setPreference(“browser.download.dir”, downloadPath); profile.setPreference(“browser.helperApps.neverAsk.openFile”,”application/excel”);
profile.setPreference(“browser.helperApps.neverAsk.saveToDisk”,”application/excel”);
profile.setPreference(“browser.helperApps.alwaysAsk.force”, false);
profile.setPreference(“browser.download.manager.showAlertOnComplete”, false); profile.setPreference(“browser.download.manager.closeWhenDone”, false);
5. How to handle SSL certificate error (Firefox browser) ?
FirefoxProfile profile = allProfiles.getProfile("CertificateIssue");
profile.setAcceptUntrustedCertificates(
true
);
profile.setAssumeUntrustedCertificateIssuer(
false
);
WebDriver driver =
new
FirefoxDriver(profile);
driver.get("https://seleniumbycharan.wordpress.com"
);
I hope this helps you a lot…!
I want to change firefox version
LikeLike
What library do I need to import to enable these commands? (Using robot framework).
LikeLike
Sorry! I am familiar with Robot Framework
LikeLike