First off, a HUGE thanks for your help on this table. I’m starting to learn a bit more about how this works. I now have the ability to match on a specific row value and then check the values on that row.
I’m trying to apply what I’ve learned so far on this other table, which I originally posted above:
The code I have written based on what you have assisted with is here:
WebDriver driver = DriverFactory.getWebDriver();
WebElement myTable = driver.findElement(By.xpath(‘//mat-table[@role=“grid”]’))
List rows_in_table = myTable.findElements(By.xpath(‘//mat-row[@role=“row”]’))
‘To calculate no of rows In table’
int rows_count = rows_in_table.size()
Loop:
for (int row = 0; row < rows_count; row++) {
‘To locate columns(cells) of that specific row’
List columns_in_row = rows_in_table.get(row).findElements(By.xpath(‘/mat-header-cell[@role=“gridcell”]’))
int column = 0;
String celltext = ‘\s’+columns_in_row.get(column).getText()+‘\s’;
if (celltext == “Patient4, Conductor”) {
WebUI.verifyMatch(columns_in_row.get(0).getText(), ‘Patient4, Conductor’, false)
WebUI.verifyMatch(columns_in_row.get(1).getText(), ‘13/08/2020’, false)
WebUI.verifyMatch(columns_in_row.get(2).getText(), ‘24/08/2020’, false)
WebUI.verifyMatch(columns_in_row.get(3).getText(), ‘26/08/2020 *’, false)
WebUI.verifyMatch(columns_in_row.get(4).getText(), ‘Scheduling Needed’, false)
WebUI.verifyMatch(columns_in_row.get(5).getText(), ‘The Infusion Clinic’, false)
WebUI.verifyMatch(columns_in_row.get(6).getText(), ‘PPMS’, false)
break Loop;
}
column++
}
I’m really not sure that I have the xpath correct, but the code seems to be dropping into the for loop correctly. However, it fails on the String celltext line, which I am using to try to match on.
Here is the error I am receiving:
=============== ROOT CAUSE =====================
10-28-2020 11:07:31 AM Test Cases/Drug Dashboard/Settings/My Team/Patient List Table
Elapsed time: 47.982s
Test Cases/Drug Dashboard/Settings/My Team/Patient List Table FAILED.
Reason:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java_util_List$get$1.call(Unknown Source)
at Patient List Table.run(Patient List Table:42)
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:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1603901249104.run(TempTestCase1603901249104.groovy:25)
Any help would be greatly appreciated. I feel like its close, but I’m not used to this syntax.