Skip to content

Commit ce2e986

Browse files
author
JHuxtable
committed
Added the ability to use a file as a Firefox Profile, along with a profile name
1 parent 3dea6ae commit ce2e986

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/com/frameworkium/config/drivers/FirefoxImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import com.frameworkium.config.DriverType;
44
import org.openqa.selenium.WebDriver;
55
import org.openqa.selenium.firefox.FirefoxDriver;
6+
import org.openqa.selenium.firefox.FirefoxProfile;
67
import org.openqa.selenium.firefox.internal.ProfilesIni;
78
import org.openqa.selenium.remote.DesiredCapabilities;
89

10+
import java.io.File;
11+
912
import static com.frameworkium.config.SystemProperty.FIREFOX_PROFILE;
1013

1114
public class FirefoxImpl extends DriverType {
@@ -18,7 +21,15 @@ public DesiredCapabilities getDesiredCapabilities() {
1821
@Override
1922
public WebDriver getWebDriverObject(DesiredCapabilities capabilities) {
2023
if (FIREFOX_PROFILE.isSpecified()) {
21-
return new FirefoxDriver(new ProfilesIni().getProfile(FIREFOX_PROFILE.getValue()));
24+
File profileFile = new File(FIREFOX_PROFILE.getValue());
25+
FirefoxProfile firefoxProfile;
26+
if (profileFile.isFile() && !profileFile.isDirectory()) {
27+
firefoxProfile = new FirefoxProfile(profileFile);
28+
}
29+
else {
30+
firefoxProfile = new ProfilesIni().getProfile(FIREFOX_PROFILE.getValue());
31+
}
32+
return new FirefoxDriver(firefoxProfile);
2233
}
2334
else {
2435
return new FirefoxDriver(capabilities);

0 commit comments

Comments
 (0)