What would be a possible reason that tests pass in chrome but failed in firefox- particularly i was trying to send text to the input box which worked in chrome. I was able to send in firefox too but was not saved

Problem Analysis

Your issue is a classic cross-browser testing problem where text is successfully sent to an input field in Firefox but not persisted. This typically occurs because Firefox and Chrome handle JavaScript events and DOM updates differently, particularly when using Katalon’s text input methods.

Root Causes

1. Missing JavaScript Event Triggers
The primary culprit is that WebUI.setText() in Katalon injects text directly into the element’s property without firing companion JavaScript events like change, input, keydown, or blur. Many web applications rely on these events to trigger save logic or data persistence. Firefox may be more strict about requiring these events to fire before persisting data, while Chrome may handle it more leniently.

2. Browser-Specific Event Handling Differences
Firefox and Chrome handle the blur event differently in certain scenarios. In Firefox, the blur event may not fire when it would in Chrome, especially if the element’s parent is hidden or if there are timing issues. This prevents your application’s save handlers from executing.

3. Timing and Synchronization Issues
Firefox and Chrome execute JavaScript and handle DOM mutations at different speeds. Your test may proceed to verify the saved data before Firefox has completed the event handling chain and persistence logic. Chrome’s faster execution may mask this timing issue.

4. DOM Rendering Differences
Each browser handles DOM updates and CSS animations differently, which can affect when and how your application’s JavaScript responds to input changes.

Solutions

Option 1: Trigger Events Manually After setText()
After using WebUI.setText(), explicitly trigger the necessary events:

// Set the text
WebUI.setText(findTestObject('Object Repository/input_field'), 'Your Text')

// Trigger the blur event to simulate user leaving the field
WebUI.executeJavaScript('arguments[0].blur()', findTestObject('Object Repository/input_field'))

// Or trigger change event
WebUI.executeJavaScript('arguments[0].dispatchEvent(new Event("change", { bubbles: true }))', findTestObject('Object Repository/input_field'))

Option 2: Use sendKeys() Instead of setText()
sendKeys() more closely mimics actual user typing and is more likely to trigger events:

WebUI.sendKeys(findTestObject('Object Repository/input_field'), 'Your Text')

Option 3: Add Explicit Waits
Ensure Firefox has enough time to complete event handling and persistence:

WebUI.setText(findTestObject('Object Repository/input_field'), 'Your Text')
WebUI.delay(1) // Add delay for Firefox to process
WebUI.executeJavaScript('arguments[0].blur()', findTestObject('Object Repository/input_field'))
WebUI.waitForElementPresent(findTestObject('Object Repository/saved_indicator'), 10)

Option 4: Use Actions API for More Natural Input
The Actions API simulates more realistic user interactions:

WebUI.click(findTestObject('Object Repository/input_field'))
WebUI.sendKeys(findTestObject('Object Repository/input_field'), 'Your Text')
WebUI.sendKeys(findTestObject('Object Repository/input_field'), Keys.TAB) // Trigger blur

Key Considerations

  • Avoid mixing implicit and explicit waits - this can cause unpredictable wait times
  • Test with both methods - if setText() doesn’t work in Firefox, switch to sendKeys() which better simulates user behavior
  • Browser-specific testing - always test critical workflows in both Chrome and Firefox, as they may behave differently
  • Event-driven applications - if your application heavily relies on JavaScript events for data persistence, manually triggering events after text input is essential

References