0

While running Selenium tests on my customizations to a CMS generated donation form I was getting inexplicable errors. I need to get the configuration options for the form from my page. So I did this:

const foo = await driver.executeScript('return Bar.options');

Which gave me these:

  • StaleElementReferenceError: The element is no longer attached to the DOM
    Which is all well and good except I never once referenced that element.
  • JavascriptError: Cyclic object value
    Which was a total WTF?

1 Answer 1

1

Answering my own quesion in case anyone else runs into this or I forget what I did.

Tackling the Cyclic object issue first, I remembered that the page configuration object contained jQuery objects. I can't (don't want to) use that in my Selenium stuff anyway so I did this instead:

const foo = JSON.parse(await driver.executeScript(`return JSON.stringify(Bar.options.theOneIWant, function (key, value) {
    if (value?.jquery)
        return {
            id: value.attr('id'),
            value: value.val()
        };
    else
        return value;
});`));

Et voila! I have a collection of customization options which bypasses the jQuery stuff while keeping some values just in case I want them later. In addition, the StaleElementReferenceError magically disappeared. I expect it was one of the many nested jQuery objects pointing to various bits of the DOM I need to manipulate. Those items get regenerated when the CMS rewrites the DOM so I don't care to test that particular error.

Shorter answer and more work would be just to eliminate jQuery from my customization code. Screw that, it makes my life easier.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.