Skip to content
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

misc: implement webdriver on top of geckodriver in order to reduce overhead maintenance and code #30324

Merged
merged 27 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
48c0a37
misc: implement webdriver npm package as the client for the webdriver…
AtofStryker Sep 26, 2024
abf7294
misc: go back to xulstore to save browser preferences [run ci]
AtofStryker Sep 30, 2024
c7c23f1
add changelog [run ci]
AtofStryker Sep 30, 2024
27bb8bd
chore: fix screenshot resolution [run ci]
AtofStryker Sep 30, 2024
ff075cf
fix check-ts issues [run ci]
AtofStryker Sep 30, 2024
31192bc
run windows ci [run ci]
AtofStryker Oct 1, 2024
713932e
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use…
AtofStryker Oct 1, 2024
69b7196
run ci
AtofStryker Oct 1, 2024
a937c50
add comments [run ci]
AtofStryker Oct 1, 2024
30b968b
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use…
AtofStryker Oct 2, 2024
5809c5f
build binaries for webdriver impl [run ci]
AtofStryker Oct 2, 2024
7bca33d
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use…
AtofStryker Oct 7, 2024
4f3804d
fix Cypress namespace missing issue. see https://github.com/cypress-i…
AtofStryker Oct 7, 2024
68f50a2
chore: updating v8 snapshot cache
Oct 7, 2024
6f33c60
chore: updating v8 snapshot cache
Oct 7, 2024
c17f87c
chore: updating v8 snapshot cache
Oct 7, 2024
9f647f9
patch edgedriver and preserve dependency paths for webdriver so they …
AtofStryker Oct 7, 2024
226c5ae
fix issues with firefox profile not being created in open mode when o…
AtofStryker Oct 9, 2024
e204aab
address comments that came up in review [run ci]
AtofStryker Oct 9, 2024
a2b40a6
see if this fixes extension test [run ci]
AtofStryker Oct 10, 2024
132ab07
make sure process kill emits the exit event [run ci]
AtofStryker Oct 10, 2024
5d1aa64
update geckodriver to include contribution patch to types [run ci]
AtofStryker Oct 10, 2024
9e09f84
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use…
AtofStryker Oct 10, 2024
78060ef
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use…
AtofStryker Oct 10, 2024
1d42807
fix misapplication of geckodriver package (accidentally deleted) [run…
AtofStryker Oct 10, 2024
00de09a
empty commit to trigger ci [run ci]
AtofStryker Oct 11, 2024
e8ab563
address comments from code review [run ci]
AtofStryker Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/cache-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Bump this version to force CI to re-create the cache from scratch.

09-30-24-windows-patch-server-2022
10-08-24-webdriver2
10 changes: 5 additions & 5 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mainBuildFilters: &mainBuildFilters
- /^release\/\d+\.\d+\.\d+$/
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- 'update-v8-snapshot-cache-on-develop'
- 'ryanm/fix/find-process'
- 'misc/use_webdriver'
- 'publish-binary'

# usually we don't build Mac app - it takes a long time
Expand All @@ -42,7 +42,7 @@ macWorkflowFilters: &darwin-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/find-process', << pipeline.git.branch >> ]
- equal: [ 'misc/use_webdriver', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -53,7 +53,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/find-process', << pipeline.git.branch >> ]
- equal: [ 'misc/use_webdriver', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -76,7 +76,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/find-process', << pipeline.git.branch >> ]
- equal: [ 'misc/use_webdriver', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -152,7 +152,7 @@ commands:
name: Set environment variable to determine whether or not to persist artifacts
command: |
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "ryanm/fix/find-process" ]]; then
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "misc/use_webdriver" ]]; then
export SHOULD_PERSIST_ARTIFACTS=true
fi' >> "$BASH_ENV"
# You must run `setup_should_persist_artifacts` command and be using bash before running this command
Expand Down
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _Released 10/1/2024 (PENDING)_
**Misc:**

