Getting below error while calling custom keyword function from one test cases. Previously it was working before new katalon update

Reason:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java_util_List$get$1.call(Unknown Source)
at RB_FetchValues.fetchVariablevaluesFromReport(RB_FetchValues.groovy:72)
at RB_FetchValues.invokeMethod(RB_FetchValues.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at To get all added column values from report.run(To get all added column values from report:33)
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:337)

Can we see the code for this custom keyword please

1 Like

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.annotation.Keyword
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.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 org.openqa.selenium.WebElement as WebElement
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.By as By
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory as MobileDriverFactory
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.testobject.RequestObject as RequestObject
import com.kms.katalon.core.testobject.ResponseObject as ResponseObject
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.testobject.TestObjectProperty as TestObjectProperty
import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper as MobileElementCommonHelper
import com.kms.katalon.core.util.KeywordUtil as KeywordUtil
import com.kms.katalon.core.webui.exception.WebElementNotFoundException as WebElementNotFoundException
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor
import internal.GlobalVariable as GlobalVariable

public class RB_FetchValues
{

String StoreName = GlobalVariable.PCName
String DataGrain = GlobalVariable.DataGrain
String PresentBy = GlobalVariable.PresentBy


def ValuesFromReport = [:]

int index;

int NewIndex;

@Keyword
def fetchVariablevaluesFromReport()

{




	println 'intofunctions'
	
	WebDriver driver = DriverFactory.getWebDriver()
	






	WebElement HeaderRow = driver.findElement(By.xpath("(//thead[@class='ui-table-thead'])[2]"))



	List<WebElement> HeadersRowTotal = HeaderRow.findElements(By.tagName('tr'))

	List<WebElement> Headers = HeadersRowTotal.get(1).findElements(By.tagName('th'))

	println(Headers.size())


	WebElement Tabel = driver.findElement(By.xpath("(//tbody[@class='ui-table-tbody'])[2]"))

	List<WebElement> Rows = Tabel.findElements(By.tagName('tr'))

	/for (int j = 0; j < Rows.size(); j++) {

		WebElement VariableRow = Rows.get(j)

		List<WebElement> cells = VariableRow.findElements(By.tagName('td'))

		String Variablename = cells.get(0).getText()

		if (Variablename.trim().length() > 8) {
			String gotStorename = Variablename.substring(11, Variablename.length()).trim()

			println(gotStorename)

			if (gotStorename.equalsIgnoreCase(StoreName)) {

				NewIndex = j

				println(NewIndex)

				break
			}
		}
	}

	//Fetching variable values from tabel for all variables.
	//Headers.size()
	for (int i = 0; i <Headers.size(); i++) {

		JavascriptExecutor je = ((driver) as JavascriptExecutor)

		WebElement HeaderNameElement = Headers.get(i)

		je.executeScript('arguments[0].scrollIntoView()', HeaderNameElement)

		String HeaderName = HeaderNameElement.getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll('\n', ' ')

		println(HeaderName)




		switch (HeaderName) {


			case 'Net Sales $':


				KeywordUtil.logInfo('FETCHING NET SALES TY VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String NetsalesReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number NetSales = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(NetsalesReport)

				println(NetSales)


				ValuesFromReport.put('Net Sales $', NetSales)


				break


			case 'Net Sales LY $':

				KeywordUtil.logInfo('FETCHING NET SALES LY $ VALUE FROM REPORT FOR FURUTE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String NetsalesLYReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number NetSalesLY = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(NetsalesLYReport)


				println(NetSalesLY)


				ValuesFromReport.put('Net Sales LY $', NetSalesLY)



				break



			case 'Net Sales vs LY $':

				KeywordUtil.logInfo('FETCHING NET SALES VS LY $ VALUE FROM REPORT FOR FURUTE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String Netsales_VS_LYReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')
				Number NetSalesLY_vs_LY = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(Netsales_VS_LYReport)


				println(NetSalesLY_vs_LY)


				ValuesFromReport.put('Net Sales vs LY $', NetSalesLY_vs_LY)


				break






			case 'Net Sales vs LY %':

				KeywordUtil.logInfo('FETCHING NET SALES VS LY % VALUE FROM REPORT FOR FURUTE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String Netsales_VS_LY_Percent_Report = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')


				Number Netsales_VS_LY_Percent = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(Netsales_VS_LY_Percent_Report)


				println(Netsales_VS_LY_Percent)


				ValuesFromReport.put('Net Sales vs LY %', Netsales_VS_LY_Percent)

				break

			case 'Sales Budget $':


				KeywordUtil.logInfo('FETCHING  Sales Budget $  VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String SalesBudgetDollar = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number SalesBudgetDollars =CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(SalesBudgetDollar)

				println(SalesBudgetDollars)


				ValuesFromReport.put('Sales Budget $', SalesBudgetDollars)


				break



			case 'Sales Budget %':


				KeywordUtil.logInfo('FETCHING Sales Budget % VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String NetsalesBudgetPercent = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number NetSalesBudget =CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(NetsalesBudgetPercent)

				println(NetSalesBudget)


				ValuesFromReport.put('Sales Budget %', NetSalesBudget)


				break


			case 'Sales vs Budget $':


				KeywordUtil.logInfo('FETCHING Sales vs Budget $ VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String NetsalesVSBudgetDollar = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number NetSalesVsBudget =CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(NetsalesVSBudgetDollar)

				println(NetSalesVsBudget)


				ValuesFromReport.put('Sales vs Budget $', NetSalesVsBudget)


				break


			case 'Sales vs Budget %':


				KeywordUtil.logInfo('FETCHING Sales vs Budget % VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String NetsalesVSBudgetPercentage = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number NetSalesVsBudgetPercent =CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(NetsalesVSBudgetPercentage)

				println(NetSalesVsBudgetPercent)


				ValuesFromReport.put('Sales vs Budget %', NetSalesVsBudgetPercent)


				break



			case 'Guest Count':

				KeywordUtil.logInfo('FETCHING GUEST COUNT  FROM CALENDAR FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String GuestCountReport1 = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number GuestCountReport =CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(GuestCountReport1)


				println(GuestCountReport)


				ValuesFromReport.put('Guest Count', GuestCountReport)


				break


			case 'Guest LY Count':

				KeywordUtil.logInfo('FETCHING GUEST COUNT LY FROM CALENDAR FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String GuestCountLYReport1 = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number GuestCountLYReport =CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(GuestCountLYReport1)


				println(GuestCountLYReport)


				ValuesFromReport.put('Guest LY Count', GuestCountLYReport)



				break


			case 'Guest vs LY Count':

				KeywordUtil.logInfo('FETCHING GUEST COUNT VS LY COUNT FROM CALENDAR FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String GuestCount_VS_LY_COUNT_Report1 = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number GuestCount_VS_LY_COUNT_Report =CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(GuestCount_VS_LY_COUNT_Report1)

				println(GuestCount_VS_LY_COUNT_Report)


				ValuesFromReport.put('Guest vs LY Count', GuestCount_VS_LY_COUNT_Report)



				break



			case 'Guest vs LY %':

				KeywordUtil.logInfo('FETCHING GUEST COUNT VS LY % COUNT FROM CALENDAR FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String GuestCount_VS_LY_PERCENT_Report = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number GuestCount_VS_LY_PERCENT = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(GuestCount_VS_LY_PERCENT_Report)


				println(GuestCount_VS_LY_PERCENT)


				ValuesFromReport.put('Guest vs LY %', GuestCount_VS_LY_PERCENT)

				break

			case 'Avg Check $':

				KeywordUtil.logInfo('FETCHING AVG CHECK VALUE FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String AvgCheckReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number AvgCheckDollor = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(AvgCheckReport)


				println(AvgCheckDollor)


				ValuesFromReport.put('Avg Check $', AvgCheckDollor)


				break

			case 'Avg Check LY $':

				KeywordUtil.logInfo('FETCHING AVG CHECK VALUE LY FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String AvgCheckLYReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number AvgCheckLY = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(AvgCheckLYReport)


				println(AvgCheckLY)


				ValuesFromReport.put('Avg Check LY $', AvgCheckLY)



				break

			case 'Avg Check vs LY $':

				KeywordUtil.logInfo('FETCHING AvgCheck_VS_LYReport FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String AvgCheck_VS_LYReport = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number AvgCheck_VS_LY = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(AvgCheck_VS_LYReport)


				println(AvgCheck_VS_LY)


				ValuesFromReport.put('Avg Check vs LY $', AvgCheck_VS_LY)
				break

			case 'Avg Check vs LY %':

				KeywordUtil.logInfo('FETCHING AvgCheckvsLY_PERCENT FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String  AvgCheckvsLY_PERCENT  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number AvgCheckvs_LY_PERCENTEGE = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(AvgCheckvsLY_PERCENT)


				println(AvgCheckvs_LY_PERCENTEGE)


				ValuesFromReport.put('Avg Check vs LY %', AvgCheckvs_LY_PERCENTEGE)



				break



			case 'Labor Cost, $':

				KeywordUtil.logInfo('FETCHING Labor Cost, $  FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_$  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_$_Amount = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_$)


				println(LaborCost_$_Amount)


				ValuesFromReport.put('Labor Cost, $', LaborCost_$_Amount)

				break

			case 'Labor Cost, %':

				KeywordUtil.logInfo('FETCHING Labor Cost, %  FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostPercent  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_Percent = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCostPercent)


				println(LaborCost_Percent)


				ValuesFromReport.put('Labor Cost, %', LaborCost_Percent)
				break

			case 'Labor Cost LY, $':

				KeywordUtil.logInfo('FETCHING Labor Cost LY, $  FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostLY$  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_LY$ = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCostLY$)


				println(LaborCost_LY$)


				ValuesFromReport.put('Labor Cost LY, $', LaborCost_LY$)
				break

			case 'Labor Cost LY, %':

				KeywordUtil.logInfo('FETCHING Labor Cost LY, % FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostLYPercent  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCostLY_Percent = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCostLYPercent)


				println(LaborCostLY_Percent)


				ValuesFromReport.put('Labor Cost LY, %', LaborCostLY_Percent)

				break

			case 'Labor Cost vs LY, $':

				KeywordUtil.logInfo('FETCHING Labor Cost vs LY, $ FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_LY_$  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VS_LY = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_VS_LY_$)


				println(LaborCost_VS_LY)


				ValuesFromReport.put('Labor Cost vs LY, $', LaborCost_VS_LY)
				break

			case 'Labor Cost vs LY, p.p.':

				KeywordUtil.logInfo('FETCHING Labor Cost vs LY, p.p. FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_LY_PP1  = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VS_LY_PP = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCost_VS_LY_PP1)


				println(LaborCost_VS_LY_PP)


				ValuesFromReport.put('Labor Cost vs LY, p.p.', LaborCost_VS_LY_PP)

				break

			case 'Labor Cost LW, $':

				KeywordUtil.logInfo('FETCHING Labor Cost LW, $ FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_LW_$ = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_LW_$_Report = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_LW_$)


				println(LaborCost_LW_$_Report)


				ValuesFromReport.put('Labor Cost LW, $', LaborCost_LW_$_Report)
				break

			case 'Labor Cost LW, %':


				KeywordUtil.logInfo('FETCHING Labor Cost LW, % FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_LW_Percent = cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_LW = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCost_LW_Percent)


				println(LaborCost_LW)


				ValuesFromReport.put('Labor Cost LW, %', LaborCost_LW)

				break

			case 'Labor Cost vs LW, $':

				KeywordUtil.logInfo('FETCHING Labor Cost vs LW, $ FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_LW_$= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VS_LW_$_report = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_VS_LW_$)


				println(LaborCost_VS_LW_$_report)


				ValuesFromReport.put('Labor Cost vs LW, $', LaborCost_VS_LW_$_report)
				break

			case 'Labor Cost vs LW, p.p.':

				KeywordUtil.logInfo('FETCHING Labor Cost vs LW, p.p. FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_LW_PP1= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VS_LW_PP = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCost_VS_LW_PP1)


				println(LaborCost_VS_LW_PP)


				ValuesFromReport.put('Labor Cost vs LW, p.p.', LaborCost_VS_LW_PP)



				break


			case 'Labor Cost Budget, %':


				KeywordUtil.logInfo('FETCHING Labor Cost Budget, % FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostBudgetPercent= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCostBudgetPercentage = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCostBudgetPercent)


				println(LaborCostBudgetPercentage)


				ValuesFromReport.put('Labor Cost Budget, %', LaborCostBudgetPercentage)


				break

			case 'Labor Cost Budget, $ (actual sales)':


				KeywordUtil.logInfo('FETCHING LaborCostBudget_$_ActualSales FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostBudget_$_ActualSales= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCostBudget$_ActualSales = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCostBudget_$_ActualSales)


				println(LaborCostBudget$_ActualSales)


				ValuesFromReport.put('Labor Cost Budget, $ (actual sales)', LaborCostBudget$_ActualSales)


				break

			case 'Labor Cost Budget, $ (budgeted sales)':


				KeywordUtil.logInfo('FETCHING  Labor Cost Budget, $ (budgeted sales) FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCostBudget_$_BudgetedSales= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCostBudget$_BudgetedSales = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCostBudget_$_BudgetedSales)


				println(LaborCostBudget$_BudgetedSales)


				ValuesFromReport.put('Labor Cost Budget, $ (budgeted sales)', LaborCostBudget$_BudgetedSales)



				break


			case 'Labor Cost vs Budget, p.p.':


				KeywordUtil.logInfo('FETCHING  Labor Cost vs Budget, p.p. FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_Budget_PP1= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VS_Budget_PP = CustomKeywords.'reportbuildercustom.RB_Keywords.setNumberFormat'(LaborCost_VS_Budget_PP1)


				println(LaborCost_VS_Budget_PP)


				ValuesFromReport.put('Labor Cost vs Budget, p.p.', LaborCost_VS_Budget_PP)



				break

			case 'Labor Cost vs Budget, $ (actual sales)':


				KeywordUtil.logInfo('FETCHING  Labor Cost vs Budget, $ (actual sales)  FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_Budget_$_ActualSales= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VSBudget$_ActualSales = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_VS_Budget_$_ActualSales)


				println(LaborCost_VSBudget$_ActualSales)


				ValuesFromReport.put('Labor Cost vs Budget, $ (actual sales', LaborCost_VSBudget$_ActualSales)



				break

			case 'Labor Cost vs Budget, $ (budgeted sales)':


				KeywordUtil.logInfo('FETCHING  Labor Cost vs Budget, $ (actual sales)  FROM REPORT FOR FUTURE CALCULATION')

				index = i

				WebElement Tabel2 = driver.findElement(By.xpath('(//tbody[@class="ui-table-tbody"])[4]'))

				List<WebElement> Rows2 = Tabel2.findElements(By.tagName('tr'))

				WebElement RequiredRow = Rows2.get(NewIndex)

				List<WebElement> cellsNew = RequiredRow.findElements(By.tagName('td'))

				String LaborCost_VS_Budget_$_BudgetedSales= cellsNew.get(index).getText().replaceAll('\r\n', ' ').replaceAll('\r', ' ').replaceAll(
						'\n', ' ')

				Number LaborCost_VSBudget_$_BudgetedSales = CustomKeywords.'reportbuildercustom.RB_Keywords.removeCurrencyFormat'(LaborCost_VS_Budget_$_BudgetedSales)


				println(LaborCost_VSBudget_$_BudgetedSales)


				ValuesFromReport.put('Labor Cost vs Budget, $ (budgeted sales)', LaborCost_VSBudget_$_BudgetedSales)



				break

			default:


				break


		}


	}




	println ValuesFromReport


	return ValuesFromReport


}

}

Somewhere you are trying to access the second value of the array when the size of the array is 1 which is what is causing this exception, so you should be accessing the “1st” value of the array. I currently don’t have time to fully analyse your code, hopefully someone with good eyes can have a look.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.