Devtools console errors

Hello, guys!

I want to know if Katalon or WebDriver can get the erros on Chrome Devtools console.
For example, when the user try to login with wrong credentials, besides the error alert, we print an error message on the console. How can i get this error message on Katalon?

Thanks!

See the reply fro Vinh here: http://forum.katalon.com/discussion/4820/verify-some-javascript-errors-from-console-browser

Hello, Russ

I dont know why, but it doesnt work for me. :confused:

Thanks!

@Mateus Gomes Binatti

Try this:

WebDriver driver = DriverFactory.getWebDriver()
LogEntries logs = driver.manage().logs().get("browser")
for (LogEntry entry : logs) {
WebUI.comment("##### ${entry.getLevel()}")
WebUI.comment("##### ${entry.getMessage()}")
}

I just tried it - same problem, doesn’t work.

I originally saw that message and kept a link to it because it sounded useful and knew I’d probably get to using it “one day”.

Perhaps @Vinh Nguyen will respond.

Hey Mate

Sorry, our messages seemed to have crossed midair – I was replying to Mateus.

Have you actually tried this code? I get this:

org.openqa.selenium.UnsupportedCommandException: POST /session/4169109c-483d-4c1a-b152-68bf8fb11fdc/log did not match a known command …

Which is a little odd - the word log (singular) is not used.

Yes, I tried it and it works.

Browser? I’m using Firefox.

Here’s my code – see anything wrong?

  /**
   * NOT WORKING
   * 
   * Source: http://forum.katalon.com/discussion/4820/verify-some-javascript-errors-from-console-browser
   */
  void appendBrowserLogs() {
    WebDriver driver = DriverFactory.getWebDriver()
    LogEntries logs = driver.manage().logs().get("browser")

    for (LogEntry entry : logs) {
      append(entry.getLevel() + " " + entry.getMessage())
    }
  }

1 Like

I’m using Chrome.

Not sure what “append” does (apart from obvious intention).

When I use @Vinh’s example with

println entry.getLevel() + " " + entry.getMessage() 

this is what I get:

groovy.lang.MissingMethodException: No signature of method: java.util.logging.Level.plus() is applicable for argument types: (java.lang.String) values: [ ]
Possible solutions: parse(java.lang.String), split(groovy.lang.Closure), is(java.lang.Object), use([Ljava.lang.Object;), wait(), dump()

But when I divide it to

println entry.getLevel() 
println entry.getMessage()

both level and message get printed.

1 Like

@Russ Thomas

I’ll take an uneducated guess… :#
Maybe it has something to do with the app. What happens if no messages are generated in the dev tools console?

There’s ALWAYS console messages in the dev version of our app (I wrote them B) )

Not sure what “append” does (apart from obvious intention).

Yeah, it’s part of something bigger :slight_smile: I was sure you’d figure that out :wink:

Try this your end:

println entry.getLevel().toString() + " " + entry.getMessage()

Work now?

Sup, guys!

I’ve tried mate’s answer and did not work too.
Theres no error message on katalon console/log viewer, but it doesnt print. :confused:

Where should i paste the code, after WebUI.openBrowser(’’);?
Im using chrome, if it helps.

Thanks

Where should i paste the code

Well that depends on what you’re trying to achieve. My purpose was to gather the entire log and then (one day) write more code to sift through it for significant messages. So for me, I was intending to run that code at the end of a test case (during one of my @AfterTestCase methods).

What browser are you using? Firefox?

Sorry, guys, i’ve made a mistake.

Forgot to call appendBrowserLogs()

06-20-2018 01:31:25 PM - [START] - Start action : Statement - println(entry.getMessage())

https://betaapp.universal.org.br/sgiurdfront/assets/js/src/iurd-min.js?random_string=1529512283045 0:7789 “Request Error #6. URL: /sgiurd/usuarioSG.do Action: 7”

06-20-2018 01:31:25 PM - [END] - End action : Statement - println(entry.getMessage())

Thank you, guys.
Best regards!

The logging APIs (as I listed above) are officially not working in Firefox/geckodriver – their reasoning: “it’s not standard”.

Hope this saves other people from wasting a ton of time.

Russ Thomas said:

There’s ALWAYS console messages in the dev version of our app (I wrote them B) )

Not sure what “append” does (apart from obvious intention).

Yeah, it’s part of something bigger :slight_smile: I was sure you’d figure that out :wink:

Try this your end:

println entry.getLevel().toString() + " " + entry.getMessage()

Work now?

This is working. Thanks!


Mine just doesn’t print anything regardless of the print statement. Any idea why?

Capture.PNG

Capture3.PNG

@7562-Bella

You don’t get any error messages, you just don’t get anything printed?
Maybe there’s nothing to print - no console errors?

@Mate Mrse Nothing is printed. Not even the Hello. :frowning: