0

See the code

from selenium import webdriver

driver = webdriver.PhantomJS()
driver.get("http://www.metasozluk.com/?r=girdi/goster&g=298794")
driver.page_source
# Returns a whole bunch of HTML page.

driver.find_element_by_css_selector(".entry-list-cats-link").click()
driver.page_source
# Returns '<html><head></head><body></body></html>'

When I load a page with Python's Selenium on PhantomJS, the page loads well. However, when I try to manipulate a DOM element, it simply changes the whole source to <html><head></head><body></body></html>.

Also this issue does not occur in Firefox, but I need a headless browser and there seems to be no other alternative rather than PhantomJS. Is it a bug?

Edit: Found Some Logs

I've found a log name ghostdriver.log on the same path as my script. This is it:

PhantomJS is launching GhostDriver...
[INFO  - 2015-11-07T20:45:38.121Z] GhostDriver - Main - running on port 51516
[INFO  - 2015-11-07T20:45:39.090Z] Session [8101ecc0-8590-11e5-91d2-17516fa65f1d] - CONSTRUCTOR - Desired Capabilities: {"platform":"ANY","version":"","javascriptEnabled":true,"browserName":"phantomjs"}
[INFO  - 2015-11-07T20:45:39.090Z] Session [8101ecc0-8590-11e5-91d2-17516fa65f1d] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.0","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"linux-unknown-64bit","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-11-07T20:45:39.091Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 8101ecc0-8590-11e5-91d2-17516fa65f1d
[INFO  - 2015-11-07T20:50:38.119Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2015-11-07T20:55:38.213Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2015-11-07T21:00:38.311Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO  - 2015-11-07T21:05:38.330Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW

I'm not sure about _cleanupWindowlessSessions part, maybe this is a clue about problem.


Edit: --ignore-ssl-errors=true did not solve the problem

I did a further coding, but I run across the same issue while ignoring ssl errors. There are also few answers saying ignoring SSL errors would solve the issue, but it seems not. So I cancelled this answer's validity for the sake of anyone having this issue.

2
  • Could you give your code please ? Commented Nov 7, 2015 at 21:06
  • The link above works I suppose? Commented Nov 7, 2015 at 21:08

1 Answer 1

3

I'm having the same issue, many people are reporting that ignoring ssl issues solves it, so it may work for you.

self.driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
Sign up to request clarification or add additional context in comments.

1 Comment

That actually did well. Thanks. ^^

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.