testcafe: 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@tbcoyle I researched both your examples and found that they have different causes. So I created a separated ticked for this one https://github.com/DevExpress/testcafe/issues/2601#issuecomment-502809500 Please refer to it https://github.com/DevExpress/testcafe/issues/3924

@tbcoyle Thank you for another example. I was able to reproduce the issue in Chrome. I hope to fix it in the near future.

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.