-
Notifications
You must be signed in to change notification settings - Fork 675
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
improperly behaviour of window.getSelection().getRangeAt(0) #5420
Comments
Hello,
Please, update your version to the latest I suppose you tried to return the <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="div" contenteditable="true">Sample Text</div>
<button id="btn">Button to focus</button>
</body>
</html> test.js import { ClientFunction } from 'testcafe';
fixture `Fixture`
.page `./index.html`;
const getSelectionRange = async t => JSON.parse(await t.eval(() => {
const { startOffset, endOffset, collapsed } = window.getSelection().getRangeAt(0);
return JSON.stringify({ startOffset, endOffset });
}));
const focusOnButton = ClientFunction(() => {
document.getElementById('btn').focus();
});
test('test', async t => {
await t
.selectText('#div', 2, 8)
await focusOnButton();
const expectedRange = {
startOffset: 2,
endOffset: 8
}
await t
.expect(await getSelectionRange(t)).eql(expectedRange);
}); Result:
|
This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open. |
We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you. |
What is your Test Scenario?
Getting a selection of characters after focusing out by Tab key
What is the Current behavior?
Does'not return a selection after focusing out
What is the Expected behavior?
Should return a selected value after focusing out
What is your web application and your TestCafe test code?
Web app code:
TestCafe code:
window.getSelection().getRangeAt(0)
Steps to Reproduce:
Your Environment details:
testcafe version: 1.8.2
node.js version: 10.18.1
browser name and version: Chrome 84, Edge 84, Safari 13.1
platform and version: macOS, Windows
The text was updated successfully, but these errors were encountered: