So far I have been using Katalon for Mozilla Firefox and everything worked fine, but today when creating (previously recorded pages) I get the error [error] c.initKeyEvent is not a function
Welcome to Katalon Community, please kindly share your log or screenshot so we can assist you with your issue.
The error [error] c.initKeyEvent is not a function typically indicates a JavaScript compatibility issue. The initKeyEvent() method is a deprecated DOM API that was removed from modern Firefox versions. This method was replaced by the KeyboardEvent constructor in modern browsers.
This error commonly occurs when:
- Test scripts or recorded actions are using outdated keyboard event simulation methods
- Website JavaScript code is using deprecated APIs that Firefox no longer supports
- Katalon’s recording mechanism is capturing interactions that rely on deprecated methods
Troubleshooting Steps
1. Update Firefox and WebDriver
- Ensure you’re using a compatible version of Firefox and GeckoDriver
- Update Katalon Studio to the latest version, which may have fixes for Firefox compatibility
2. Check Your Test Scripts
If you’re using custom keyboard event code, replace deprecated initKeyEvent() with the modern KeyboardEvent constructor:
// OLD (Deprecated - Don't use)
var event = document.createEvent('KeyboardEvent');
event.initKeyEvent('keydown', true, true, window, false, false, false, false, 65, 0);
// NEW (Modern approach)
var event = new KeyboardEvent('keydown', {
key: 'a',
code: 'KeyA',
keyCode: 65,
which: 65,
bubbles: true,
cancelable: true
});
3. Use Katalon’s Built-in Keyboard Keywords
Instead of custom JavaScript, use Katalon’s native keyboard keywords:
// Use Katalon's sendKeys keyword instead of custom JavaScript
WebUI.sendKeys(findTestObject('your_element'), 'your_text')
// Or use the Keys class for special keys
WebUI.sendKeys(findTestObject('your_element'), Keys.chord(Keys.CONTROL, 'a'))
4. Disable JavaScript Execution (if applicable)
If the error is coming from website JavaScript, you might need to:
- Check if the website has JavaScript errors in its own code
- Contact the website owner if it’s their code using deprecated APIs
- Consider using Firefox preferences to handle this
5. Re-record Your Tests
- Delete the problematic recorded test steps
- Re-record them fresh with the latest version of Katalon
- Avoid using custom keyboard event JavaScript if possible
6. Check Firefox Version Compatibility
Refer to the Katalon documentation on Firefox compatibility:
References
hi @es600jarek
it’s seems like compatibility version issue.
maybe you can try to:
- update geckodriver:
- in Katalon Studio: Tools → Update WebDrivers → Firefox, then restart and retry
- update Katalon Studio: newer builds often fix Firefox/geckodriver compatibility issues
- if custom JS is involved, stop using
initKeyEventand switch tonew KeyboardEvent(...)
Did you check any of the suggested solutions?
kindly update both katalon and webdrivers to latest version and confirm if issue still persists?