From selenium 3.0 beta 4, selenium introduced class FirefoxOptions to Manage firefox specific settings in a way gecko driver can understand.
Let’s see how firefox settings we can use in selenium easily
Before to selenium 3.0, used firefox profile as
FirefoxProfile profile= new FirefoxProfile(); profile.setPreference("browser.startup.homepage","http://qavalidation.com"); profile.setAcceptUntrustedCertificates(true); DesiredCapabilities caps=DesiredCapabilities.firefox(); caps.setCapability(FirefoxDriver.PROFILE, profile); FirefoxDriver driver = new FirefoxDriver(caps);
Now we can write without using the FirefoxProfile as
FirefoxOptions options = new FirefoxOptions(); options.addPreference("browser.startup.homepage","https://qavalidation.com"); options.setAcceptInsecureCerts(true); DesiredCapabilities caps=DesiredCapabilities.firefox(); //caps.setCapability([capabilityName], [value]); options.merge(caps); driver = new FirefoxDriver(options);
profile.setPreference
can be written as options.addPreference
if you enter caps. you will get lots of methods for your needs.
FirefoxDriver(Capabilities capabilities)
– Deprecated, Instead you can Use FirefoxDriver(FirefoxOptions)
Reference:
FirefoxOptions