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

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

1 Answer 27 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
JC
Top achievements
Rank 1
JC asked on 21 Dec 2018, 03:40 PM

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 

1 Answer, 1 is accepted

Sort by
0
Nikolai
Telerik team
answered on 26 Dec 2018, 07:23 AM
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!
Tags
General Discussions
Asked by
JC
Top achievements
Rank 1
Answers by
Nikolai
Telerik team
Share this question
or