```

OS: Windows 10 pro
IDE: Eclipse Neon
JDK: version 1.8.0_91
Selenium standalone server: version 3.0.1
phantom.exe: version 2.1.1 Windows
phantom.jar: version 1.2.1
TestNG: version 6.9.9

```

**Description:**
I'm trying to use phantomJS headless browser together with selenium webdriver and java.
I need to load a https url which has a certificate error (The security certificate presented by this website was not issued by a trusted certificate authority). I need to pass this issue.
I've tried to do it (among other failed attempts) as follows:

*class initializeTest.java*

```
public class initializeTest{

public static WebDriver driver = null;

public static WebDriver settingBrowser(String browser) throws InterruptedException {

if(browser.equalsIgnoreCase("phantom")){
File file = new File("C:\\Program Files\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");

System.setProperty("phantomjs.binary.path", file.getAbsolutePath());

DesiredCapabilities capabilitiesPhantomJS = DesiredCapabilities.phantomjs();
capabilitiesPhantomJS.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ssl-protocol=tlsv1"});
capabilitiesPhantomJS.setPlatform(Platform.ANY);
capabilitiesPhantomJS.setJavascriptEnabled(true);
capabilitiesPhantomJS.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

driver = new PhantomJSDriver();
}

}
return driver;
}

```

*code excerpt from the class where that is run as a TestNG class*

```
@BeforeTest
public void navigate() throws InterruptedException{

String selectBrowser = "phantom"
this.driver = initializeTest.settingBrowser(selectBrowser);

driver.navigate().to(https://....);
thread.sleep(5000);

System.out.println(driver.getTitle());
System.out.println("Begin 2");

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.urlContains("login")); 
System.out.println(driver.getTitle());
}

```

**Result:** 

1. The first println runs and nothing is printed at the console.

2. "Begin 2" is printed and the last println is not executed (the login string at the url is not found).

3. the third println is not executed 

 The reason is that the url is not loaded, although I do not understand why.
Does anyone have an idea or knows a workaround?