Unable to click an element as it does not scroll above the webpage footer
Are you requesting a feature or reporting a bug?
Bug
What is the current behavior?
The webpage under test has a footer and the button to be clicked scrolls and comes behind the footer. Due to this, testcafe is unable to click on the button and the script fails. Workaround used: Tried to use a client function with “ScrollBy” function. This works inconsistently. Works in one environment but does not work on another test environment
What is the expected behavior?
The button scrolls up automatically into the browser viewport above the webpages footer and testcafe is able to click the button
How would you reproduce the current behavior (if this is a bug)?
Since I am unable to share our application under test in our test environment. testcafe script with an sample website with similar footer and similar issue is provided below.
Provide the test code and the tested page URL (if applicable)
Attached testcafe script has the details Tested page URL:
Test code
=================================== Testcafe sample code:
import { Selector } from 'testcafe';
import { ClientFunction } from 'testcafe';
fixture `Automation Testing Started...`
.page `https://www.fwd.com.sg`;
const browserscroll = ClientFunction(function() {
// window.scrollBy(0, 100);
window.scrollBy(0,1000)
//document.scrollIntoView(true)
})
test('Test', async t => {
await t.maximizeWindow();
await browserscroll();
//await t.wait(5000);
await t.click("body > nav:nth-child(2) > div.nav-container.top-nav.container-fluid > div.navbar-collapse.collapse > div > button");
await t.click("#productListModalWrapper > div > div > div > ul > li:nth-child(2) > div.frame-container > svg");
await t.click("#quickquestions > form > div:nth-child(1) > div:nth-child(2) > div > div.input-group__input > i");
await t.click("#app > div.menu__content.menu__content--select.menu__content--auto.menuable__content__active > div > ul > li:nth-child(1) > a > div");
await t.click("#TI_GetQuotepage_Next_1");
await t.click("#TI_GetQuotepage_Promo_Skip");
await t.click("#TI_QuoteSummarypage_Premium_Buy_Bottom");
await t.click("#TI_BuyEnhacements_Continue_Yes"); // FAILS TO CLICK THIS BUTTON AS IT APPEARS BEHIND THE FOOTER
await t.click("#coverage-list > ul > li:nth-child(4) > section > div.coverage__checkbox > div > div.input-group__input > div");
await t.click("#TI_BuyEnhacements_Next_Submit");
await t.typeText("#holder-form > div:nth-child(7) > div.flex.spinner-input.xs12.sm7 > input", "100060");
await t.click("#traveller-details > div > div.consent > div.consent__checkbox > div > div.input-group__input > div");
})
===================================
Specify your
- operating system: Windows 10 pro
- testcafe version: 0.19.2 and 0.20.0
- node.js version: 8.11.2 *Browser version: 67.0.3396.99 (Official Build) (64-bit) *NPM: 5.6.0
Hi @srijitdas8, I've reproduced the problem.
Hi Guys....Any luck with the issue. Appreciate your help...Thanks
Hi @srijitdas8, I'm working on this.
Hi @srijitdas8 We've optimized the scrolling mechanism in context of https://github.com/DevExpress/testcafe/issues/2450 . It should also fix the current issue. Could you please check the issue with the latest (0.21.1) testcafe version?
Hi @AlexKamaev and @AndreyBelym, since upgrading from version 0.20.5 to 0.21.1 I suddenly started experiencing the same issue as #2450. This seems to be a new issue as of the newer versions, because on version 0.20.5 this was not a problem. In 0.20.5, it would scroll to avoid the fixed element, but I don't see that same scrolling behavior happening in 0.21.1.
Hi @edenadler Would you please share your test page and test file? Could you also clarify in which browser you can reproduce the issue?
Hi @AlexKamaev. I'm not able to share the test page and file, but I found a solution to the problem. The problem was that it is only scrolling horizontally but not vertically. I can submit a pull request for it. Since #2450 is already closed, let me know what ID I should submit it with.
I'm happy to hear that you solved the issue. If you think that it was connected to #2450, you can submit your PR with its ID. I'll take a look at your PR and review it; otherwise, you are free to open a separate issue and post it there.
@AlexKamaev PR submitted https://github.com/DevExpress/testcafe/pull/2812
Thanks, I'll take a look
I've reviewed the PR and found that you toggle scrollDirection on every step of the cycle. However, the idea of the algorithm is to move horizontally from the left to the right and try to detect that the element is visible. If the element is not visible on the whole horizontal line, then the algorithm increases the vertical margin and so on.
If you cannot share a real page of your project, could you please provide us with a simple example based on your real page to demonstrate the issue?
I'm closing this since there was no activity here for a long time. Feel free to reopen the issue if it's still actual.
any update for this issue? i don't think it's solve. I face the same issue
@juliusgonawan Could you please clarify what TestCafe version you are using? If you can reproduce the issue with the latest version, could you share your test project and code?
We are also experiencing a similar issue. Tests started failing after we introduced a sticky footer.
When I run tests in UI mode and scroll manually when it reaches to the end of screen size, tests are working fine. But without the manual scrolling and in headless mode, it doesn't scroll after filling first elements appear on the screen and tests start failing.
Version: 0.23.1
@eaorak, could you please provide an example of a webpage and test code I could use to reproduce this behavior.
I've tried testing a random website with a sticky footer with TestCafe v0.23.2. When I run my test in the UI mode, TestCafe seems to scroll to an element behind the footer automatically, I didn't have to scroll manually within a client function.
As to the headless mode, I haven't found good content that would allow me to ensure that TestCafe scrolls down correctly and clicks the correct element.
So, it would be of great help if you send a reproducible example.
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.
@VasilyStrelyaev because it's a private web app we're building for a client, unfortunately, I won't be able to share a public website. But it's a React application and we're using React Bootstrap components to create the sticky footer as with other components.
For now, we've overcome the issue by increasing the viewport size with
t.resizeWindow(1200, 3000)
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.
I am having similar issue here - clientFunction scrollby does not work for me, but I can get by from doing either resizeWindow or call hover with offset but should not be the permanent solution though.