Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Uncaught object' error when previously clicked element is removed from the DOM and it is an <a> or <area> element #8264

Closed
egorshantur opened this issue Aug 26, 2024 · 2 comments · Fixed by #8289
Assignees
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@egorshantur
Copy link

What is your Scenario?

TestCafe (proxy mode) fails with 'Uncaught object' error on leaveElement when the prevElement is removed from the DOM, and it (or its parent, which is also removed) is an <a> or <area> element. The issue happens because subsequent getParent hammerhead's code returns "host", which is a string representing the host in case of <a> and <area> elements, not an element. This causes a failure when attempting to get its parent again using nativeMethods.nodeParentNodeGetter.call(el).

From the user's perspective, it appears that TestCafe attempts to move the mouse very slowly to the next element and then fails with an Uncaught object error.

Issue is not reproducible in native automation mode.

What is the Current behavior?

Test execution fails with error:

  1) Uncaught object

   "{"callsite":{"filename":"C:\\work\\git\\testcafe-callsite-issue\\test.js","lineNum":6,"callsiteFrameIdx":5,"stackFrames":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],"isV8Frames":true}}"
      was thrown. Throw Error instead.

What is the Expected behavior?

Testcafe should execute test commands without error

What is the public URL of the test page? (attach your complete example)

Test page to reproduce the issue

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Link Removal Example</title>
</head>
<body>
    <a href="https://www.google.com" id="link">Click me to remove</a>
    <button id="btn">Button</button>

    <script>
        document.getElementById('link').addEventListener('click', function(event) {
            event.preventDefault(); // Prevent the default link behavior
            this.remove(); // Remove the link element from the page
        });
    </script>
</body>
</html>

What is your TestCafe test code?

fixture('TestCafe Callsite Issue')
    .page('./page.html');

test('Test link removal', async t => {
    await t
        .click('#link')
        .click('#btn');
});

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

TestCafe version

^3.4.0

Node.js version

No response

Command-line arguments

testcafe chrome test.js --disable-native-automation

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

Tests running in proxy mode began failing after upgrading to version 3.4.0 or higher. The last version without this issue was 3.3.0.
I found that the issue is reproducible after the following change: DevExpress/testcafe#7995

If add removed code back, then test does not fail

        const prevElementInDocument = prevElement && domUtils.isElementInDocument(prevElement);

        const prevElementInRemovedIframe = prevElement && domUtils.isElementInIframe(prevElement) &&
                                         !domUtils.getIframeByElement(prevElement);

        if (!prevElementInDocument || prevElementInRemovedIframe)
            prevElement = null;

Based on the description "removed IE leftovers from src\client\automation," it should not affect my tests as I run them in Chrome. However, it did affect them, so I reviewed the code that was originally executed for all browsers but was removed in that commit, and identified the issue.

@egorshantur egorshantur added the TYPE: bug The described behavior is considered as wrong (bug). label Aug 26, 2024
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 26, 2024
@Bayheck Bayheck added STATE: Issue accepted An issue has been reproduced. and removed STATE: Need response An issue that requires a response or attention from the team. labels Aug 29, 2024
Copy link

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

@Vitalii4as
Copy link

Seems like I have the same issue

"{"callsite":{"filename":"../commonScripts.js","lineNum":373,"callsiteFrameIdx":5,"stackFrames":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],"isV8Frames":true}}"

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 3, 2024
@PavelMor25 PavelMor25 removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 9, 2024
@PavelMor25 PavelMor25 self-assigned this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Issue accepted An issue has been reproduced. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@egorshantur @Bayheck @Vitalii4as @PavelMor25 and others