I have a profile folder src/main/resources/firefox/profile/selenium
and an extension folder under src/main/resources/firefox/extensions/
I am using the maven shade plugin to package this as an uber jar so we can run the test suite on our server.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.erac.automation.automationCommon.test.gui.TestGui</Main-Class>
<X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
and how I access the profile and extension folder
try{
firefoxProfileDirectory = getExtension("/firefox/profiles/selenium/", "");
System.out.println("the file for the firefoxProfileDirectory - " + firefoxProfileDirectory.exists());
}catch(Exception e){
}
FirefoxProfile profile = new FirefoxProfile(firefoxProfileDirectory);
try{
profile.addExtension(getExtension("/firefox/extensions/", FIREBUG_XPI));
profile.addExtension(getExtension("/firefox/extensions/", FIREPATH_XPI));
}catch(Exception e){
}
public static File getExtension(String path, String file) throws IOException {
URL url = AutomationProfileFactory.class.getResource(path + file);
File firefoxProfileFolder = new File("");
if(url == null) {
//nothing
}
else{
firefoxProfileFolder = new File(url.getPath());
System.out.println(firefoxProfileFolder.exists());
return firefoxProfileFolder;
}
return new File("");
}
When running the program in MyEclipse the tests run as normal, but after creating the uber jar and running in command line I get this error
Caused by: org.openqa.selenium.firefox.UnableToCreateProfileException: Given model profile directory does not exist: file:\C:\rmqa\rmqa\target\rmqa-0.0.1-SNAPSHOT.jar!\firefox\profiles\selenium
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'XD-DW764-676', ip: '10.23.14.55', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_72'
Driver info: driver.version: EventFiringFirefoxDriver
at org.openqa.selenium.firefox.FirefoxProfile.verifyModel(FirefoxProfile.java:180)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:91)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:78)
at com.erac.automation.automationCommon.driver.AutomationProfileFactory.getFirefoxProfile(AutomationProfileFactory.java:27)
at com.erac.automation.automationCommon.driver.EventFiringFirefoxDriver.<init>(EventFiringFirefoxDriver.java:11)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
How should I access these .xpi files and get the profile folder?