get count of charecters from Description field in Test Plan (269 Views)
Reply
Valued Contributor
Avinash01
Posts: 151
Registered: ‎01-14-2014
Message 1 of 9 (269 Views)

get count of charecters from Description field in Test Plan

Hi ,

 

Is there any way to get the count of charecters from the description field from Test plan ?

 

Thanks,

Avi.

Please use plain text.
Valued Contributor
Avinash01
Posts: 151
Registered: ‎01-14-2014
Message 2 of 9 (258 Views)

Re: get count of charecters from Description field in Test Plan

Or Can I get count (number) of design steps in a test case and assign the value to user field ?

 

Thanks,

Avi.

Please use plain text.
Esteemed Contributor
William Schmitt
Posts: 337
Registered: ‎04-02-2008
Message 3 of 9 (254 Views)

Re: get count of charecters from Description field in Test Plan

[ Edited ]

For the first question - since Description is a memo field and is stored in the database as HTML, you have to convert to plain text and then you just get the length of the Description field for the test:

 

Set tfact = td.TestFactory
Set tlist = tfact.NewList("")
td.IgnoreHtmlFormat = True
For Each mytest In tlist
    MsgBox mytest.Field("TS_DESCRIPTION")
    MsgBox Len(mytest.Field("TS_DESCRIPTION"))
Next

 

 Of course, the Len function will count spaces as well, so if you want just characters, you will need to find them in the string and subtract them from the count.

Please use plain text.
Esteemed Contributor
William Schmitt
Posts: 337
Registered: ‎04-02-2008
Message 4 of 9 (250 Views)

Re: get count of charecters from Description field in Test Plan

For the second question:

 

For Each mytest In tlist
    Set stepfact = mytest.DesignStepFactory
    Set StepList = stepfact.NewList("")
    mytest.Field("TS_USER_01") = StepList.Count
Next

Please use plain text.
Valued Contributor
Avinash01
Posts: 151
Registered: ‎01-14-2014
Message 5 of 9 (243 Views)

Re: get count of charecters from Description field in Test Plan

Hi William ,

 

Thanks for the help.

 

I am using the below function for this and it working fine ../As it is taking a bit time for exce I posted the query

 

Function SetStepCount (TestID)

On Error Resume Next

 

Set StepCommand = TDConnection.Command

StepCommand.CommandText = "Select count(*) from DESSTEPS where  DESSTEPS.DS_TEST_ID =" & TestID

Set StepCountSet = StepCommand.Execute()

 

Test_Fields.Field("TS_USER_20").IsReadOnly = False

Test_Fields.Field("TS_USER_20").Value = StepCountSet.fieldvalue(0)

Test_Fields.Field("TS_USER_20").IsReadOnly = True

 

On Error GoTo 0

End Function

 

I will implement your solution and will update you

 

Thanks

Avi.

Please use plain text.
Valued Contributor
Avinash01
Posts: 151
Registered: ‎01-14-2014
Message 6 of 9 (201 Views)

Re: get count of charecters from Description field in Test Plan

Hi William ,

 

Its not working for me with the design factory. below is the code

 

Sub DesignDesCount

  On Error Resume Next

   

    Set DFact=TFact.DesignStepFactory
  Set TList=DFact.NewList("")
  msgbox TList.Count-------------------------its getting count as Zero

 

 

 

For Each test In TList

 

    set stepcount=Len(test.Fields.Field("DS_DESCRIPTION"))

   

Next

 

   'DesignStep_Fields.Field("DS_USER_01").IsReadOnly=False
   'DesignStep_Fields.Field("DS_USER_01").Value=stepcount.fieldvalue()

 

 On Error GoTo 0
End Sub

 

 

any help ..

 

Thanks,

Avi.

Please use plain text.
Esteemed Contributor
William Schmitt
Posts: 337
Registered: ‎04-02-2008
Message 7 of 9 (194 Views)

Re: get count of charecters from Description field in Test Plan

You're getting your objects and factories mixed up.  Look at my code snippets again.  The object hierarchy goes like this, with each object accessed through the NewList method of the respective Factory.

TD

TestFactory

Test

DesignStepFactory

DesignStep

 

 

Of course you need to create the TD object first.  I don't see you doing that.  And stepcount is not an object - you don't set it.

Please use plain text.
Valued Contributor
Avinash01
Posts: 151
Registered: ‎01-14-2014
Message 8 of 9 (176 Views)

Re: get count of charecters from Description field in Test Plan

Hi William ,

 

Thanks for the reply. Here is my latest code.

 

But the only issue was I cannot able to assign a value from Setcpount to user description field.

 

Sub DesignDesCount

 

  On Error Resume Next

 

  Set TestFact=TDConnection.TestFactory

  Set TList=TestFact.NewList("")

 

  TDConnection.IgnoreHtmlFormat = True

 

For Each Test In TList

 

set DesignFact=Test.DesignStepFactory

 

Set DesignStepList=DesignFact.NewList("")

 

'MsgBox DesignStepList.Count

 

For Each DesignStep In DesignStepList

 

Set stepcount=Len(DesignStep.Field("DS_DESCRIPTION"))

 

 

      DesignStep_Fields.Field("DS_USER_01").Value=stepcount.Value' stepcount.Get Value()----------------------------------------------Error

 

Next

 

Next

 

MsgBox "Done"

 

On Error GoTo 0

End Sub

 

Any suggestions...

 

Thanks,

Avi.

Please use plain text.
Esteemed Contributor
William Schmitt
Posts: 337
Registered: ‎04-02-2008
Message 9 of 9 (165 Views)

Re: get count of charecters from Description field in Test Plan

See my previous post.  StepCount is not an object, it's a variable - you don't "set" it.

 

stepcount=Len(DesignStep.Field("DS_DESCRIPTION"))

DesignStep_Fields.Field("DS_USER_01").Value=stepcount

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation