# How to run test in headed mode using VS Code

**URL:** <https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434>\
**Category:** Browser\
**Created:** [15 June 2024 00:34 UTC](https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434 "2024-06-15T00:34:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![f-w](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/f-w/32/3981_2.png) [@f-w](https://forum.robotframework.org/u/f-w)\
**Post date:** [15 June 2024 00:34 UTC](https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434/1 "2024-06-15T00:34:23Z")

</div>

Hi, I’m new to robotframework and Playwright. I installed

1. robotframework browser library

2. VS code with Robot Framework language server extension  
I can run following sample test successfully in headless mode. But how can I run it in headed mode, i.e. showing browser UI?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [15 June 2024 02:07 UTC](https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434/2 "2024-06-15T02:07:23Z")

</div>

Hi Fred,

From the documentation for [New Page](https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Page):

> When a [New Page](https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Page) is called without an open browser, [New Browser](https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Browser) and [New Context](https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Context) are executed with default values first.

The setting you are after is in [New Browser](https://marketsquare.github.io/robotframework-browser/Browser.html#New%20Browser):

> headless = True bool

so you’ll want to change your test to:

```python
***Settings***
Library Browser

***Test Cases***
Run Test
    New Browser headless=False
    New Page https://playwright.dev
    Get Text h1 contains Playwright

```

Dave.

---

<div class="post-metadata">

**Author:** ![f-w](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/f-w/32/3981_2.png) [@f-w](https://forum.robotframework.org/u/f-w)\
**Post date:** [15 June 2024 12:08 UTC](https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434/3 "2024-06-15T12:08:38Z")

</div>

Hi Dave,  
Thanks for the solution. What if the test suite needs to be executed in both headed and headless mode, and the condition is defined outside of the script, say, via env or CLI argument?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [15 June 2024 12:40 UTC](https://forum.robotframework.org/t/how-to-run-test-in-headed-mode-using-vs-code/7434/4 "2024-06-15T12:40:02Z")

</div>

Hi Fred,

Just create a variable like this:

```python
***Settings***
Library Browser

***Variables***
${HEADLESS} ${True}

***Test Cases***
Run Test
    New Browser headless=${HEADLESS}
    New Page https://playwright.dev
    Get Text h1 contains Playwright

```

Now it defaults to headless (or defaults to headed if you set it False), which you can override on the command line with the `-v` or `--variable` option, like this:

```python
robot -v HEADLESS:${False} robotfile.robot

```

Dave.
