Here's how I try to load web page content:
System.setProperty("phantomjs.binary.path", PhantomJsDowloader.getPhantomJsPath());
WebDriver driver = new PhantomJSDriver();
driver.get("https://www.google.ru/?gws_rd=ssl");
System.out.println(driver.getTitle());
System.out.println(driver.getPageSource());
driver.quit();
It works. When I try to load the other specific website, it says the page is empty:
System.setProperty("phantomjs.binary.path", PhantomJsDowloader.getPhantomJsPath());
WebDriver driver = new PhantomJSDriver();
driver.get("https://www.avito.ru/");
System.out.println(driver.getTitle());
System.out.println(driver.getPageSource());
driver.quit();
Output:
PhantomJS is launching GhostDriver...
[INFO - 2015-12-21T08:23:45.460Z] GhostDriver - Main - running on port 44702
[INFO - 2015-12-21T08:23:46.167Z] Session [276997f0-a7bc-11e5-8fb7-7daedea9cbfa] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO - 2015-12-21T08:23:46.167Z] Session [276997f0-a7bc-11e5-8fb7-7daedea9cbfa] - page.customHeaders: - {}
[INFO - 2015-12-21T08:23:46.167Z] Session [276997f0-a7bc-11e5-8fb7-7daedea9cbfa] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"windows-8-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2015-12-21T08:23:46.167Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 276997f0-a7bc-11e5-8fb7-7daedea9cbfa
<html><head></head><body></body></html>
[INFO - 2015-12-21T08:23:46.571Z] ShutdownReqHand - _handle - About to shutdown
Why PhantomJS fails? Is it bug or it is some kind of protection? I still can open and read that website with ChromeDriver, so that kind of "protection" is useless.
Libraries are:
<dependencies>
<dependency>
<groupId>com.github.igor-suhorukov</groupId>
<artifactId>phantomjs-runner</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>