Skip to content

fix: activate main tab before detecting iframe focus in firefox/bidi implementation of cy.press() #31481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 14, 2025

Conversation

cacieprins
Copy link
Contributor

Additional details

The webdriver classic window reference does not sync with the webdriver bidi active context automatically; between specs we clear out all of the tabs and create a new one, so webdriver classic needs to be informed of which window/tab needs to be active. The webdriver classic methods in use are in order to determine if the AUT iframe has focus (will receive key press events).

Steps to test

In run mode, execute any spec prior to executing the cypress/e2e/commands/actions/press.cy.ts spec (or any other spec that includes the cy.press() command. The cy.press() command should not error.

How has the user experience changed?

PR Tasks

@cacieprins cacieprins marked this pull request as ready for review April 10, 2025 18:24
@AtofStryker AtofStryker self-requested a review April 10, 2025 18:57
Copy link

cypress bot commented Apr 10, 2025

cypress    Run #61586

Run Properties:  status check passed Passed #61586  •  git commit 4bc7525aff: Merge branch 'develop' into cacie/fix/ff-press-flake
Project cypress
Branch Review cacie/fix/ff-press-flake
Run status status check passed Passed #61586
Run duration 09m 37s
Commit git commit 4bc7525aff: Merge branch 'develop' into cacie/fix/ff-press-flake
Committer Cacie Prins
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 694
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 130
View all changes introduced in this branch ↗︎

}

async function activateTopWindow (client: Client, autContext: string): Promise<void> {
const { contexts: [{ context: topLevelContext }] } = await client.browsingContextGetTree({})
Copy link
Contributor

@AtofStryker AtofStryker Apr 10, 2025

Choose a reason for hiding this comment

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

can we just eliminate this function and just call client.switchToWindow(topLevelContext) or remove the autContext arg? I don't think autContext is used, but my guess is this was looking up the top context before but no longer is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in e0421b2

@AtofStryker AtofStryker self-requested a review April 11, 2025 13:55

it('activates the top level context window', async () => {
await bidiKeyPress({ key }, client as WebdriverClient, autContext, 'idSuffix')
expect(client.switchToWindow).to.have.been.calledWith(topLevelContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably also testing the case when the top level context is already active and we don't need to call switchToWindow if that test doesn't already exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely - also the case where there is an active window, but it's not our top. Addressed in 944b913

@cacieprins cacieprins merged commit 9a51a0f into develop Apr 14, 2025
90 of 91 checks passed
@cacieprins cacieprins deleted the cacie/fix/ff-press-flake branch April 14, 2025 20:13
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 17, 2025

Released in 14.3.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v14.3.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In Firefox, cy.press() only works in the first spec of a run
2 participants