Use of Variables throughout the test

4 posts, 0 answers
  1. Nithya
    Nithya avatar
    17 posts
    Member since:
    Aug 2016

    Posted 27 Sep Link to this post

    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!!

     

  2. Nikolay Petrov
    Admin
    Nikolay Petrov avatar
    256 posts

    Posted 29 Sep Link to this post

    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!
  3. Nithya
    Nithya avatar
    17 posts
    Member since:
    Aug 2016

    Posted 03 Oct in reply to Nikolay Petrov Link to this post

    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.

  4. Nikolay Petrov
    Admin
    Nikolay Petrov avatar
    256 posts

    Posted 06 Oct Link to this post

    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!
Back to Top