This is a migrated thread and some comments may be shown as answers.

Use of Variables throughout the test

3 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nithya
Top achievements
Rank 1
Veteran
Nithya asked on 27 Sep 2017, 02:22 PM

Hi , 

I have 2 functions or methods  in the test. In function1, I have a variable called x which stores the inner text of particular span in my webpage. Now I need the value of the variable to be used in my Function 2. I dont want to use the extract step . I want to find the element using find expression in function1 and use the value in function2 .

Eg : 

Public sub function1()

Span = Pages. xxxx.xxxx

Dim X as string = Span. innertext ()

End Sub

--------------------------------------------------------

Public Sub function2 ()

Messagebox.Show("Document id is :" &Docid)

End Sub

 

Could anyone help me to do this ? Thanks in Advance!!

 

3 Answers, 1 is accepted

Sort by
0
Nikolay Petrov
Telerik team
answered on 29 Sep 2017, 06:06 AM
Hello Nithya,

To have a common variable you have to create a stand alone class file and to place there a public static property there. It would be accessible in all tests in the project. Here is an example of using such class.

I hope this clarification helps.

Best Regards,
Nikolay Petrov
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Nithya
Top achievements
Rank 1
Veteran
answered on 03 Oct 2017, 01:53 PM

Hi Nikolay,

yeah.. I have gone through this and have created utility class.. But I am not sure how to access those varaiables.. I can explain with some details..

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have  declared  "test" as string in the utility class. So that , I can access the variable test all throughout the Project..

My Scenario :

I have a test with function storing the inner text of the value in the variable..I need the inner text to be stored in "test". So that I can use the same function multiple times.. And expecting the "test"  should change values based on runtime.

 

<CodedStep("New Coded Step")> _
        Public Sub Example()
        
             ActiveBrowser.ContentWindow.SetFocus
            Dim expr As New HtmlFindExpression("tagname=span","class=docid")         
            Dim span As HtmlSpan =Pages.xxx.FrameFrameContent.Find.ByExpression(Of htmlspan)(expr)
            span.Focus()
         Utility.Test=span.InnerText      --------------------------- > I just give like this , to store the innertext value to "test" .. But it says test is not declared...
         Messagebox.Show("Document id is :" &Test)
                    
        End Sub

 

Could you please help me to fix this.. Thanks in advance!!

 

Regards,

Nithya A.

0
Nikolay Petrov
Telerik team
answered on 06 Oct 2017, 08:09 AM
Hello Nithya,

If follow the provided example in the documentation you could be able to reach the static property of the class in your coded step.

Please provide the project to investigate further.

Kind Regards,
Nikolay Petrov
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Nithya
Top achievements
Rank 1
Veteran
Answers by
Nikolay Petrov
Telerik team
Nithya
Top achievements
Rank 1
Veteran
Share this question
or