Search code examples
javaseleniumphantomjsrpa

PhantomJS webdriver can't load url


I use phantomjs webdriver for RPA implementation. There is one url that it tries to load with this code:

webDriver.get(url);

The thing is that I can go to this url manually (just copying it into my address line in browser). It loads fine. But when it comes to phantomjs, it can't load it. I thought that it may be related to ssl protocol, so set these options for phantomjs:

--ignore-ssl-errors=true
--ssl-protocol=any
--web-security=true

Still the same thing. In debug mode I got the following logs when trying to load the url:

[DEBUG] HTTP Request - URI /session/1ed10cc0-ddc6-11e8-87f5-2f782befb71d/url
[DEBUG] HTTP Request - Method POST
[DEBUG] HTTP Request - HTTP Version 1.1
[DEBUG] HTTP Request - Query String 
[DEBUG] HTTP Request - Receiving Header "Accept" = "application/json, image/png"
[DEBUG] HTTP Request - Receiving Header "Content-Type" = "application/json; charset=utf-8"
[DEBUG] HTTP Request - Receiving Header "Content-Length" = "141"
[DEBUG] HTTP Request - Receiving Header "Host" = "localhost:64560"
[DEBUG] HTTP Request - Receiving Header "Connection" = "Keep-Alive"
[DEBUG] HTTP Request - Method POST/PUT
[DEBUG] HTTP Request - Content Body: {"url":"myHiddenUrl"}
[DEBUG] WebPage - updateLoadingProgress: 56
[DEBUG] WebPage - updateLoadingProgress: 58
[DEBUG] WebPage - updateLoadingProgress: 61
[DEBUG] WebPage - updateLoadingProgress: 63
[DEBUG] WebPage - updateLoadingProgress: 66
[DEBUG] WebPage - updateLoadingProgress: 69
[DEBUG] WebPage - updateLoadingProgress: 72
[DEBUG] WebPage - updateLoadingProgress: 74
[DEBUG] WebPage - updateLoadingProgress: 77
[DEBUG] WebPage - updateLoadingProgress: 80
[DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "http://localhost:8080/idea/style/kendo/fonts/glyphs/WebComponentsIcons.ttf?gedxeo"
[DEBUG] WebPage - updateLoadingProgress: 100
[DEBUG] WebPage - updateLoadingProgress: 10
[DEBUG] WebPage - setupFrame ""
[DEBUG] HTTP Response - Status Code 500 Internal Server Error
[DEBUG] HTTP Response - Sending Header "Cache" = "no-cache"
[DEBUG] HTTP Response - Sending Header "Content-Length" = "54132"
[DEBUG] HTTP Response - Sending Header "Content-Type" = "application/json;charset=UTF-8"

So as you see there is 500 error. But I have no idea to what it may be related. I don't have such an issue manually. Can it be something with request headers? Thanks in advance for any help with this issue.


Solution

  • You might be missing some POST request parameters where your request seems to be invalid.

    You are able to load the URL manually which narrows it down and supports the above statement.

    Make sure the request information being sent is not missing anything.