Katalon writing data to excel

You say you have already put the earlier code block into your test case yet this error message above says you didn’t. As I said in my previous post, If you did change it, then maybe shut down KS, restart it and try again.

@grylion54
I tried to use this code again…but still errors occured.

2022-01-31 15:23:17.405 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 44: The current scope already contains a variable of the name row
 @ line 44, column 6.
   	Row row = sheet.createRow(newRow );
        ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 44: unable to resolve class Row 
 @ line 44, column 6.
   	Row row = sheet.createRow(newRow );
        ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 88: unable to resolve class XSSFWorkbook 
 @ line 88, column 15.
   	XSSFWorkbook workbook = new XSSFWorkbook (fis);
                 ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 88: unable to resolve class XSSFWorkbook 
 @ line 88, column 26.
   	XSSFWorkbook workbook = new XSSFWorkbook (fis);
                            ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 90: unable to resolve class Row 
 @ line 90, column 6.
   	Row excelRow = sheet.createRow(newRow );
        ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 91: unable to resolve class Cell 
 @ line 91, column 7.
   	Cell cell = excelRow.createCell(0);
         ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 93: unable to resolve class XSSFSheet 
 @ line 93, column 12.
   	XSSFSheet sheet = workbook.getSheet("Sheet1");
              ^

7 errors

	at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643610192601.run(TempTestCase1643610192601.groovy:25)

