testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

CleanAttributes() dosn't work with Attribute "length"

Open lisandrogreco opened this issue 2 years ago • 3 comments

What is your Scenario?

When a wrapper element contains an attribute which is named "length". The for loop crashes because the length attribute got removed. This breaks the Test execution in Testcafe

https://github.com/DevExpress/testcafe-hammerhead/blob/a878aefb01e45c3dc58d9d92da6e618cbc494c4c/src/client/sandbox/node/attributes/index.ts#L8

What is the Current behavior?

Testcafe execution fails when element has an attribute named "length"

What is the Expected behavior?

Testcafe works as expected

What is your public website URL? (or attach your complete example)

http://axas-welt.de/

What is your TestCafe test code?

import { Selector } from 'testcafe';

fixture`Getting Started`
    .page`http://axas-welt.de/`;
    

test('My first test', async t => {
   await t
   .typeText("#myId", "Hallo")
});

### Your complete configuration file

{ "browsers": "chrome", "selectorTimeout": 45000, "assertionTimeout": 45000, "pageLoadTimeout": 45000, "screenshots": { "takeOnFails": false }, "skipJsErrors": true, "disableHttp2": true }

Your complete test report

No response

Screenshots

2022-03-06_15-56-13

2022-03-06_17-09-28

Steps to Reproduce

  1. Execute Test

TestCafe version

1.18.4

Node.js version

v16.14.0

Command-line arguments

testcafe test.ts

Browser name(s) and version(s)

Chrome

Platform(s) and version(s)

Windows

Other

As workaround i changed the for loop with skipping the deletion of the attribute

function cleanAttributes(wrapper) {
	    if (wrapper.length) {
	        for (var i = 0; i < wrapper.length; i++) {
		if(wrapper[i].name == "length")
		{					
                    continue;
		}
	            delete wrapper[wrapper[i].name];
	            delete wrapper[i];
	        }
	    }
	}

lisandrogreco avatar Mar 06 '22 16:03 lisandrogreco

Hi @lisandrogreco

Thank you for the shared information. I've reproduced the issue.

alexfi1in avatar Mar 07 '22 10:03 alexfi1in

If it's ok for you i would implement the workaround mentioned above to prevent this issue. I could to then a PR. For us it would be better if we could still use the "original" version of testcafe and testcafe-hammerhead instead of our custom fixed version

lisandrogreco avatar Mar 28 '22 06:03 lisandrogreco

I'm afraid that your workaround isn't suitable for us. We will research the issue and update this thread once we have any news.

Aleksey28 avatar Mar 29 '22 08:03 Aleksey28

We will close this issue since it is fixed in the Native Automation mode. Please try the native automation mode in your tests. Feel free to reopen the issue if you need a fix for the other browsers or you cannot use Native Automation for some reason.

Artem-Babich avatar Apr 13 '23 06:04 Artem-Babich