Is there any means to parametrise a checkbox using data-driven?


#4

you can store it as coma separated values and parse it in script


#5

Andrej Podhajský said:

you can store it as coma separated values and pare it in script

do you have an example?


#6
def dataFromExcell = 'Slovakia,USA,Japan,Korea,Czech republic'def listCountries = dataFromExcell.tokenize(',')for (i in listCountries){	println i}

console:

10-15-2018 03:08:15 PM - [START]  - Start Test Case : Test Cases/__Sandbox/New Test Case10-15-2018 03:08:15 PM - [INFO]   - Evaluating variables for test case10-15-2018 03:08:15 PM - [START]  - Start action : Statement - dataFromExcell = "Slovakia,USA,Japan,Korea,Czech republic"10-15-2018 03:08:15 PM - [END]    - End action : Statement - dataFromExcell = "Slovakia,USA,Japan,Korea,Czech republic"10-15-2018 03:08:15 PM - [START]  - Start action : Statement - listCountries = dataFromExcell.tokenize(",")10-15-2018 03:08:15 PM - [END]    - End action : Statement - listCountries = dataFromExcell.tokenize(",")10-15-2018 03:08:15 PM - [START]  - Start action : Statement - For (def i : listCountries)10-15-2018 03:08:15 PM - [START]  - Start action : Statement - println(i)Slovakia10-15-2018 03:08:15 PM - [END]    - End action : Statement - println(i)10-15-2018 03:08:15 PM - [START]  - Start action : Statement - println(i)USA10-15-2018 03:08:15 PM - [END]    - End action : Statement - println(i)10-15-2018 03:08:15 PM - [START]  - Start action : Statement - println(i)Japan10-15-2018 03:08:15 PM - [END]    - End action : Statement - println(i)10-15-2018 03:08:15 PM - [START]  - Start action : Statement - println(i)Korea10-15-2018 03:08:15 PM - [END]    - End action : Statement - println(i)10-15-2018 03:08:15 PM - [START]  - Start action : Statement - println(i)Czech republic10-15-2018 03:08:15 PM - [END]    - End action : Statement - println(i)10-15-2018 03:08:15 PM - [END]    - End action : Statement - For (def i : listCountries)10-15-2018 03:08:15 PM - [PASSED] - Test Cases/__Sandbox/New Test Case10-15-2018 03:08:15 PM - [END]    - End Test Case : Test Cases/__Sandbox/New Test Case


#7

Hey,
I am new to katalon and automation.
I am working on same thing where I am trying to check membership depend on data from Excel.

In my case there are three membership as below and I would like to pass the value based on Excel data.

Would you be able to share the knowledge and let me know the process?

Thanks

Screen Shot 2018-10-31 at 11.37.27 AM.png


#8

Hello Hiral,
i’m not sure if i get your question… can you please describe what exactly you want achieve and what is problem?


#9

Hello,

I am trying to check the membership checkbox but I want to pass the membership year 1, 2 or 3 from excel.

Basically I am trying to make the check box select data driven but not sure hows the best way I can achieve.

Thanks


#10

similar as i described in my 1st post add column to your data and based on value 1-3 you check correct option:

if(checkData == 1){WebUI.check(TO1)} else if(checkData == 2){WebUI.check(TO2)} else if(checkData == 3){WebUI.check(TO3)}

this is one of many solutions


#11

Thanks a lot,

So I have below if and else statement.
I have created variable as member.
I also have a column name as a member into excel file (screenshot attached) and that’s where I am passing value to select membership.

if(member == 1){
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (1)'))
	} else if(member == 2)
	{
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (2)'))
	} else if(member ==3)
	{
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (3)'))
	}

Screen Shot 2018-11-01 at 4.01.14 PM.png


#12

looks good
don’t forget to make also assert based on value of member on the end of TC


#13

Thanks for prompt response.

I have passed value as member = 2

in console I see as below and it does not take any action and not move to membership 2

1-01-2018 04:56:38 PM - [PASSED] - Delayed 3 second(s)

11-01-2018 04:56:38 PM - [END] - End action : delay

11-01-2018 04:56:38 PM - [START] - Start action : Statement - If (member == 1)

11-01-2018 04:56:38 PM - [END] - End action : Statement - If (member == 1)

11-01-2018 04:56:38 PM - [START] - Start action : delay


#14

are you sure you sending value? is it binded correctly? did you try to print member variable out?


#15

Thanks Andrej,

It sounded like I am not doing it correct way. The code and excel sheet screenshot that I have posted in my previous comment was only thing I am doing.

It looks like excel data has been passing correctly.
I have not tried to print member variable value which I will try.

Thank you for your help


#16

Hiral said:

Thanks Andrej,

It sounded like I am not doing it correct way. The code and excel sheet screenshot that I have posted in my previous comment was only thing I am doing.

It looks like excel data has been passing correctly.
I have not tried to print member variable value which I will try.

Thank you for your help

What type is your variable member?
Is it INT or is it STRING?

Did you try if(member == 1){

Single quotes around 1?
I use it like that (with quotes) and it is working without problems.


#17

Thank you very much,
Changing to INT and sing quote around number worked for me.

Thanks Andrej for your help


#18

Thank you Andrej and crokatalontest for helping out earlier.

I have one more scenario where I am not getting to work if and else.

I am trying to test checkout path where user will be offered Product 1 or Product 2 on the page and user will have to select checkbox to add that product into cart and click next to go to next page.
‘Check if the product 1 is present’

if (WebUI.verifyTextPresent('Join The  membership!', false) == true)
{
'Check the checkbox if the product 1 is present'
	WebUI.check(findTestObject('Object Repository/Plat_Auto/GS_upsell_Add'))
} 
'else Check if the product 2 text is present '
else (WebUI.verifyTextPresent('Add ThisProduct to your order', false) == true)
{	
'Check the checkbox if the product 2 is present'
	WebUI.check(findTestObject('Object Repository/Plat_Auto/TA_upsell_Add'))
}

For above condition, The test run and try to find product 1 and if the product 1 is not present it throw the error but does not go to product 2


#19

you need else if:

if(){
} else if(){
}

#20

Thanks Andrej,
I have tried that but when I run test case it does not seems to jump to else if the 1st condition does not meet.
If the first condition then it Check the checkbox and proceed to next step but if the first condition does not march it throw an error that text is not present


#21

Thanks Andrej,

I was able to get if and else work


#22

Hi Andrej, on this example, how can i make katalon check two options and not only one

if(member == 1){
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (1)'))
	} else if(member == 2)
	{
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (2)'))
	} else if(member ==3)
	{
		WebUI.check(findTestObject('Object Repository/input_Choose your plan_members (3)'))
	}

#23

which ones you want to check?