Forum Discussion

sonya_m's avatar
sonya_m
SmartBear Alumni (Retired)
4 years ago
Solved

[TechCorner Challenge #14] Filtering data retrieved from a DataSource

Hi ReadyAPI Community!   Weโ€™ve prepared an interesting task for you to solve today! Check out the participation rules and the TechCorner Leaderboard here.   Imagine that you are working with ...
  • HimanshuTayal's avatar
    HimanshuTayal
    4 years ago

    Task: Create a script that will filter data retrieved from a DataSource

     

    This is a solution created for [TechCorner Challenge #14]

     

    sonya_m :

     

    So, i have updated the script in order to meet the criteria, please give it a try:

     

     

    def Participant_Location = context.expand( '${DataSource#Participant_Location}' )
    
    if(Participant_Location.toLowerCase() == "boston"){
    	testRunner.testCase.getTestStepByName("Register User").run(testRunner, context);
    	testRunner.testCase.getTestStepByName("Buy a Ticket").run(testRunner, context);
    }
    else{
    //	Disabling them in order them not to run
    	testRunner.testCase.getTestStepByName("Register User").setDisabled(true)
    	testRunner.testCase.getTestStepByName("Buy a Ticket").setDisabled(true)
    }