Daniel
There’s something crazy going on here, because the mechanism we’re talking about certainly works (all my tests would fail if this didn’t work). So we’re looking for something a bit crazy/stupid/whatever.
In brief, here is what my test code does:
I have a file, helpers.js, which I load from disk and insert into my AUT page. I do this in a listener, like so:
@BeforeTestCase
def loginBeforeTestCase(TestCaseContext testCaseContext) {
comment("loginBeforeTestCase")
LOGGEDIN = false
TEST_FAILED = false
IS_STANDARD_PAGE = false
String tcId = testCaseContext.testCaseId
GlobalVariable.TCID = tcId
GlobalVariable.LAST_AUT_MSG = ""
if(tcId.startsWith("Test Cases/Pages")) {
IS_STANDARD_PAGE = true
}
// ************************************************************
loadJSHelpers() // LOAD helpers.js form Disk
// ************************************************************
getProfileSettings()
getCredentials(tcId)
// etc ..........
}
helpers.js contains things like
function $$(selector, frmSelector) {
if(frmSelector) {
return getFrameElement(frmSelector, selector);
}
return document.querySelector(selector);
}
function $$prop(selector, prop, frmSelector) {
if(frmSelector) return getFrameProp(frmSelector, selector, prop);
var el = $$(selector);
var style = window.getComputedStyle(el);
return style.getPropertyValue(prop);
}
// etc ..........
I’m just showing you all that crapola so you can see what you’re trying to do is perfectly fine. It is most certainly going to work.
I (and you) just can’t figure out what is going wrong.
Questions:
1 - did you try this in a trimmed down example test inside a dead simple project?
2 - Did you check the browser console (F12 developer tools) just in case there is an error?
3 - Last resort - did you try kicking the computer?

Let me know how it goes and what you find.
Good luck!