4141 */
4242public class PhantomJSDriverBuilder extends DriverBuilder <PhantomJSDriverBuilder > {
4343
44- public static final String PHANTOMJS_EXECUTABLE_PATH_PROPERTY = PhantomJSDriverService .PHANTOMJS_EXECUTABLE_PATH_PROPERTY ;
44+ private static final String PHANTOMJS_EXECUTABLE_PATH_PROPERTY = PhantomJSDriverService .PHANTOMJS_EXECUTABLE_PATH_PROPERTY ;
4545
4646 private static final String EXCEPTION_MESSAGE = " \n Download the latest release at http://phantomjs.org/download.html and place it: \n " +
4747 "(1) on the classpath of this project; or\n " +
@@ -67,7 +67,7 @@ public PhantomJSDriverBuilder() {
6767 this (SystemUtils .IS_OS_WINDOWS , PHANTOMJS_EXECUTABLE_WINDOWS , PHANTOMJS_EXECUTABLE_LINUX );
6868 }
6969
70- public PhantomJSDriverBuilder (boolean isWindowsOS , String phantomjsExecutableWindows , String phantomjsExecutableLinux ) {
70+ PhantomJSDriverBuilder (boolean isWindowsOS , String phantomjsExecutableWindows , String phantomjsExecutableLinux ) {
7171 this .isWindowsOS = isWindowsOS ;
7272 this .phantomjsExecutableWindows = phantomjsExecutableWindows ;
7373 this .phantomjsExecutableLinux = phantomjsExecutableLinux ;
@@ -86,6 +86,12 @@ public PhantomJSDriverBuilder withPathToPhantomJS(String pathToPhantomJs) {
8686 @ Override
8787 protected WebDriver build () {
8888 autoDownloadDriverIfAskedFor (PhantomJSDriver .class );
89+ WebDriver webDriver = buildPhantomJS ();
90+ autoQuitDriverIfAskedFor (webDriver );
91+ return webDriver ;
92+ }
93+
94+ private WebDriver buildPhantomJS () {
8995 DesiredCapabilities capabilities = capabilities (new DesiredCapabilities ());
9096
9197 configurePhantomJsExecutablePath (capabilities );
0 commit comments