In Selenium Grid, “DesiredCapabilities dc = DesiredCapabilities.firefox();” line of code is used to set firefox profile — Why ‘new’ keyword is not been used here?

sangameswari Default Asked on August 22, 2016 in Selenium WebDriver.
Add Comment
1 Answer(s)


If you will check the code in DesiredCapabilities class
to initiliaze the class with new keyword
You have to pass 3 argumets.

public DesiredCapabilities(String browser, String version, Platform platform) {
setCapability(BROWSER_NAME, browser);
setCapability(VERSION, version);
setCapability(PLATFORM, platform);

But when you initiliaze it with DesiredCapabilities.firefox(); // which is a static method of class

it initiliaze the object with new keyword insie static method

public static DesiredCapabilities firefox() {
return new DesiredCapabilities(BrowserType.FIREFOX, “”, Platform.ANY);

ankit ramola Vice Professor Answered on August 24, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.