Skip to content

Commit 14b8106

Browse files
committed
Added Phanbedder as dependency which handles OS and arch specific phantomjs binaries
1 parent 6ac05f1 commit 14b8106

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
<version>8.1.13.v20130916</version>
8282
<scope>test</scope>
8383
</dependency>
84+
<dependency>
85+
<groupId>net.anthavio</groupId>
86+
<artifactId>phanbedder-1.9.7</artifactId>
87+
<version>1.0.0</version>
88+
<scope>test</scope>
89+
</dependency>
8490
</dependencies>
8591

8692
<build>

src/test/java/ch/racic/selenium/helper/download/SeleniumDownloadHelperTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package ch.racic.selenium.helper.download;
77

8+
import net.anthavio.phanbedder.Phanbedder;
89
import org.apache.commons.io.FileUtils;
910
import org.eclipse.jetty.server.Handler;
1011
import org.eclipse.jetty.server.Server;
@@ -17,6 +18,8 @@
1718
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
1819
import org.openqa.selenium.ie.InternetExplorerDriver;
1920
import org.openqa.selenium.phantomjs.PhantomJSDriver;
21+
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
22+
import org.openqa.selenium.remote.DesiredCapabilities;
2023
import org.openqa.selenium.safari.SafariDriver;
2124

2225
import java.io.File;
@@ -53,7 +56,9 @@ public static void setUpClass() throws Exception {
5356

5457
@AfterClass
5558
public static void tearDownClass() throws Exception {
56-
server.stop();
59+
if (server != null) {
60+
server.stop();
61+
}
5762
}
5863

5964
@Before
@@ -78,7 +83,7 @@ public void testGetFileFromUrlHtmlUnit() throws Exception {
7883

7984
@Test
8085
public void testGetFileFromUrlChrome() throws Exception {
81-
//TODO put this into pom profiles which are OS specific
86+
//TODO put this into pom profiles which are OS specific or build helper lib like phantomjs has
8287
System.setProperty("webdriver.chrome.driver", "driver/chromedriver");
8388
driver = new ChromeDriver();
8489
invokeGetFileDataFromUrl();
@@ -101,14 +106,19 @@ public void testGetFileFromUrlFireFox() throws Exception {
101106

102107
@Test
103108
public void testGetFileFromUrlInternetExplorer() throws Exception {
109+
//TODO Fetch latest binaries and make arch specific profiles
104110
driver = new InternetExplorerDriver();
105111
invokeGetFileDataFromUrl();
106112
invokeGetFileFromUrl();
107113
}
108114

109115
@Test
110116
public void testGetFileFromUrlPhantomJS() throws Exception {
111-
driver = new PhantomJSDriver();
117+
// See http://blog.anthavio.net/2014/04/phantomjs-embedder-for-selenium.html
118+
File phantomjs = Phanbedder.unpack();
119+
DesiredCapabilities dcaps = new DesiredCapabilities();
120+
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjs.getAbsolutePath());
121+
driver = new PhantomJSDriver(dcaps);
112122
invokeGetFileDataFromUrl();
113123
invokeGetFileFromUrl();
114124
}

0 commit comments

Comments
 (0)