testcafe
testcafe copied to clipboard
Hammerhead crashes if DOM contains iframes with quotes in name attribute
What is your Scenario?
DOM contains an iframe like
<iframe src="https://example.com" name='my "example" page'/>
What is the Current behavior?
If i run any test, hammerhead crashes with: Failed to execute 'querySelectorAll' on 'Document': '*[target="my "example" page"]' is not a valid selector.
What is the Expected behavior?
hammerhead handles this special case of name attributes correct
What is your public website URL? (or attach your complete example)
https://crs7fr.csb.app/
What is your TestCafe test code?
fixture(`Iframe`).page("https://crs7fr.csb.app/");
test("iframe input exists", async (t) => {
await t.expect(Selector(`[data-test-id="iframe"]`).count).eql(1);
});
Your complete configuration file
No response
Your complete test report
No response
Screenshots
No response
Steps to Reproduce
- run example test provided above
TestCafe version
1.18.4
Node.js version
No response
Command-line arguments
Browser name(s) and version(s)
No response
Platform(s) and version(s)
No response
Other
No response
Could be fixed by changing https://github.com/DevExpress/testcafe-hammerhead/blob/master/src/client/sandbox/node/element.ts#L960 to
const elementsWithTarget = nativeMethods.querySelectorAll.call(this.document, `*[target="${iframe.name.replaceAll('"', '\\"')}"]`);
I was able to reproduce the issue. Moreover, I confirm that your fix solves the described problem. If you want, you can create a PR with the suggested fix. We will review it.
fixed by https://github.com/DevExpress/testcafe-hammerhead/pull/2788