Skip to content

Commit

Permalink
fix flaky test because of inline element
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mann committed Jun 29, 2020
1 parent 1508bac commit 715d07c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3711,7 +3711,8 @@ describe('shadow dom', () => {
it('does not hang when experimentalShadowDomSupport is false and clicking on custom element', () => {
Cypress.config('experimentalShadowDomSupport', false)
// needs some size or it's considered invisible and click will fail its prerequisites
cy.$$('#shadow-element-1').css({ padding: 2 })
// so we make it display: block so its getClientRects() contains only a single
cy.$$('#shadow-element-1').css({ display: 'block' })

cy.get('#shadow-element-1').click()
})
Expand Down
10 changes: 9 additions & 1 deletion packages/driver/src/dom/coordinates.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const _ = require('lodash')
const $window = require('./window')
const $elements = require('./elements')

Expand All @@ -7,6 +8,13 @@ const getElementAtPointFromViewport = (doc, x, y) => {

const isAutIframe = (win) => !$elements.getNativeProp(win.parent, 'frameElement')

const getFirstValidSizedRect = (el) => {
return _.find(el.getClientRects(), (rect) => {
// use the first rect that has a nonzero width and height
return rect.width && rect.height
}) || el.getBoundingClientRect() // otherwise fall back to the parent client rect
}

/**
* @param {JQuery<HTMLElement>} $el
*/
Expand All @@ -32,7 +40,7 @@ const getElementPositioning = ($el) => {
// returns a zero length DOMRectList in that case, which becomes undefined.
// so we fallback to getBoundingClientRect() so that we get an actual DOMRect
// with all properties 0'd out
const rect = [...el.getClientRects()].find((e) => e.width && e.height) || el.getBoundingClientRect()
const rect = getFirstValidSizedRect(el)

// we want to return the coordinates from the autWindow to the element
// which handles a situation in which the element is inside of a nested
Expand Down

4 comments on commit 715d07c

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 715d07c Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/linux-x64/circle-develop-715d07c1a9308ad215fe35da2775100a31dbf982-381978/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/circle-develop-715d07c1a9308ad215fe35da2775100a31dbf982-381961/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 715d07c Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-ia32/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.10.0/win32-ia32/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-ia32/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-ia32/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 715d07c Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-x64/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.10.0/win32-x64/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-x64/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/win32-x64/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.10.0/appveyor-develop-715d07c1a9308ad215fe35da2775100a31dbf982-33804787/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 715d07c Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.10.0/darwin-x64/circle-develop-715d07c1a9308ad215fe35da2775100a31dbf982-382278/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.10.0/circle-develop-715d07c1a9308ad215fe35da2775100a31dbf982-382141/cypress.tgz

Please sign in to comment.