Repeat a test with differents values from a dropdown menu

Hi,

I’m asking help, i’m not familiar with Katalon or other automation tool and I’m a super beginner in code.

So here is the explanation.

I have to test a survey which depending on the answer you put will give you a certain type of result.

For that i’m testing the survey step by step.

My first step is to select automatically the different answers from a dropdown menu by doing a loop.

For example
Question 1 : Which model do you have ?

Answers (list of models):
Choice 1
Choice 2
Choice 3

So I would like the tool to first pick the Choice 1 then start again using a loop but this time make it choose the Choice 2, etc.

Is there a way to make the tool pick a different answer after each loop without creating too much lines in the script ? Like using variables ?

Thanks for helping

Yes, there is a way, always.

You want to make 2 test cases: ‘Test Cases/survey’ and ‘Test Cases/doSurveys’. One calls another

survey

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIWebUI.comment("Q1=${Q1},Q2=${Q2},Q3=${Q3}")

doSuvrveys

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIWebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':1, 'Q3':1])WebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':1, 'Q3':2])WebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':1, 'Q3':3])WebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':2, 'Q3':1])WebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':2, 'Q3':2])WebUI.callTestCase(findTestCase('survey'), ['Q1':1, 'Q2':2, 'Q3':3])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':1, 'Q3':1])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':1, 'Q3':2])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':1, 'Q3':3])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':2, 'Q3':1])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':2, 'Q3':2])WebUI.callTestCase(findTestCase('survey'), ['Q1':2, 'Q2':2, 'Q3':3])

Select and run the doSurveys.
You will see following output as in the log view:

スクリーンショット 2018-11-23 7.39.56.png

Thanks for your help, I understood what you meant but I think I forget to mention that the survey is running on a website, so I need to test the survey by opening the website.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpointimport static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport static com.kms.katalon.core.testdata.TestDataFactory.findTestDataimport static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport com.kms.katalon.core.checkpoint.Checkpoint as Checkpointimport com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKWimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobileimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.testcase.TestCase as TestCaseimport com.kms.katalon.core.testdata.TestData as TestDataimport com.kms.katalon.core.testobject.TestObject as TestObjectimport com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIimport internal.GlobalVariable as GlobalVariableimport org.openqa.selenium.Keys as KeysWebUI.openBrowser('')WebUI.navigateToUrl('mysurveyurl.com')WebUI.click(findTestObject('Start survey'))WebUI.click(findTestObject('dropdownmenu'))WebUI.click(findTestObject('Model type1'))

Here is the code I started to do. Once I start the survey, Katalon is clicking on Start survey and then it opens the dropdown menu from the first question and it picks the Model type1, then I would like it to do a loop to repeat this task but only from the

WebUI.click(findTestObject('dropdownmenu'))

and then choose the Model type2. To summary I want it to go back to the dropdownmenu and to pick the second value.

I know that I can do it by just repeating the task while recording but my goal here is to avoid that (can’t I put all the model types in a list and then make Katalon repeat this list starting with the first model then the second, etc ?

I dont know if I’m clear, so if it’s not clear at all tell me

Hi,

I still didn’t figure out the problem :confused:

Antoine,

The following code would not work.

WebUI.navigateToUrl('mysurveyurl.com')

navigateToUrl() method requires a string as a valid URL which starts with ‘http://’ or ‘https://’; so the line should be something like

WebUI.navigateToUrl('http://mysurveyurl.com')

----

The following line would not work as well

WebUI.click(findTestObject('Start survey'))

findTestObject() method requires a string as a valid Test Object name, with starts with ‘Object Repository/’ usually; so the line should be something like

WebUI.click(findTestObject('Object Repository/Start survey'))

----

I do not how much you are experienced with Katalon Studio. If you have none yet, I would like to suggest to go through some tutorial document and grasp a working sample project in your hand.