I want to import text from Excel and use the text as part of a condition for If-Else decision.

2 posts, 0 answers
  1. JC
    JC avatar
    3 posts
    Member since:
    Aug 2018

    Posted 21 Dec 2018 Link to this post

    I want to import text from Excel and use the text as part of a condition for If-Else decision.  This text is not placed into any web page field.  I just want to grab the text and make a decision based on its content.

    Is there a way to do this?

    For example: 
    If (the imported Excel text = a specific value) then
       Execute TestAsStep1
    else
       Execute TestAsStep2 

  2. Nikolai
    Admin
    Nikolai avatar
    111 posts

    Posted 26 Dec 2018 Link to this post

    Hello JC,

    Test Studio runtime engine is built on top of the .Net framework, you can leverage this and write your own Excel reader. Here is a good article on how to write your code. 

    Alternatively you can use the test's data bind functionality to read the Excel file, please note that this may change the runtime behavior of the test since it will act as a data-driven execution
     1. Add new data source - https://docs.telerik.com/teststudio/features/data-driven-testing/manage-external-data-source
     2. Bind your test - https://docs.telerik.com/teststudio/features/data-driven-testing/bind-test-data-source
     3. How to read the cell value in code-behind step - https://docs.telerik.com/teststudio/advanced-topics/coded-samples/general/attach-data-columns


    No matter which approach you take to read the cell value(s), the code below can be used to trigger a "test as step":

    if(cellValue == "something")
    {
        this.ExecuteTest("CaseA.tstest");
    }
    else
    {
        this.ExecuteTest("CaseB.tstest");
    }


    Regards,
    Nikolai
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top