15

I'm using the Java bindings of GhostDriver to run Selenium acceptance tests against PhantomJS.

If one of the web pages requested by PhantomJS logs to the Javascript console via console.log, is there a way to capture or view those messages?

I'm guessing that the answer to this is forehead-slappingly simple but I can't work it out!

kelveden
  • 153
  • 1
  • 2
  • 6

1 Answers1

12
LogEntries logs = driver.manage().logs().get("browser");
lukeis
  • 1,983
  • 2
  • 19
  • 19
  • Yes, that should now work since that part of the [WebDriver Wire Protocol](http://code.google.com/p/selenium/wiki/JsonWireProtocol) was [implemented](https://github.com/detro/ghostdriver/issues/279) in GhostDriver a few weeks ago. i.e. it should work with GhostDriver 1.1.0. Once PhantomJS is upgraded to embed GhostDriver 1.1.0 all should be rosy. Therefore I'm going to accept this as the correct answer. – kelveden Jan 16 '14 at 10:38
  • 1.9.6 of phantomjs should have it :) – lukeis Jan 25 '14 at 08:03
  • 1
    Yes, it should do. Unfortunately the combination of PhantomJS/GhostDriver in 1.9.6 is a bit bricked because of this: https://github.com/ariya/phantomjs/issues/11915. It sounds like a 1.9.7 release to fix the issue is imminent though. I'll update when I've been able to make use of the new release. (This is assuming that they go down the fix-forward route rather than rollback to GhostDriver 1.0 of course!) – kelveden Jan 27 '14 at 10:02
  • 2
    How would you do this in C#? There is no `Logs` method on the manage object. – Mathias Lykkegaard Lorenzen Oct 28 '14 at 14:30
  • Ever figure this out @MathiasLykkegaardLorenzen ? – George Mauer Nov 21 '14 at 02:43
  • Yes, in a hackish way. I overwrote the onError method on the page object to add a `div` with a specific class on error with all the details in it. Then, from my unit tests, I made helper methods to check if such error `div`s were encountered. – Mathias Lykkegaard Lorenzen Nov 21 '14 at 09:29
  • The current WebDriver version 2.53.0.0 has a Logs property: driver.Manage().Logs.GetLog(OpenQA.Selenium.LogType.Browser) – user3167162 May 25 '16 at 01:10