- Cypress now consumes [geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver/index.html) to help automate the Firefox browser instead of [marionette-client](https://github.com/cypress-io/marionette-client). Addresses [#30217](https://github.com/cypress-io/cypress/issues/30217).
- Cypress now consumes [webdriver](https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver) to help automate the Firefox browser and [firefox-profile](https://github.com/saadtazi/firefox-profile-js) to create a firefox profile and convert it to Base64 to save user screen preferences via `xulstore.json`. Addresses [#30300](https://github.com/cypress-io/cypress/issues/30300) and [#30301](https://github.com/cypress-io/cypress/issues/30301).
- Pass spec information to protocol's `beforeSpec` to improve troubleshooting when reporting on errors. Addressed in [#30316](https://github.com/cypress-io/cypress/pull/30316).

**Dependency Updates:**
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"scripts"
],
"nohoist": [
"**/@wdio/*",
"**/webpack-preprocessor/babel-loader",
"**/webpack-preprocessor/**/merge-source-map",
"**/webpack-preprocessor/**/patch-package",
Expand All @@ -262,6 +263,7 @@
"**/@types/cheerio": "0.22.21",
"**/@types/enzyme": "3.10.5",
"**/@types/react": "16.9.50",
"**/@wdio/logger": "9.0.0",
"**/jquery": "3.4.1",
"**/pretty-format": "26.4.0",
"**/sharp": "0.29.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-context/src/DataContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class DataContext {
@cached
get cloud () {
return new CloudDataSource({
fetch: (...args) => this.util.fetch(...args),
fetch: (...args: [RequestInfo | URL, (RequestInit | undefined)?]) => this.util.fetch(...args),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ran into typings issues, my guess with the updated lock, which is kinda weird but I just chose to strongly type the lines that were failing

getUser: () => this.coreData.user,
logout: () => this.actions.auth.logout().catch(this.logTraceError),
invalidateClientUrqlCache: () => this.graphql.invalidateClientUrqlCache(this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SocketShape } from '@packages/socket/lib/types'
import type { ClientOptions } from '@urql/core'

export const urqlFetchSocketAdapter = (io: SocketShape): ClientOptions['fetch'] => {
return (url, fetchOptions = {}) => {
return (url, fetchOptions: RequestInit = {}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

return new Promise<Response>((resolve, reject) => {
// Handle aborted requests
if (fetchOptions.signal) {
Expand Down
18 changes: 9 additions & 9 deletions packages/server/lib/browsers/firefox-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Foxdriver from '@benmalka/foxdriver'
import * as protocol from './protocol'
import { CdpAutomation } from './cdp_automation'
import { BrowserCriClient } from './browser-cri-client'
import type { Client as WebDriverClient } from 'webdriver'
import type { Automation } from '../automation'
import type { CypressError } from '@packages/errors'
import type { WebDriverClassic } from './webdriver-classic'

const debug = Debug('cypress:server:browsers:firefox-util')

Expand All @@ -20,7 +20,7 @@ let timings = {
collections: [] as any[],
}

let webDriverClassic: WebDriverClassic
let webdriverClient: WebDriverClient

const getTabId = (tab) => {
return _.get(tab, 'browsingContextID')
Expand Down Expand Up @@ -103,11 +103,11 @@ async function connectToNewTabClassic () {
// For versions 124 and above, a new tab is not created, so @packages/extension creates one for us.
// Since the tab is always available on our behalf,
// we can connect to it here and navigate it to about:blank to set it up for CDP connection
const handles = await webDriverClassic.getWindowHandles()
const handles = await webdriverClient.getWindowHandles()

await webDriverClassic.switchToWindow(handles[0])
await webdriverClient.switchToWindow(handles[0])

await webDriverClassic.navigate('about:blank')
await webdriverClient.navigateTo('about:blank')
}

async function connectToNewSpec (options, automation: Automation, browserCriClient: BrowserCriClient) {
Expand Down Expand Up @@ -140,7 +140,7 @@ async function setupCDP (remotePort: number, automation: Automation, onError?: (
}

async function navigateToUrlClassic (url: string) {
await webDriverClassic.navigate(url)
await webdriverClient.navigateTo(url)
}

const logGcDetails = () => {
Expand Down Expand Up @@ -213,17 +213,17 @@ export default {
url,
foxdriverPort,
remotePort,
webDriverClassic: wdcInstance,
webdriverClient: wdInstance,
}: {
automation: Automation
onError?: (err: Error) => void
url: string
foxdriverPort: number
remotePort: number
webDriverClassic: WebDriverClassic
webdriverClient: WebDriverClient
}): Promise<BrowserCriClient> {
// set the WebDriver classic instance instantiated from geckodriver
webDriverClassic = wdcInstance
webdriverClient = wdInstance
const [, browserCriClient] = await Promise.all([
this.setupFoxdriver(foxdriverPort),
setupCDP(remotePort, automation, onError),
Expand Down
Loading
Loading