# Unable to get console logs from a local html file, what is the reason?

**URL:** <https://forum.katalon.com/t/unable-to-get-console-logs-from-a-local-html-file-what-is-the-reason/185939>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [November 26, 2025, 8:15am UTC](https://forum.katalon.com/t/unable-to-get-console-logs-from-a-local-html-file-what-is-the-reason/185939 "2025-11-26T08:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxfair](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@maxfair](https://forum.katalon.com/u/maxfair)\
**Post date:** [November 26, 2025, 8:15am UTC](https://forum.katalon.com/t/unable-to-get-console-logs-from-a-local-html-file-what-is-the-reason/185939/1 "2025-11-26T08:15:16Z")

</div>

For example, I created a html file that outputs a statement (test.html):

```go
<body onload="console.log('test')"></body>

```

also created a function to test if console log is non-empty, which test() would be called during testing to check if there is any log printed:

```auto
package com.example.keywords

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.WebDriver
import org.openqa.selenium.logging.LogEntry
import org.openqa.selenium.logging.LogType

public class TestKeywords {

	private static List<LogEntry> cachedLogs = []

	@Keyword
	def test() {
		assert !DriverFactory.getWebDriver().manage().logs().get(LogType.BROWSER).getAll().isEmpty()
		return true
	}
}

```

When test.html is put into the server and run the test, the test passed:

 ![p1](https://europe1.discourse-cdn.com/katalon/original/3X/4/a/4a5b3e6c26afc631036d2c76166b3a803bfc575b.jpeg)

* * *

but when move test.html out of server and change the url to local file, the test failed:

 ![p2](https://europe1.discourse-cdn.com/katalon/original/3X/b/3/b329b9ba2d0aadb588219d7bac99f22e6025f6b8.png)

what is the reason?

---

<div class="post-metadata">

**Author:** ![nghi.phan](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nghi.phan/32/30970_2.png) [@nghi.phan](https://forum.katalon.com/u/nghi.phan)\
**Post date:** [November 26, 2025, 8:26am UTC](https://forum.katalon.com/t/unable-to-get-console-logs-from-a-local-html-file-what-is-the-reason/185939/2 "2025-11-26T08:26:34Z")

</div>

Dear maxfair,

Thank you for your question, from what I have found in our library this can be explained this way:

It’s happening because of **how the browser + WebDriver handle console logs for `file://` pages** , not because of Katalon or your code.

### What’s going on?

When you open:

```auto
file:///.../test.html

```

most modern browsers (Chrome, Edge, etc.) treat this as a **local file origin** , which has a stricter / special security model.

* * *

**Solution** :

**Use a Local Web Server (Recommended)** Instead of opening the file directly, serve it locally:

// Use a simple HTTP server to serve your local HTML file  
// Option A: Python (if installed)  
// python -m http.server 8000

// Option B: Node.js (if installed)  
// npx http-server

// Then access it via: [http://localhost:8000/test.html](http://localhost:8000/test.html)

This can be the most reliable approach and aligns with how web applications are actually tested in production environments. This eliminates the security restrictions and ensures your tests behave consistently.

Let us know if that helps

Bella

---

<div class="post-metadata">

**Author:** ![depapp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/depapp/32/29178_2.png) [@depapp](https://forum.katalon.com/u/depapp)\
**Post date:** [November 26, 2025, 8:32am UTC](https://forum.katalon.com/t/unable-to-get-console-logs-from-a-local-html-file-what-is-the-reason/185939/3 "2025-11-26T08:32:59Z")

</div>

hi @maxfair

when you load via `file://`, chrome treats it as a `"null origin"` and the logging APIs behave differently (or just don’t work)

quickest fix: `cd` to your html folder and run `python -m http.server 8080`, then hit `http://localhost:8080/test.html`

so `Navigate To Url` value should be [http://localhost:8080/test.html](http://localhost:8080/test.html) instead of `file://Users/testUser/xxxxxx`
