# Can we get Opened TapPlan path inside a Test step?

**URL:** <https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446>\
**Category:** General\
**Created:** [September 15, 2021, 5:02am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446 "2021-09-15T05:02:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![justin\_c\_i](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/justin_c_i/32/232_2.png) [@justin\_c\_i](https://forum.opentap.io/u/justin_c_i)\
**Post date:** [September 15, 2021, 5:02am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/1 "2021-09-15T05:02:11Z")

</div>

Hi Team,

We have a Property inside a Test Step called ProfileLocation.

While Opening a tapplan can we get current tapplan path

```csharp
 /// <summary>
        /// Gets or sets Profile location.
        /// </summary>
        [Browsable(false)]
        public string Profilelocation
        {
            get => this.profilelocation; set
            {
                this.profilelocation = value;
                if (!this.isProfileSaving)
                {

                    var profLocat= Path.GetDirectoryName(GetCurrentTestPlanPath()) + this.profilelocation;
                }
            }
        }

```

Please suggest

Regards  
Jestin CI

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [September 15, 2021, 6:23pm UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/2 "2021-09-15T18:23:44Z")

</div>

This should work:  
`string testPlanPath = GetParent<TestPlan>()?.Path;`

---

<div class="post-metadata">

**Author:** ![justin\_c\_i](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/justin_c_i/32/232_2.png) [@justin\_c\_i](https://forum.opentap.io/u/justin_c_i)\
**Post date:** [September 16, 2021, 1:37am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/4 "2021-09-16T01:37:06Z")

</div>

Hi @david-wsd ,

Mentioned function works after loading the TapPlan,.

While loading the tapplan GetParent is null.

Is there any way to get path while loading the TapPlan.

I Tried Task.Run() and wait until Parent get filled, it works.  
but we need to get in between loading the tapplan.

Tried some reflection methods, but I understand like TestPlanPath gets filled only after loading completes.

---

<div class="post-metadata">

**Author:** ![justin\_c\_i](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/justin_c_i/32/232_2.png) [@justin\_c\_i](https://forum.opentap.io/u/justin_c_i)\
**Post date:** [September 16, 2021, 9:59am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/5 "2021-09-16T09:59:27Z")

</div>

Hi @david-wsd ,

I changed the logic and I created a TapPlan loaded function using GetParent method and I called my function there. Thanks for the suggestion.

---

<div class="post-metadata">

**Author:** ![justin\_c\_i](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/justin_c_i/32/232_2.png) [@justin\_c\_i](https://forum.opentap.io/u/justin_c_i)\
**Post date:** [September 20, 2021, 2:33am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/6 "2021-09-20T02:33:54Z")

</div>

Hi @david-wsd ,

On further testing I understand this way does not work.

If we try to get path in separate thread, in mean time all the test steps will be loaded, and some of test step using Profile settings will display error like “Instrument not found”.

So need to get the Plan path before loading the plan,

Immediatley like after OpenFileDialog is closed.

Regards  
Jestin CI

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [September 20, 2021, 4:46pm UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/7 "2021-09-20T16:46:16Z")

</div>

Hi @justin_c_i, this seems to reliably display the test plan path right after opening a test plan. I’m not sure the exact details of what you need to do, but hopefully this might help.

```csharp
        [Display("Test Plan Path")]
        [Browsable(true)]
        public string TestPlanPath
        {
            get
            {
                return GetParent<TestPlan>()?.Path;
            }
        }

```

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [September 20, 2021, 4:47pm UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/8 "2021-09-20T16:47:36Z")

</div>

I do see that `GetParent<TestPlan>()` returns null when called from a test step’s constructor. Maybe that is part of what you’re facing.

---

<div class="post-metadata">

**Author:** ![justin\_c\_i](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/justin_c_i/32/232_2.png) [@justin\_c\_i](https://forum.opentap.io/u/justin_c_i)\
**Post date:** [September 21, 2021, 12:47am UTC](https://forum.opentap.io/t/can-we-get-opened-tapplan-path-inside-a-test-step/446/9 "2021-09-21T00:47:31Z")

</div>

Hi @david-wsd ,

I am trying to access GetParent in the set of another property. it returns null.
