# Enabled attribute not available in test steps created in Python

**URL:** <https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344>\
**Category:** Technical\
**Tags:** python\
**Created:** [June 15, 2021, 10:09am UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344 "2021-06-15T10:09:30Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 15, 2021, 10:09am UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/1 "2021-06-15T10:09:30Z")

</div>

I’ve noticed that test steps created in Python, including the examples, don’t have `Enabled` parameter exposed to the UI in the step settings. At the same time, `Break Conditions` and `Description` attributes coming from the base test step are exposed properly. Adding this attribute explicitly seems to confuse OpenTAP completely. Does anyone know what causes this behavior and whether there’s a workaround?

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 22, 2021, 5:12pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/2 "2021-06-22T17:12:04Z")

</div>

Because of the generic types used in the C# version of Enabled this is implemented slightly different than the standard attributes. You can see an example here:

> <https://gitlab.com/OpenTAP/Plugins/python/-/blob/master/Keysight.OpenTap.Plugins.Python/PluginExample/BasicFunctionality.py#L66>

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 22, 2021, 8:17pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/3 "2021-06-22T20:17:21Z")

</div>

Are you saying that `Enabled` attribute won’t come from the base `TestStep` class and it needs to be added explicitly (similar to the provided example)?

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 22, 2021, 8:26pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/4 "2021-06-22T20:26:43Z")

</div>

That is not what I meant, but is that the behavior you are seeing? I was just trying to say that handling those types is a little different (OpenTap.Enabled):

```python
logging = self.AddProperty("Logging", OpenTap.Enabled[String](), OpenTap.Enabled[String])

```

And you also have to import the .NET types:

```python
from System import Array, Double, Byte, Int32, String, Boolean # Import types to reference for generic methods   

```

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 22, 2021, 8:46pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/5 "2021-06-22T20:46:45Z")

</div>

Yeah, that’s the behavior I’m seeing. Maybe my initial message was not so clear but I was talking about `TestStep.Enabled` attribute, not `OpenTap.Enabled` datatype 🙂

---

<div class="post-metadata">

**Author:** ![john.berlien](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@john.berlien](https://forum.opentap.io/u/john.berlien)\
**Post date:** [June 22, 2021, 10:16pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/6 "2021-06-22T22:16:27Z")

</div>

So you’re talking about the _property_, not the attribute?

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 22, 2021, 10:35pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/7 "2021-06-22T22:35:49Z")

</div>

@pythonized ok thanks for the clarification. I see what you mean now. That does appear to be a bug, and I have submitted it here:

> **[Enabled Step Setting Property Does not appear (#35) · Issues · OpenTAP /...](https://gitlab.com/OpenTAP/Plugins/python/-/issues/35)**
>
> The Common \> Enabled Setting does not appear for Python-based Test Steps:

You can of course enable/disable the Test Step manually from the Test Plan Panel.

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 23, 2021, 8:24am UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/8 "2021-06-23T08:24:57Z")

</div>

@john.berlien Thanks for the correction, I meant the _property_ indeed. The _attribute_ is actually there.

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 23, 2021, 6:30pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/9 "2021-06-23T18:30:10Z")

</div>

As a workaround, it seems to work if property and attribute are added to the step explicitly:

```csharp
        self.AddProperty("Enabled", True, Boolean).AddAttribute(OpenTap.DisplayAttribute, "Enabled", "", Group="Common", Order=20000, Collapsed=True).\
        AddAttribute(OpenTap.ColumnDisplayNameAttribute, "", Order=-101)

```

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 26, 2021, 10:38pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/10 "2021-06-26T22:38:54Z")

</div>

@brennen_direnzo It seems that there’s a similar issue with `TestStep.Name`. I couldn’t find a good workaround for that one though. I can add it explicitly as `TestStep.Enabled` but I’m not really able to make use of it. Namely, I can set `self.Name` but it doesn’t have any effect. I’ve also tried using `OnPropertyChanged` but with no luck.

My use case is to have different display name and regular name like in `Sweep Parameter` step: `Sweep Parameter` vs `Sweep {Parameters}`.

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 28, 2021, 3:55pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/11 "2021-06-28T15:55:48Z")

</div>

Where are you trying to update this? DisplayName is generally the right place to make these changes, but they aren’t really intended to be dynamically updated outside of using “{ }” in the DisplayName

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 28, 2021, 5:14pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/12 "2021-06-28T17:14:21Z")

</div>

@brennen_direnzo Ah I mixed it up I think. Actually it’s `DisplayName` that is missing and it can be fixed the same way as `Enabled`!

```csharp
self.AddProperty("DisplayName", "", String).\
            AddAttribute(OpenTap.DisplayAttribute, "Step Name", "", Group="Common", Order=20001, Collapsed=True).\
            AddAttribute(OpenTap.ColumnDisplayNameAttribute, "Name", Order=-100)

```

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 28, 2021, 5:56pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/13 "2021-06-28T17:56:02Z")

</div>

You should also be able to add the DisplayAttribute like this:

```python
@Attribute(DisplayAttribute, Name="Charge", Description="Simulated scenario of an emulated power analyzer charging a battery and measuring the voltage curve.", Groups= ["Python Example", "Battery Test"])
class ChargeStep(SamplingStepBase):

```

> <https://gitlab.com/OpenTAP/Plugins/python/-/blob/master/Keysight.OpenTap.Plugins.Python/PluginExample/ChargeStep.py#L20>

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 28, 2021, 8:33pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/14 "2021-06-28T20:33:26Z")

</div>

@brennen_direnzo Not sure I fully understand your idea 🙂 To my best knowledge, applying this decorator to a test step will only set `TestStep.Name` and at the moment there’s no way to set `DisplayName` unless it’s added explicitly like `Enabled`.

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 28, 2021, 8:36pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/15 "2021-06-28T20:36:24Z")

</div>

In this case DisplayAttribute Name == DisplayName (as in the name that will appear in the Editor). It should accomplish the same as your code, just in a slightly simplified way

---

<div class="post-metadata">

**Author:** ![pythonized](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@pythonized](https://forum.opentap.io/u/pythonized)\
**Post date:** [June 28, 2021, 8:52pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/16 "2021-06-28T20:52:01Z")

</div>

My original idea was to have _Name != DisplayName_. Is it possible to accomplish that this way? My experiments show that setting `TestStep.DisplayName` doesn’t have any effect unless the suggested code is added.

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [June 28, 2021, 8:53pm UTC](https://forum.opentap.io/t/enabled-attribute-not-available-in-test-steps-created-in-python/344/17 "2021-06-28T20:53:19Z")

</div>

I see. Then your implementation makes sense.
