Hi Team,
We have a Property inside a Test Step called ProfileLocation.
While Opening a tapplan can we get current tapplan path
 /// <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
             
            
              
              
              
            
                
            
           
          
            
            
              This should work:
string testPlanPath = GetParent<TestPlan>()?.Path;
             
            
              
              
              2 Likes
            
            
           
          
            
            
              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.
             
            
              
              
              
            
            
           
          
            
            
              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.
             
            
              
              
              3 Likes
            
            
           
          
            
            
              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
             
            
              
              
              
            
            
           
          
            
            
              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.
        [Display("Test Plan Path")]
        [Browsable(true)]
        public string TestPlanPath
        {
            get
            {
                return GetParent<TestPlan>()?.Path;
            }
        }
             
            
              
              
              1 Like
            
            
           
          
            
            
              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.
             
            
              
              
              
            
            
           
          
            
            
              Hi @david-wsd ,
I am trying to access GetParent in the set of another property. it returns null.