Selection code works in Chrome but not Firefox

Below is the code I use to select from a list of clickable elements. It works with Chrome and moves on to the next Test Case fine, but in Firefox it doesn’t work but still moves on as if the Test Case passes and all following Test Cases fail.

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import org.openqa.selenium.WebElement

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable

List<WebElement> dispatchEntryList = WebUI.findWebElements(findTestObject('Object Repository/Dispatch List/Buttons/Dispatch Entry'), 2)

if(dispatchEntryList.size() > 0) {
	
	int count = -1;
	
	for(int i = 0; i < dispatchEntryList.size(); i++) 
		if(dispatchEntryList.get(i).getAttribute('outerText').equals('# ' + GlobalVariable.dispatchNumber)) {
			count = i;
			break;
		}
		
	if(count != -1) 
		dispatchEntryList.get(count).click()
	
}

The image shows my list of items. I am trying to click the one numbered #1702

(Fixed your code formatting for clarity…)

My guess as to what’s happening is that your locator is returning a non-empty list of elements in chrome, but that same locator is returning an empty list in FF. Thus, your if() condition is skipped entirely, and your test “fails” silently.

My suggestion would be to take whatever locator you are using to get the list, and enter it into the console of the FF inspector, and see if you are still getting a non-empty list of elements like you are in Chrome.

Also, if you can share your locator as well as the HTML for the target elements, we may be able to provide a more stable solution.