diff --git a/packages/driver/cypress/fixtures/sticky-header.html b/packages/driver/cypress/fixtures/sticky-header.html
new file mode 100644
index 000000000000..63f891a7ee39
--- /dev/null
+++ b/packages/driver/cypress/fixtures/sticky-header.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/driver/cypress/integration/commands/actions/check_spec.js b/packages/driver/cypress/integration/commands/actions/check_spec.js
index 3b236e383228..a60c9cd10957 100644
--- a/packages/driver/cypress/integration/commands/actions/check_spec.js
+++ b/packages/driver/cypress/integration/commands/actions/check_spec.js
@@ -204,6 +204,42 @@ describe('src/cy/commands/actions/check', () => {
})
})
+ it('can specify scrollBehavior bottom in config', { scrollBehavior: 'bottom' }, () => {
+ cy.get(':checkbox:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get(':checkbox:first').check()
+
+ cy.get(':checkbox:first').then((el) => {
+ expect(el[0].scrollIntoView).to.be.calledWith({ block: 'end' })
+ })
+ })
+
+ it('can specify scrollBehavior center in config', { scrollBehavior: 'center' }, () => {
+ cy.get(':checkbox:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get(':checkbox:first').check()
+
+ cy.get(':checkbox:first').then((el) => {
+ expect(el[0].scrollIntoView).to.be.calledWith({ block: 'center' })
+ })
+ })
+
+ it('can specify scrollBehavior nearest in config', { scrollBehavior: 'nearest' }, () => {
+ cy.get(':checkbox:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get(':checkbox:first').check()
+
+ cy.get(':checkbox:first').then((el) => {
+ expect(el[0].scrollIntoView).to.be.calledWith({ block: 'nearest' })
+ })
+ })
+
it('does not scroll when scrollBehavior is false in config', { scrollBehavior: false }, () => {
cy.get(':checkbox:first').scrollIntoView()
cy.get(':checkbox:first').then((el) => {
@@ -230,6 +266,13 @@ describe('src/cy/commands/actions/check', () => {
})
})
+ // https://github.com/cypress-io/cypress/issues/4233
+ it('can check an element behind a sticky header', () => {
+ cy.viewport(400, 400)
+ cy.visit('./fixtures/sticky-header.html')
+ cy.get(':checkbox:first').check()
+ })
+
it('waits until element is no longer disabled', () => {
const chk = $(':checkbox:first').prop('disabled', true)
diff --git a/packages/driver/cypress/integration/commands/actions/clear_spec.js b/packages/driver/cypress/integration/commands/actions/clear_spec.js
index 145d135d9cb4..5dfab1bb74ae 100644
--- a/packages/driver/cypress/integration/commands/actions/clear_spec.js
+++ b/packages/driver/cypress/integration/commands/actions/clear_spec.js
@@ -124,6 +124,13 @@ describe('src/cy/commands/actions/type - #clear', () => {
})
})
+ // https://github.com/cypress-io/cypress/issues/4233
+ it('can scroll to an element behind a sticky header', () => {
+ cy.viewport(400, 400)
+ cy.visit('./fixtures/sticky-header.html')
+ cy.get('input:first').clear()
+ })
+
// https://github.com/cypress-io/cypress/issues/5835
it('can force clear when hidden in input', () => {
const input = cy.$$('input:first')
diff --git a/packages/driver/cypress/integration/commands/actions/click_spec.js b/packages/driver/cypress/integration/commands/actions/click_spec.js
index 7e0b0cacf535..e8e0bc7b54f3 100644
--- a/packages/driver/cypress/integration/commands/actions/click_spec.js
+++ b/packages/driver/cypress/integration/commands/actions/click_spec.js
@@ -1090,6 +1090,13 @@ describe('src/cy/commands/actions/click', () => {
cy.get('#overflow-auto-container').contains('quux').click()
})
+ // https://github.com/cypress-io/cypress/issues/4233
+ it('can click an element behind a sticky header', () => {
+ cy.viewport(400, 400)
+ cy.visit('./fixtures/sticky-header.html')
+ cy.get('p').click()
+ })
+
it('does not scroll when being forced', () => {
const scrolled = []
@@ -1224,6 +1231,42 @@ describe('src/cy/commands/actions/click', () => {
})
})
+ it('can specify scrollBehavior bottom in config', { scrollBehavior: 'bottom' }, () => {
+ cy.get('input:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get('input:first').click()
+
+ cy.get('input:first').then((el) => {
+ expect(el[0].scrollIntoView).calledWith({ block: 'end' })
+ })
+ })
+
+ it('can specify scrollBehavior center in config', { scrollBehavior: 'center' }, () => {
+ cy.get('input:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get('input:first').click()
+
+ cy.get('input:first').then((el) => {
+ expect(el[0].scrollIntoView).calledWith({ block: 'center' })
+ })
+ })
+
+ it('can specify scrollBehavior nearest in config', { scrollBehavior: 'nearest' }, () => {
+ cy.get('input:first').then((el) => {
+ cy.spy(el[0], 'scrollIntoView')
+ })
+
+ cy.get('input:first').click()
+
+ cy.get('input:first').then((el) => {
+ expect(el[0].scrollIntoView).calledWith({ block: 'nearest' })
+ })
+ })
+
it('does not scroll when scrollBehavior is false in config', { scrollBehavior: false }, () => {
cy.get('input:first').then((el) => {
cy.spy(el[0], 'scrollIntoView')
@@ -2155,7 +2198,8 @@ describe('src/cy/commands/actions/click', () => {
cy.on('fail', (err) => {
expect(this.logs.length).eq(2)
expect(err.message).not.to.contain('CSS property: `opacity: 0`')
- expect(err.message).to.contain('`cy.click()` failed because this element is not visible')
+ expect(err.message).to.contain('`cy.click()` failed because this element')
+ expect(err.message).to.contain('is being covered by another element')
done()
})
@@ -2282,17 +2326,10 @@ describe('src/cy/commands/actions/click', () => {
expect(lastLog.get('snapshots')[0].name).to.eq('before')
expect(lastLog.get('snapshots')[1]).to.be.an('object')
expect(lastLog.get('snapshots')[1].name).to.eq('after')
- expect(err.message).to.include('`cy.click()` failed because this element is not visible:')
- expect(err.message).to.include('>button ...')
- expect(err.message).to.include('`