# Adding Command Line Variables with RobotCode

**URL:** https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477
**Category:** Visual Studio Code(ium)
**Created:** [15 November 2023 16:35 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477 "2023-11-15T16:35:47Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![robot\_wj](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@robot\_wj](https://forum.robotframework.org/u/robot_wj)
#### Post date: [15 November 2023 16:35 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/1 "2023-11-15T16:35:47Z")

</div>

I am looking for a way to be able to easily pass a command line variable to a test… on some executions.

Currently I know how to edit the Robotcode extension settings and add an item in the Robot:Variables section. But it would be great if I could run the test by right clicking beside the Test Case name and have an option there to select running with or without the variable specified.

There is an option for “Execute using profile” underneath the “Run” and “Debug” but information on setting up profiles is sparse.

I’m open to other alternatives that are more convenient, I could create the variable directly in the code and comment it out as needed but I’m hoping for something more elegant than that.

Thanks!

---

<div class="post-metadata">

### Author: ![daniel](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/daniel/32/1492_2.png) [@daniel](https://forum.robotframework.org/u/daniel)
#### Post date: [15 November 2023 23:41 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/2 "2023-11-15T23:41:45Z")

</div>

In principle, something like this is possible, albeit with a new function of RobotCode that is not yet fully finished and has not been publicly announced. I plan to present it to a larger audience for the first time at RoboCon 2024 in February. But I still need a few testers who are willing to try it out beforehand and check the documentation that is still to be created. Do you have time and possibly interest?

---

<div class="post-metadata">

### Author: ![robot\_wj](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@robot\_wj](https://forum.robotframework.org/u/robot_wj)
#### Post date: [16 November 2023 23:32 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/3 "2023-11-16T23:32:03Z")

</div>

Hi Daniel, thanks for the quick response. I’d definitely be willing to try it out and provide some feedback. Thanks!

---

<div class="post-metadata">

### Author: ![daniel](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/daniel/32/1492_2.png) [@daniel](https://forum.robotframework.org/u/daniel)
#### Post date: [17 November 2023 09:28 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/4 "2023-11-17T09:28:57Z")

</div>

ok, then let me activate the feature in the code and publish a new package and I’ll write a short guide here. I think I’ll be able to do that this weekend.

---

<div class="post-metadata">

### Author: ![robot\_wj](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@robot\_wj](https://forum.robotframework.org/u/robot_wj)
#### Post date: [17 November 2023 15:07 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/5 "2023-11-17T15:07:35Z")

</div>

Sounds good!

---

<div class="post-metadata">

### Author: ![daniel](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/daniel/32/1492_2.png) [@daniel](https://forum.robotframework.org/u/daniel)
#### Post date: [20 November 2023 22:03 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/6 "2023-11-20T22:03:20Z")

</div>

ok, there is a new version of robotcode, you need to update to at least 0.64.1.

Now you can create a `launch.config` if you don’t already have one.

Open your `launch.config`, now you can create a new “RobotCode: Test Profile” configuration.

It should look like this:

```json
{
    "name": "RobotCode: Test Profile",
    "type": "robotcode",
    "request": "launch",
    "presentation": {
        "hidden": true
    },
    "purpose": "test-profile"
},

```

The important thing is the `purpose` property, which defines what this configuration is for. This must be `test-profile`. If your VSCode is already set for your normal execution, you can now overwrite certain settings. For example, the robot global variables or the environment variables:

Here are a few examples:

```json
 {
    "name": "No Headless",
    "type": "robotcode",
    "request": "launch",
    "presentation": {
        "hidden": true
    },
    "purpose": "test-profile",
    "variables": {
        "HEADLESS": "False"
    }
  },
  {
    "name": "Test Env",
    "type": "robotcode",
    "request": "launch",
    "presentation": {
        "hidden": true
    },
    "purpose": "test-profile",
    "variables": {
        "URL": "https://test.app.com",
        "USER": "test_user"
    }
  },
  {
    "name": "Prod Env",
    "type": "robotcode",
    "request": "launch",
    "presentation": {
        "hidden": true
    },
    "purpose": "test-profile",
    "variables": {
        "URL": "https://prod.app.com",
        "USER": "prod_user"
    },
    "exclude": ["wip"]
  },

```

You can now select these profiles in the Test Explorer using the Run or Debug button. But also in the context menu of a test case or suite in the Explorer, but also on the Play button next to the test case in the Editor, via the “Execute Using Profile” entry,

You can also select the default profiles at the top of the Test Explorer, in the menu of the Run or Debug button. Please only select one profile at a time, otherwise the test will run 2 or 3 or 4 times at the same time. But this is a feature of VSCode, you just have to know it 😉

Hope that fits, if you find bugs or have any suggestions, it is easiest if you put an entry on github: [Issues · d-biehl/robotcode · GitHub](https://github.com/d-biehl/robotcode/issues)

And thanks in advance for trying out!!!

---

<div class="post-metadata">

### Author: ![robot\_wj](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@robot\_wj](https://forum.robotframework.org/u/robot_wj)
#### Post date: [21 November 2023 22:47 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/7 "2023-11-21T22:47:46Z")

</div>

Hi Daniel. I will download this and give it a try as soon as I can (hopefully tomorrow).

---

<div class="post-metadata">

### Author: ![robot\_wj](https://avatars.discourse-cdn.com/v4/letter/r/d26b3c/32.png) [@robot\_wj](https://forum.robotframework.org/u/robot_wj)
#### Post date: [23 November 2023 18:35 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/8 "2023-11-23T18:35:26Z")

</div>

Tried it on 64.1 and upgraded to 66.0 this morning. It worked seamlessly on 66. No issues with attached pydebug config. I was able to run tests by default without the added variable config (but with the variables specified in Robot:Variables in setting) and as well run using the execute using profile to get the profile specific variables. This is perfect as I can setup variables for default test execution in the settings and profile specific variables for alternate execution (where both sets of variables will be introduced).

This will save me considerable annoyance. You, sir, are a prince among men. You have my gratitude.

---

<div class="post-metadata">

### Author: ![daniel](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/daniel/32/1492_2.png) [@daniel](https://forum.robotframework.org/u/daniel)
#### Post date: [5 December 2023 10:43 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/9 "2023-12-05T10:43:08Z")

</div>

thank you!!!

---

<div class="post-metadata">

### Author: ![spicard](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@spicard](https://forum.robotframework.org/u/spicard)
#### Post date: [5 March 2024 18:24 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/10 "2024-03-05T18:24:42Z")

</div>

Hi Daniel. I see here the syntax to add variables and tags to a profile. And it works fine.  
What would be the syntax to add --argumentfile Arguments.txt to the profile in launch.json  
Thanks.

---

<div class="post-metadata">

### Author: ![daniel](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/daniel/32/1492_2.png) [@daniel](https://forum.robotframework.org/u/daniel)
#### Post date: [12 March 2024 16:29 UTC](https://forum.robotframework.org/t/adding-command-line-variables-with-robotcode/6477/11 "2024-03-12T16:29:44Z")

</div>

Sorry for the late answer,

try something like:

```jsonc
"args": [
   "--argumentfile", "Arguments.txt"
]

```
