0

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>
Aeteros
  • 643
  • 1
  • 10
  • 24
  • I guess that's not the case. Tried both "--ssl-protocol=tlsv1" and "--web-security=false", "--ignore-ssl-errors=true" options – Aeteros Dec 21 '15 at 09:49
  • Then you can try to upgrade your PhantomJS version. – Artjom B. Dec 21 '15 at 09:52
  • Sorry, my fault. Actually, using "--ssl-protocol=tlsv1" fixed the problem: DesiredCapabilities caps = DesiredCapabilities.phantomjs(); caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ssl-protocol=tlsv1"}); WebDriver driver = new PhantomJSDriver(caps); – Aeteros Dec 21 '15 at 10:03
  • You should be able to confirm the duplicate now. There should be a link above your question. – Artjom B. Dec 21 '15 at 11:10

0 Answers0