Scroll works but back to top page again while next action
Are you requesting a feature or reporting a bug?
BUG
What is your Test Scenario?
Scrolling in a page
What is the Current behavior?
The page is already scrolling to bottom, but when the next action it came back to top again.
What is the Expected behavior?
The page is stay at current position after scrolling
How would you reproduce the current behavior (if this is a bug)?
import { Selector, ClientFunction } from 'testcafe'
const browserscroll = ClientFunction(function() {
window.scrollBy(0,500)
});
await t.typeText(pageForm.fieldARTitle, 'Congratulations!')
await browserscroll()
await t.typeText(pageForm.fieldContinueButton, 'Continue')
Provide the test code and the tested page URL (if applicable)
Your website URL (or attach your complete example):
Your complete test code (or attach your test files)
Your Environment details:
- testcafe version:
- node.js version:
- command-line arguments:
- browser name and version:
- platform and version:
- other: testcafe 0.23.2 OSX Mojave Chrome 70
same with me, although some url testcafe can automatically scroll to element, but in some case element can not find, and seems like testcafe don't have scroll function. I scroll using window scroll, but after scroll, testcafe return the previous state
I tried to reproduce the issue with the following page and test, but it works fine:
page.html
<html>
<head></head>
<body>
<input id="header"/>
<div style="height:2000px"></div>
<input id="footer"/>
</body>
</html>
test.js
import { Selector, ClientFunction } from 'testcafe'
const browserscroll = ClientFunction(function() {
window.scrollBy(0,500)
});
fixture`1`.page`./test3.html`;
test(`1`, async t => {
await t.typeText('#header', 'Congratulations!')
await browserscroll()
await t.typeText('#footer', 'Continue')
})
I also tried to reproduce it on a Github page with the following test, but it also works:
test-github.js
import { ClientFunction } from 'testcafe';
fixture `GitHub`
.page `https://github.com/DevExpress/testcafe/issues/3119`;
const scroll = ClientFunction(function() {
window.scrollBy(0,500)
});
test(`test`, async t => {
await t.typeText('.header-search-input', 'test');
await scroll();
await t.hover('.discussion-timeline-actions');
await t.wait(1000);
});
Could you please provide a page that can be used to reproduce the issue?
Also, this problem can be caused by a situation when Chrome needs some time to update the page layout and recalculate coordinates. Try adding the t.wait action after the call to the browserscroll function. It should help in this case:
await t.typeText(pageForm.fieldARTitle, 'Congratulations!')
await browserscroll()
await t.wait(3000)
await t.typeText(pageForm.fieldContinueButton, 'Continue')
I think i have same problem with this issue https://github.com/DevExpress/testcafe/issues/2900 Anw, what's the possibility the cause of testcafe can not autoscroll in certain website page?
I have the same issue. I'm trying to click on page 2 button positioned at the bottom of a long page. It works ok on remote device with Safari, but bugs out on PC with Chrome. The moment when the element is supposed to be clicked the page is scrolled to the top and the element is not found.
This is the structure of the DOM tree. Unfortunately, I cannot share the page. #app > div > div > div > div:nth-child(2) > div:nth-child(3) > div > div > div.paginator-container > ul > li:nth-child(4) > a
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
Any progress or solution for this? I scroll to element by using the ClientFunction, but as soon as test.click method gets called the page scrolls back to top of page. A solution would be to implement my own click method but, because of the complexity of my query the item I try to find can not be found with normal css selectors.
Is there anyway I can avoid this behavior? Does anyone have a solution? Also why does test cafe NOT have a built in scroll function??
const TestSurveyCard = Selector(testSurveyCardSelector + ' > span.card-twisit-title').withExactText('Test survey (integration tests)');
await t.expect(TestSurveyCard.exists).ok('Survey card not found, or no incomplete survey matching id available');
await TestBase.scrollToElement(await TestSurveyCard.parent('div.c-card.active.survey'));
await t.wait(5000);
await t.click(TestSurveyCard); //Jumps back to top of page here
The element can no longer be clicked as it is not in view
@EttoreRaimondi
Click action should not force a page to scroll back to top. This behavior is incorrect. Please provide us with a full example where this issue is reproduced.
TestCafe does not provide a special scroll action because it has the built-in scrolling functionality in such actions as click, hover, etc.