tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
84.71k stars 2.55k forks source link

[docs] WebDriver (Selenium and WebdriverIO) e2e testing does not work. #10670

Open ospfranco opened 2 months ago

ospfranco commented 2 months ago

I'm trying to setup end-to-end tests for Tauri. I've followed the official documentation but when I try to start my tests I get the following error:

** (pulsar:12894): WARNING **: 06:38:47.744: Disabled hardware acceleration because GTK failed to initialize GL: Unable to create a GL context.

** (pulsar:12894): WARNING **: 06:38:47.751: webkit_settings_set_enable_offline_web_application_cache is deprecated and does nothing.
  1) "before all" hook in "{root}"
  2) "after all" hook in "{root}"

  0 passing (741ms)
  2 failing

  1) "before all" hook in "{root}":
     SessionNotCreatedError: Failed to match capabilities
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:521:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:514:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:446:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) "after all" hook in "{root}":
     TypeError: Cannot read properties of undefined (reading 'quit')
      at Context.<anonymous> (test/test.js:47:16)
      at process.processImmediate (node:internal/timers:483:21)

The application starts correctly when I launch it manually. But fails without a reason in the selenium test. Any idea what could be wrong or how can I get a more descriptive error? Are the docs up-to-date? Migration to v2 is not possible for us at the moment, just need to get the tests running, any help is much appreciated.

ospfranco commented 2 months ago

I decided to give webdriverio a test. Again following the official docs. This time it gets further. The app starts and there is some console output. But the tests never start running. Am I missing something?

OSP 000215

My app starts and when I minimize it I see on the console nothing is running.

ospfranco commented 2 months ago

I have tried updating the wdio dependencies to the latest versions, but I get other errors.

Any feedback @FabianLars ?

OSP 000251

ospfranco commented 2 months ago

When I leave the test running my linux vm hangs and dies. But I've manage to retrieve a log where there is a request failure:

debian@debian:~/Developer/pulsar/wdio$ yarn test

Execution of 1 workers started at 2024-08-24T12:59:11.703Z

2024-08-24T12:59:11.710Z INFO @wdio/cli:launcher: Run onPrepare hook
2024-08-24T12:59:11.710Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2024-08-24T12:59:11.711Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
[0-0] 2024-08-24T12:59:11.861Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in undefined - /test/specs/example.e2e.js
[0-0] 2024-08-24T12:59:11.902Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2024-08-24T12:59:11.919Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-08-24T12:59:11.919Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': {
[0-0]       application: '../src-tauri/target/release/pulsar',
[0-0]       webviewOptions: {}
[0-0]     }
[0-0]   }
[0-0] }
[0-0] "/home/debian/Developer/pulsar/src-tauri/target/release/nebula/backends/llama_cpp/llama-cpp-sys/dist"
[0-0] libEGL warning: egl: failed to create dri2 screen
[0-0] 
[0-0] ** (pulsar:7355): WARNING **: 05:59:12.093: webkit_settings_set_enable_offline_web_application_cache is deprecated and does nothing.
[0-0] libEGL warning: egl: failed to create dri2 screen
[0-0] [2024-08-24][12:59:12][INFO][a7@tauri://localhost/assets/index-BztbfkBh.js:43:675] [Model Manager] has no local models
[0-0] [2024-08-24][12:59:13][ERROR][a7@tauri://localhost/assets/index-BztbfkBh.js:43:675] [Updates] the platform `linux-aarch64` was not found on the response `platforms` object
[0-0] 2024-08-24T13:01:12.035Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2024-08-24T13:01:12.038Z INFO webdriver: Retrying 1/3
[0-0] 2024-08-24T13:01:12.038Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-08-24T13:01:12.038Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': {
[0-0]       application: '../src-tauri/target/release/pulsar',
[0-0]       webviewOptions: {}
[0-0]     }
[0-0]   }
[0-0] }
[0-0] "/home/debian/Developer/pulsar/src-tauri/target/release/nebula/backends/llama_cpp/llama-cpp-sys/dist"
[0-0] libEGL warning: egl: failed to create dri2 screen

You can see there is a Request timed out! response. When I call the endpoint http://localhost:4444/session manually I do get a response:

debian@debian:~/Developer/pulsar/wdio$ curl -X POST http://localhost:4444/session -H "Content-Type: application/json" -d "{\"capabilities\":{\"alwaysMatch\":{\"tauri:options\":{}},\"
firstMatch\":[{}]},\"desiredCapabilities\":{\"tauri:options\":{\"application\":\"../src-tauri/target/release/pulsar\",\"webviewOptions\":{}}}}"
{"value":{"sessionId":"be344bce-7ba2-492a-923f-b39062057565","capabilities":{"browserName":"MiniBrowser","browserVersion":"2.44.2","platformName":"linux","acceptInsecureCerts":false,"strictFileInteractability":false,"setWindowRect":true,"unhandledPromptBehavior":"dismiss and notify","pageLoadStrategy":"normal","proxy":{},"timeouts":{"script":30000,"pageLoad":300000,"implicit":0}}}}

Maybe the script is missing permissions? I need another console?

sjconstantin commented 2 months ago

I am seeing similar behavior

bukowa commented 3 weeks ago

Here are capabilities that work for me without tauri-driver wrapper https://github.com/bukowa/tauri-e2e/blob/605a3ec1a3dbce14105d1a8576a1aa7f6fd34dfd/selenium/javascript/src/selenium/webkitgtk2.ts