Forum Discussion

JohanH's avatar
JohanH
Occasional Contributor
8 years ago

ProjectSuite.TestItems.Current Fails

  Hi,

 

When trying to use 'ProjectSuite.TestItems.Current' I get a runtime exception message "The parameter is incorrect". Anyone knows how to work around or why this is happening?

 

    current = ProjectSuite.TestItems.Current
    Log.Message('Current Item', 
                ("Name: {}\n" +
                "Description: {}\n" +
                "Location: {}").format(current.ProjectName,
                                       current.Description,
                                       current.ProjectLocation))

  - Johan

4 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    Try this:

     

    current = Project.TestItems.Current
        Log.Message('Current Item', 
                    ("Name: {}\n" +
                    "Description: {}\n" +
                    "Location: {}").format(current.ProjectName,
                                           current.Description,
                                           current.ProjectLocation))
    • JohanH's avatar
      JohanH
      Occasional Contributor

      'Project.TestItems.Current' and 'ProjectSuite.TestItems.Current' is not the same and does not even have the same interface.

       

      There are no 'ProjectName' property on the TestItem, it is only named 'Name'...

       

      I would like to know the Name of the currently running project (and test file/function) but that seems not to be possible...

       

      - Johan

      • Ryan_Moran's avatar
        Ryan_Moran
        Valued Contributor

        Ok, there are a lot of ways to get the information you are looking for.

        If you want to use Current that is probably not going to work unless you are running the entire project suite.

        If you want to use ProjectSuite.TestItem(indexofyourprojecthere) that will give you the properties you are specifically looking for.

        If you just want the name of your project and it's file path you can get that from this

        (probably an easier method somewhere but this works):

        current = ['Name','Path'];
        
        current.Name = 
            Project.Path.split('').reverse().join('')
                    .substr(1,
                        Project.Path.split('').reverse().join('').indexOf('\\',1) - 1)
                            .split('').reverse().join('');
        
        current.Path = Project.Path;