2022-01-31 15:23:17.432 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Upload2```

After you identify a variable (give a variable a data type), you cannot do it a second time. Leave the first identifications alone, but remove the variable’s second identification (setting the data type), like below:

    row = sheet.createRow(newRow );
    workbook = new XSSFWorkbook (fis);

    excelRow = sheet.createRow(newRow );

    cell = excelRow.createCell(0);
    sheet = workbook.getSheet("Sheet1");

AS you mentioned, I removed the variable’s second identification.

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

int newRow = 1
gTestIdPathWay =  "C:\\Users\\hojun.lee\\Katalon Studio\\excel.xlsx"

for (def row = 1; row <= findTestData('New').getRowNumbers(); row++) {
	
	Row row = sheet.createRow(newRow );
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
			'a', row))

	WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
			'c', row))

	WebUI.waitForAlert(5)

	WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
			'd', row))

	WebUI.waitForAlert(5)

	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

	WebUI.waitForPageLoad(60)

/*①From now new page will be open*/

	WebUI.switchToWindowIndex(1) //switches to 2nd window
	secondUrl = WebUI.getUrl()
	println("secondUrl: " + secondUrl)

	
	WebUI.waitForAlert(5)
	
	row = sheet.createRow(newRow );
	workbook = new XSSFWorkbook (fis);

	excelRow = sheet.createRow(newRow );

	cell = excelRow.createCell(0);
	sheet = workbook.getSheet("Sheet1");
	
	cell.setCellValue(GlobalVariable.url);

	newRow += 3

	FileOutputStream fos = new FileOutputStream(gTestIdPathWay);
	workbook.write(fos);
	fos.close();
	fis.close();
	/*Turn to the First page, then loop ①~③ process */
}

but error occured continuesly

2022-02-01 09:25:35.230 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2022-02-01 09:25:35.234 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/Upload2
2022-02-01 09:25:36.132 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 44: The current scope already contains a variable of the name row
 @ line 44, column 6.
   	Row row = sheet.createRow(newRow );
        ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 44: unable to resolve class Row 
 @ line 44, column 6.
   	Row row = sheet.createRow(newRow );
        ^

file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/Upload2/Script1643589384559.groovy: 69: unable to resolve class XSSFWorkbook 
 @ line 69, column 13.
   	workbook = new XSSFWorkbook (fis);
               ^

3 errors

	at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643675131330.run(TempTestCase1643675131330.groovy:25)

2022-02-01 09:25:36.157 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Upload2

Is there no problem with the order of development of my code?
@grylion54

@hojun.lee Maybe you have more than the one version of code that you are trying to run because the errors don’t seem to be based on the code you are showing.

Maybe like
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;
"and any others you may need"

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

int newRow = 1
gTestIdPathWay =  "C:\\Users\\hojun.lee\\Katalon Studio\\excel.xlsx"

for (def row = 1; row <= findTestData('New').getRowNumbers(); row++) {
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
			'a', row))

	WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
			'c', row))

	WebUI.waitForAlert(5)

	WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
			'd', row))

	WebUI.waitForAlert(5)

	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

	WebUI.waitForPageLoad(60)

/*①From now new page will be open*/

	WebUI.switchToWindowIndex(1) //switches to 2nd window
	secondUrl = WebUI.getUrl()
	println("secondUrl: " + secondUrl)

	WebUI.waitForAlert(5)

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

    XSSFSheet sheet = workbook.getSheet("Sheet1");
	
	Row excelRow = sheet.createRow(newRow );
	Cell cell = excelRow.createCell(0);
	cell.setCellValue(secondUrl);

	FileOutputStream fos = new FileOutputStream(gTestIdPathWay);
	workbook.write(fos);
	fos.close();
	fis.close();

	newRow += 3
	/*Turn to the First page, then loop ①~③ process */
}

@grylion54
An error occurred while proceeding until the middle.

2022-02-01 09:45:22.222 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2022-02-01 09:45:22.228 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/Upload2
2022-02-01 09:45:23.270 DEBUG testcase.Upload2                         - 1: openBrowser("")
2022-02-01 09:45:23.689 INFO  c.k.k.core.webui.driver.DriverFactory    - Starting 'Chrome' driver
2 01, 2022 9:45:23 午前 org.openqa.selenium.remote.DesiredCapabilities chrome
情報: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
2022-02-01 09:45:23.760 INFO  c.k.k.core.webui.driver.DriverFactory    - Action delay is set to 0 milliseconds
Starting ChromeDriver 97.0.4692.36 (747e0a0f19c13ca6ee136200f5b097448ae4892f-refs/branch-heads/4692@{#607}) on port 38714
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
2 01, 2022 9:45:26 午前 org.openqa.selenium.remote.ProtocolHandshake createSession
情報: Detected dialect: W3C
2022-02-01 09:45:26.778 INFO  c.k.k.core.webui.driver.DriverFactory    - sessionId = f0b66230dbe17330b35318183292aa1a
2022-02-01 09:45:26.801 INFO  c.k.k.core.webui.driver.DriverFactory    - browser = Chrome 97.0.4692.99
2022-02-01 09:45:26.801 INFO  c.k.k.core.webui.driver.DriverFactory    - platform = Windows 10
2022-02-01 09:45:26.802 INFO  c.k.k.core.webui.driver.DriverFactory    - seleniumVersion = 3.141.59
2022-02-01 09:45:26.803 INFO  c.k.k.core.webui.driver.DriverFactory    - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2022-02-01 09:45:26.833 DEBUG testcase.Upload2                         - 2: navigateToUrl("https://kusa89.jp/ss/index_comb_ss.html")
2022-02-01 09:45:27.199 DEBUG testcase.Upload2                         - 3: setText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcu"), "hojun.lee")
2022-02-01 09:45:40.276 DEBUG testcase.Upload2                         - 4: setEncryptedText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcp"), "90Dp6xqc0oO/YegCFWVM4w==")
2022-02-01 09:45:40.961 DEBUG testcase.Upload2                         - 5: sendKeys(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcp"), Keys.chord(ENTER))
2022-02-01 09:45:41.694 DEBUG testcase.Upload2                         - 6: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_KICS"))
2022-02-01 09:45:42.456 DEBUG testcase.Upload2                         - 7: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_"))
2022-02-01 09:45:43.236 DEBUG testcase.Upload2                         - 8: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2"))
2022-02-01 09:45:43.941 DEBUG testcase.Upload2                         - 9: newRow = 1
2022-02-01 09:45:43.943 DEBUG testcase.Upload2                         - 10: gTestIdPathWay = "C:\Users\hojun.lee\Katalon Studio\excel.xlsx"
2022-02-01 09:45:43.945 DEBUG testcase.Upload2                         - 11: for ([row = 1, row <= findTestData("New").getRowNumbers(), (row++)])
2022-02-01 09:45:44.921 DEBUG testcase.Upload2                         - 1: click(findTestObject("Page_SSCSVNumatcheck/input_SS_SSnum"))
2022-02-01 09:45:45.368 DEBUG testcase.Upload2                         - 2: setText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum"), findTestData("NEW").getValue("a", row))
2022-02-01 09:45:46.328 DEBUG testcase.Upload2                         - 3: uploadFile(findTestObject("Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS"), findTestData("NEW").getValue("c", row))
2022-02-01 09:45:46.867 DEBUG testcase.Upload2                         - 4: waitForAlert(5)
2022-02-01 09:45:52.050 WARN  c.k.k.c.w.k.builtin.WaitForAlertKeyword  - No alert found after 5 second(s).
2022-02-01 09:45:52.052 DEBUG testcase.Upload2                         - 5: uploadFile(findTestObject("uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP"), findTestData("NEW").getValue("d", row))
2022-02-01 09:45:52.577 DEBUG testcase.Upload2                         - 6: waitForAlert(5)
2022-02-01 09:45:57.711 WARN  c.k.k.c.w.k.builtin.WaitForAlertKeyword  - No alert found after 5 second(s).
2022-02-01 09:45:57.712 DEBUG testcase.Upload2                         - 7: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/input_SS_button"))
2022-02-01 09:45:58.183 DEBUG testcase.Upload2                         - 8: waitForPageLoad(60)
2022-02-01 09:45:58.413 DEBUG testcase.Upload2                         - 9: switchToWindowIndex(1)
2022-02-01 09:45:58.470 DEBUG testcase.Upload2                         - 10: secondUrl = getUrl()
2022-02-01 09:46:29.901 DEBUG testcase.Upload2                         - 11: println("secondUrl: " + secondUrl)
secondUrl: https://kusa89.jp/ss/planfile/5101468.html
2022-02-01 09:46:29.907 DEBUG testcase.Upload2                         - 12: waitForAlert(5)
2022-02-01 09:46:35.038 WARN  c.k.k.c.w.k.builtin.WaitForAlertKeyword  - No alert found after 5 second(s).
2022-02-01 09:46:35.039 DEBUG testcase.Upload2                         - 13: fis = new java.io.FileInputStream(internal.GlobalVariable.gTestIdPathWay)
2022-02-01 09:46:35.056 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: gTestIdPathWay for class: internal.GlobalVariable
	at Upload2.run(Upload2:77)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643676318363.run(TempTestCase1643676318363.groovy:25)

2022-02-01 09:46:35.063 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: gTestIdPathWay for class: internal.GlobalVariable
	at Upload2.run(Upload2:77)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643676318363.run(TempTestCase1643676318363.groovy:25)

2022-02-01 09:46:35.075 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Upload2

I made some edits to the script I was doing. Can you review that?

1 Like

@grylion54
I revised the code you edited. Finally, It worked. but there is a vacant row in my excel. How can I fix it?

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

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;
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;
"and any others you may need"

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

int newRow = 1
gTestIdPathWay =  "C:\\Users\\hojun.lee\\Katalon Studio\\excel.xlsx"

for (def row = 1; row <= findTestData('New').getRowNumbers(); row++) {
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
			'a', row))

	WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
			'c', row))

	WebUI.waitForAlert(5)

	WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
			'd', row))

	WebUI.waitForAlert(5)

	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

	WebUI.waitForPageLoad(60)

/*①From now new page will be open*/

	WebUI.switchToWindowIndex(1) //switches to 2nd window
	secondUrl = WebUI.getUrl()
	println("secondUrl: " + secondUrl)

	WebUI.waitForAlert(5)

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

	XSSFSheet sheet = workbook.getSheet("Sheet1");
	
	Row excelRow = sheet.createRow(newRow );
	Cell cell = excelRow.createCell(0);
	cell.setCellValue(secondUrl);

	FileOutputStream fos = new FileOutputStream(gTestIdPathWay);
	workbook.write(fos);
	fos.close();
	fis.close();

	newRow += 3
	/*Turn to the First page, then loop ①~③ process */
	WebUI.switchToWindowIndex(0) //switches to 2nd window
	println("secondUrl: " + secondUrl)
	

	WebUI.closeWindowIndex(1)
	WebUI.waitForAlert(5)
}

Find the reference that I show in the quote above and change the newRow value to only increment by 1 instead of 3, so it becomes like one of the choices below:

newRow += 1

or

newRow++

or

newRow = newRow + 1

These all do the same thing which is increment newRow by one.

1 Like

After you make the above change, you should look over your import statements at the top and remove the duplicates and those you don’t need. Or hit CTRL + SHIFT + O (that’s oh, not zero) and KS will do it for you.

1 Like

@grylion54
I am very grateful for your support. To build this web automation, I’ve seen numerous videos related to katalon (youtube), but I’ve actually been helped since I got to know this site.
@kazurayam
I’m sorry if you think I asked ridiculous question.

Btw, there is one more error here.

2022-02-01 15:31:50.785 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2022-02-01 15:31:50.785 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/tasy
2022-02-01 15:31:51.715 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/tasy FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/hojun.lee/Katalon%20Studio/NEW/Scripts/tasy/Script1643158270283.groovy: 49: The current scope already contains a variable of the name row
 @ line 49, column 6.
   	Row row = sheet.createRow(newRow );
        ^

1 error

	at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643697106780.run(TempTestCase1643697106780.groovy:25)

2022-02-01 15:31:51.742 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/tasy

@grylion54
I want to combine this code

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

for (def row=1; row<=findTestData('New').getRowNumbers(); row++) {
		
	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_ID_f_camp_id'), findTestData('NEW').getValue('a', row))
	
	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input'))
	
	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__checkAllButton'))
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input - download'))
	
	WebUI.waitForAlert(5)
	
	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_ID_f_camp_id'), findTestData('NEW').getValue('b', row))
	
	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input'))
	
	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__checkAllButton'))
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input - download'))
	
	'From now, move to Upload Test Cases'
	WebUI.waitForAlert(5)
	}

with

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

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

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

int newRow = 1
gTestIdPathWay =  "C:\\Users\\hojun.lee\\Katalon Studio\\excel.xlsx"

for (def row = 1; row <= findTestData('New').getRowNumbers(); row++) {
	
	Row row = sheet.createRow(newRow );
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
			'a', row))

	WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
			'c', row))

	WebUI.waitForAlert(5)

	WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
			'd', row))

	WebUI.waitForAlert(5)

	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

	WebUI.waitForPageLoad(60)

/*①From now new page will be open*/

	WebUI.switchToWindowIndex(1) //switches to 2nd window
	secondUrl = WebUI.getUrl()
	println("secondUrl: " + secondUrl)

/*② I acquire second page’s url*/

	GlobalVariable.url = WebUI.getUrl()

	WebUI.switchToWindowIndex(0) //switches to 1st window
	firstUrl = WebUI.getUrl()
	println("firstUrl: " + firstUrl)
	
	WebUI.waitForAlert(5)
	
/*③After I acquire second page’s url, Close second page */

	WebUI.closeWindowIndex(1)
	WebUI.waitForAlert(5)

	/* open connection to MS Excel, save surname to sheet 1, cell A2, close connection */
	FileInputStream fis = new FileInputStream (gTestIdPathWay);
	XSSFWorkbook workbook = new XSSFWorkbook (fis);

	XSSFSheet sheet = workbook.getSheet("Sheet1");

    Row excelRow = sheet.createRow(newRow );
    Cell cell = excelRow.createCell(0);
	
	cell.setCellValue(GlobalVariable.url);

	newRow += 3

	FileOutputStream fos = new FileOutputStream(gTestIdPathWay);
	workbook.write(fos);
	fos.close();
	fis.close();
	/*Turn to the First page, then loop ①~③ process */
}


As far as I know, I can press ADD of TEST CASE and add two TEST CASE with CALL TEST. But I can't proceed because of that error.

@grylion54
I did some experiments. A test file with two rows works without any error(Two URLs are included in the Excel.), but when a test file with two or more rows (variables a, c, d) is applied to the code, an error occurs.
This is an error when a test file with three rows is applied to the code.

=============== ROOT CAUSE =====================
Caused by: org.openqa.selenium.InvalidArgumentException: invalid argument: 

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html
================================================

02-01-2022 05:05:28 午後 Test Cases/Upload2

Elapsed time: 1m - 5.545s

Test Cases/Upload2 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to upload file 'C://Users//hojun.lee//Downloads//柴原温泉 手打ちそばの宿 柳屋_【楽天スーパーSALE】5%OFF柳屋のスタンダードプラン!手打ち木の芽そば×秩父の恵みに舌鼓.csv' to object 'Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword.uploadFile(UploadFileKeyword.groovy:87)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword.execute(UploadFileKeyword.groovy:68)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.uploadFile(WebUiBuiltInKeywords.groovy:4031)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$uploadFile$5.call(Unknown Source)
	at Upload2.run(Upload2:59)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643702724977.run(TempTestCase1643702724977.groovy:25)
Caused by: org.openqa.selenium.InvalidArgumentException: invalid argument: 
  (Session info: chrome=97.0.4692.99)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'P82210', ip: '10.83.16.245', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_282'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 97.0.4692.99, chrome: {chromedriverVersion: 97.0.4692.36 (747e0a0f19c13..., userDataDir: C:\Users\hojun.lee\AppData\...}, goog:chromeOptions: {debuggerAddress: localhost:53360}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: acdc17593c6cc471958f62916fcc99a1
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)
	at com.sun.proxy.$Proxy14.sendKeys(Unknown Source)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.sendKeys(EventFiringWebDriver.java:429)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.doCall(UploadFileKeyword.groovy:80)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.call(UploadFileKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 17 more

Is there anything that needs to be modified when applying multiple rows of Test data files to this code?

@hojun.lee

Posts in a Q&A Forum works well to exchange knowledges and ideas each other. But it does not work well on trying to fix coding mistakes. The Forum tends to result in ambiguous questions followed by pointless replies. It is frustrating to repeat copy&past codes and reading insufficiently chomped code fragments.

The questioner and assistants need to share the same code set via Git. Is it possible for you to make a repository on GitHub where you save your Katalon Studio project, and make the repository publicly accessible?

When you ask a new question, put a new tag on the repository, and announce the tag number or the commit id. If you make the repository, others can easily reproduce your problem on their own PC, and can precisely understand what you are asking.

@hojun.lee You are not understanding the principle of not identifying a variable twice. In this case, you are trying to identify a variable as two different data types.

In your for loop, you identify row as an int.

In the next statement, you are trying to identify row as a Row Object.

You cannot do that. That is one of your main errors. In this case, the Row Object has no place being there at all. Delete that line.

image

@grylion54
As you mentioned, I modified
for (def row = 1; row <= findTestData('New').getRowNumbers(); row++)
to
for (def row ; row <= findTestData('New').getRowNumbers(); row++)

like this

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

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;
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;
"and any others you may need"

WebUI.openBrowser('')

'Stick to this page(for Download + Upload)'
WebUI.navigateToUrl('https://kusa89.jp/ss/index_comb_ss.html')

'ID'
WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcu'), 'hojun.lee')

'PASSWORD'
WebUI.setEncryptedText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), '90Dp6xqc0oO/YegCFWVM4w==')

WebUI.sendKeys(findTestObject('Object Repository/Page_SSCSVNumatcheck/input__f_itcp'), Keys.chord(Keys.ENTER))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_KICS'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_'))

WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2'))

int newRow = 1
gTestIdPathWay =  "C:\\Users\\hojun.lee\\Katalon Studio\\excel.xlsx"

for (def row ; row <= findTestData('New').getRowNumbers(); row++) {
	
	WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

	WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
			'a', row))

	WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
			'c', row))

	WebUI.waitForAlert(5)

	WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
			'd', row))

	WebUI.waitForAlert(5)

	WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

	WebUI.waitForPageLoad(60)

/*①From now new page will be open*/

	WebUI.switchToWindowIndex(1) //switches to 2nd window
	secondUrl = WebUI.getUrl()
	println("secondUrl: " + secondUrl)

	WebUI.waitForAlert(5)

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

	XSSFSheet sheet = workbook.getSheet("Sheet1");
	
	Row excelRow = sheet.createRow(newRow );
	Cell cell = excelRow.createCell(0);
	cell.setCellValue(secondUrl);

	FileOutputStream fos = new FileOutputStream(gTestIdPathWay);
	workbook.write(fos);
	fos.close();
	fis.close();

	newRow++
	/*Turn to the First page, then loop ①~③ process */
	
	WebUI.switchToWindowIndex(0) //switches to 2nd window
	println("secondUrl: " + secondUrl)
	

	WebUI.closeWindowIndex(1)
	WebUI.waitForAlert(5)
}

but errors still remaining

2022-02-02 10:57:19.058 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2022-02-02 10:57:19.074 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/Upload2
2022-02-02 10:57:20.032 DEBUG testcase.Upload2                         - 1: openBrowser("")
2022-02-02 10:57:20.435 INFO  c.k.k.core.webui.driver.DriverFactory    - Starting 'Chrome' driver
2 02, 2022 10:57:20 午前 org.openqa.selenium.remote.DesiredCapabilities chrome
情報: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
2022-02-02 10:57:20.503 INFO  c.k.k.core.webui.driver.DriverFactory    - Action delay is set to 0 milliseconds
Starting ChromeDriver 97.0.4692.36 (747e0a0f19c13ca6ee136200f5b097448ae4892f-refs/branch-heads/4692@{#607}) on port 27407
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
2 02, 2022 10:57:23 午前 org.openqa.selenium.remote.ProtocolHandshake createSession
情報: Detected dialect: W3C
2022-02-02 10:57:23.237 INFO  c.k.k.core.webui.driver.DriverFactory    - sessionId = 545fc378f691a68a88250ece590a937b
2022-02-02 10:57:23.259 INFO  c.k.k.core.webui.driver.DriverFactory    - browser = Chrome 97.0.4692.99
2022-02-02 10:57:23.259 INFO  c.k.k.core.webui.driver.DriverFactory    - platform = Windows 10
2022-02-02 10:57:23.260 INFO  c.k.k.core.webui.driver.DriverFactory    - seleniumVersion = 3.141.59
2022-02-02 10:57:23.261 INFO  c.k.k.core.webui.driver.DriverFactory    - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2022-02-02 10:57:23.291 DEBUG testcase.Upload2                         - 2: navigateToUrl("https://kusa89.jp/ss/index_comb_ss.html")
2022-02-02 10:57:23.688 DEBUG testcase.Upload2                         - 3: setText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcu"), "hojun.lee")
2022-02-02 10:57:28.982 DEBUG testcase.Upload2                         - 4: setEncryptedText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcp"), "90Dp6xqc0oO/YegCFWVM4w==")
2022-02-02 10:57:29.594 DEBUG testcase.Upload2                         - 5: sendKeys(findTestObject("Object Repository/Page_SSCSVNumatcheck/input__f_itcp"), Keys.chord(ENTER))
2022-02-02 10:57:30.280 DEBUG testcase.Upload2                         - 6: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_KICS"))
2022-02-02 10:57:31.023 DEBUG testcase.Upload2                         - 7: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_"))
2022-02-02 10:57:31.741 DEBUG testcase.Upload2                         - 8: click(findTestObject("Object Repository/Page_SSCSVNumatcheck/a_PonyoPonyo on KICS V2"))
2022-02-02 10:57:32.516 DEBUG testcase.Upload2                         - 9: newRow = 1
2022-02-02 10:57:32.518 DEBUG testcase.Upload2                         - 10: gTestIdPathWay = "C:\Users\hojun.lee\Katalon Studio\excel.xlsx"
2022-02-02 10:57:32.518 DEBUG testcase.Upload2                         - 11: for ([row = <not implemented yet for class: org.codehaus.groovy.ast.expr.EmptyExpression>, row <= findTestData("New").getRowNumbers(), (row++)])
2022-02-02 10:57:33.419 DEBUG testcase.Upload2                         - 1: click(findTestObject("Page_SSCSVNumatcheck/input_SS_SSnum"))
2022-02-02 10:57:33.928 DEBUG testcase.Upload2                         - 2: setText(findTestObject("Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum"), findTestData("NEW").getValue("a", row))
2022-02-02 10:57:34.181 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: com.kms.katalon.core.testdata.reader.SheetPOI.getValue() is applicable for argument types: (java.lang.String, null) values: [a, null]
Possible solutions: getValue(java.lang.String, int), getValue(int, int), getClass(), getType()
	at Upload2.run(Upload2:56)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643767035528.run(TempTestCase1643767035528.groovy:25)

2022-02-02 10:57:34.200 ERROR c.k.katalon.core.main.TestCaseExecutor   - ❌ Test Cases/Upload2 FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: com.kms.katalon.core.testdata.reader.SheetPOI.getValue() is applicable for argument types: (java.lang.String, null) values: [a, null]
Possible solutions: getValue(java.lang.String, int), getValue(int, int), getClass(), getType()
	at Upload2.run(Upload2:56)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1643767035528.run(TempTestCase1643767035528.groovy:25)

2022-02-02 10:57:34.218 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Upload2

This is correct for the for loop.

Right below your for loop is the line that you must delete.
Row row = sheet.createRow(newRow );

You said you had your test case working. Go back to that instance. After that, see what I have given you about writing to excel. Read up how to make a Keyword of those statements. Then, you might see the logic that you need to have.

@grylion54
All the problems have been solved. Thank you for your kind reply.

@grylion54
Can you erase the questions that I’ve posted from this library? It’s because there are some parts related to work.

Underneath the 3 dots is the garbage can that will delete any parts of this question.

1 Like