Element selection in list

I have one dynamic list which shows 4 element per swipe I want to iterate through all elements in list one by one and check some condition if it matches then further action will be done if it doesn’t match go back and select next element problem I am facing is the list gets started from very first element every time. if I swipe to 5th element I want to iterate the list from there but the list get refreshed and first element gets visible.
How to handle this kind of situation

How about reading your “seed” number from an Excel or CSV file?
Then perhaps a “for” loop.

for (int refNum = seed; refNum < seed + dynamicList.size(); refNum++) {

Then either create a staged “if” listing or Case Block:

    if (Mobile.verify...) { dynamicList[refNum] ... }
    if (Mobile.verify...) { dynamicList[refNum] ... }
    if (Mobile.verify...) { dynamicList[refNum] ... }
    if (Mobile.verify...) { dynamicList[refNum] ... }


    switch (refNum) {
       case 0:   (or maybe case 0 + seed:)
       case 1:
       case 2:
       case 3:

I can’t read from excel sheet because data on which I have to perform above action is coming from server

I might not fully understand the concern you have with the “seed” reference, but you can do a quick read of a sheet to get the starting number and still get your information from the server. Is the concern matching of the “seed” to starting number?

Maybe like:

Create an Excel spreadsheet named, TestId.xlsx, and put a reference number in cell A2, such as 5, on the first sheet (I have it as Sheet1). Save the spreadsheet into the Katalon Studio/Data folder. Adjust the file pathway that I have to match your own. Do not leave the spreadsheet open when you run your test case as that will lock the file so Katalon cannot read it and your test case will fail. Also, the code I have gets a String as my reference and then I do what I want with it, such as convert to an Integer, using Integer.parseInt(GlobalVariable.gReferenceNumber), or display it in a textbox as is.

I also use Global Variables for my TCs, but you don’t have to if you test only uses one Test Case.

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

GlobalVariable.gTestIdPathWay = "G:\\Katalon Test Cases\\Data Files\\TestId.xlsx"

FileInputStream fis = new FileInputStream (GlobalVariable.gTestIdPathWay);
XSSFWorkbook workbook = new XSSFWorkbook (fis);

XSSFSheet sheet = workbook.getSheet("Sheet1");
// cell A2
Row row = sheet.getRow(1);
Cell cell = row.getCell(0);
GlobalVariable.gReferenceNumber = cell.getStringCellValue();