# New headless mode not working

**URL:** <https://forum.robotframework.org/t/new-headless-mode-not-working/5790>\
**Category:** Robot Framework\
**Created:** [6 June 2023 14:54 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790 "2023-06-06T14:54:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeurchoice](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/makeurchoice/32/2702_2.png) [@makeurchoice](https://forum.robotframework.org/u/makeurchoice)\
**Post date:** [6 June 2023 14:54 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/1 "2023-06-06T14:54:42Z")

</div>

I being trying to use the new headless mode for Google Chrome but I don’t know what I maybe be doing wrong.

This is my suite\_setup.robot

```
***Settings***
Library SeleniumLibrary
Library String
Library Collections
Library OperatingSystem
Library DateTime
Library FakerLibrary locale=pt_BR

***Variables***
${HEADLESS}= ${HEADLESS}
${TEARDOWN}= True
${URL}= ${URL}
${FAST_TIMEOUT}= 5
${TIMEOUT}= 30
${LONG_TIMEOUT}= 60
${HARD_TIMEOUT}= 90

***Keywords***

Open Chrome
    ${CHROME_OPTIONS}= Evaluate selenium.webdriver.ChromeOptions()
    Call Method ${CHROME_OPTIONS} add_argument --incognito    
    Call Method ${CHROME_OPTIONS} add_argument --disable-notifications   
    Call Method ${CHROME_OPTIONS} add_argument --new-window   
    Call Method ${CHROME_OPTIONS} add_argument --aggressive-cache-discard        
    Call Method ${CHROME_OPTIONS} add_argument --disable-application-cache  
    Call Method ${CHROME_OPTIONS} add_argument --disable-dev-shm-usage
    Call Method ${CHROME_OPTIONS} add_argument --no-sandbox
    Call Method ${CHROME_OPTIONS} add_argument --disable-gpu
    Call Method ${CHROME_OPTIONS} add_argument --mute-audio
    Call Method ${CHROME_OPTIONS} add_argument --start-maximized
    Run Keyword If ${HEADLESS}==True With Headless ${CHROME_OPTIONS}
    Run Keyword If ${HEADLESS}==False Without Headless ${CHROME_OPTIONS}

With Headless
    [Arguments] ${CHROME_OPTIONS}
    Call Method ${CHROME_OPTIONS} add_argument --headless=new
    Open Browser ${URL} chrome options=${CHROME_OPTIONS}
    Set Window Size 1920 1080

Without Headless
    [Arguments] ${CHROME_OPTIONS}
    Open Browser ${URL} chrome options=${CHROME_OPTIONS}

```

As soon I run the following command `robot -d ./results -v HEADLESS:True ./Cases` I get this error in the terminal: `Calling method 'add_argument' failed: TypeError: ArgOptions.add_argument() got an unexpected keyword argument '--headless'`.

This is my requirements I’m using:

```
Faker==4.16.0
python-dateutil==2.8.1
robotframework==6.0.2
robotframework-faker==5.0.0
robotframework-pabot==2.15.0
robotframework-pythonlibcore==4.1.2
robotframework-seleniumlibrary==6.1.0
selenium==4.9.0
six==1.12.0
text-unidecode==1.3
urllib3==1.26.10
wrapt==1.12.1
qase-robotframework==1.1.1

```

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [6 June 2023 20:59 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/2 "2023-06-06T20:59:26Z")

</div>

As far I as know the **new** headless mode is very easy to use. For example in the below test:

```python
***Settings***
Library SeleniumLibrary

***Test Cases***
Testing Headless Chrome
    Open Browser https://robotframework.org/ headlesschrome
    Sleep 5 seconds
    Capture Page Screenshot
    Close Browser

```

---

<div class="post-metadata">

**Author:** ![makeurchoice](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/makeurchoice/32/2702_2.png) [@makeurchoice](https://forum.robotframework.org/u/makeurchoice)\
**Post date:** [7 June 2023 12:12 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/3 "2023-06-07T12:12:00Z")

</div>

@HelioGuilherme66 I saw this option in the selenium documentation but I thought it still use the old headless mode. I was trying using the parameter `headless=new` because it is in the Google documentation.

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [7 June 2023 13:17 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/4 "2023-06-07T13:17:11Z")

</div>

OK, but the RF community always try to make things simpler 🙂

---

<div class="post-metadata">

**Author:** ![Mats](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mats/32/2923_2.png) [@Mats](https://forum.robotframework.org/u/Mats)\
**Post date:** [21 August 2023 15:23 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/5 "2023-08-21T15:23:58Z")

</div>

I have not been able to get the new functionality from Google to work with robot framework. That is using headlesschrome argument or headless=new. And with the new drivers from chrome the headlesschrome does not longer seem to work as they did a couple of months back.  
I’m probably just confused on what to use as of right now and hopefully I will get some clarity here at this forum in the future.

---

<div class="post-metadata">

**Author:** ![makeurchoice](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/makeurchoice/32/2702_2.png) [@makeurchoice](https://forum.robotframework.org/u/makeurchoice)\
**Post date:** [21 August 2023 21:35 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/6 "2023-08-21T21:35:19Z")

</div>

We started using headlesschrome here but the problems we had with the “normal” were still happening. For now, we have 6-7 test cases running with Firefox. For some reason, the headless firefox works in some way different than chrome.

---

<div class="post-metadata">

**Author:** ![kulkarnivickee](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kulkarnivickee](https://forum.robotframework.org/u/kulkarnivickee)\
**Post date:** [28 July 2024 12:49 UTC](https://forum.robotframework.org/t/new-headless-mode-not-working/5790/7 "2024-07-28T12:49:09Z")

</div>

There is option to create common keyword to run on multiple headless browser option.

headless Chrome or Firefox.

Below is the code snippet.

\*\*\* Keywords \*\*\*  
Open Headless Browser  
Set Environment Variable ${browser}  
Set Environment Variable ${url}  
${options} Evaluate sys.modules[‘selenium.webdriver’].${browser}Options()  
… modules=sys, selenium.webdriver  
Call Method ${options} add\_argument --headless  
Create Webdriver ${browser} ${options}  
Go To ${url}

Pass the browser name you want to be headless, along with URL value in the script run command.
