Git Product home page Git Product logo

hello_tauri's Introduction

Hello, Tauri! WebDriver

Absolute minimal hello world for Tauri. This exists so that I can independently experiment with things surrounding the resulting application. For now, this covers:

Screenshot

I did say absolutely minimal.

screenshot

Binary Sizes

The following binaries have had been built with --release and have had strip --strip-all run on them.

Configuration Size (MiB) Size (bytes)
stable 3.1MiB 3,162,136
build-std 2.8MiB 2,859,032
build-std + build-std-features 2.5MiB 2,539,544

Linux dev 5.12.5-arch1-1 #1 SMP PREEMPT Wed, 19 May 2021 10:32:40 +0000 x86_64 GNU/Linux btw

WebDriver testing in GitHub Actions

You will need to read the code for more information about this, until tauri-driver become pre-alpha with docs.

Check the GitHub Action workflow file for the requirements on the CI and the steps taken in order to build and then test the application. Also see the webdriver/ dir for the actual code that runs the WebDriver tests.

You can click the badge at the top of this readme to check the latest WebDriver test results.

hello_tauri's People

Contributors

chippers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hello_tauri's Issues

Not working on latest wdio

Hey, thanks for the demo repo! I think, at least as-is, it doesn't work with the latest versions of wdio and associated dependencies. If I change:

diff --git a/webdriver/package.json b/webdriver/package.json
index 609fbbc..9231a90 100644
--- a/webdriver/package.json
+++ b/webdriver/package.json
@@ -9,7 +9,7 @@
     "webdriverio"
   ],
   "dependencies": {
-    "@wdio/cli": "^7.7.3",
+    "@wdio/cli": "^8.14.3",
     "prettier": "^2.3.0"
   }
 }
diff --git a/webdriver/webdriverio/package.json b/webdriver/webdriverio/package.json
index 853d968..df91cf9 100644
--- a/webdriver/webdriverio/package.json
+++ b/webdriver/webdriverio/package.json
@@ -8,8 +8,8 @@
     "format": "prettier --write \"./**/*.js\""
   },
   "devDependencies": {
-    "@wdio/local-runner": "^7.7.3",
-    "@wdio/mocha-framework": "^7.7.3",
-    "@wdio/spec-reporter": "^7.7.3"
+    "@wdio/local-runner": "^8.14.3",
+    "@wdio/mocha-framework": "^8.14.0",
+    "@wdio/spec-reporter": "^8.14.0"
   }
 }

and run yarn install, then I get this as output:

[0-0] 2023-08-11T04:33:32.841Z ERROR @wdio/runner: Error: No "browserName" defined in capabilities nor hostname or port found!
[0-0] If you like to run a mobile session with Appium, make sure to set "hostname" and "port" in your WebdriverIO options. If you like to run a local browser session make sure to pick from one of the following browser names: chrome,googlechrome,chromium,chromium-browser,firefox,ff,mozilla,mozilla firefox,edge,microsoftedge,msedge,safari,safari technology preview

Even if I stick with v7 of wdio, I find that I cannot interact with the UI. For example, if I try to click the header:

diff --git a/webdriver/webdriverio/test/specs/example.e2e.js b/webdriver/webdriverio/test/specs/example.e2e.js
index b795b7f..efc3a6a 100644
--- a/webdriver/webdriverio/test/specs/example.e2e.js
+++ b/webdriver/webdriverio/test/specs/example.e2e.js
@@ -14,6 +14,7 @@ function luma(hex) {
 describe("Hello Tauri", () => {
   it("should be cordial", async () => {
     const header = await $("body > h1");
+    await header.click();
     const text = await header.getText();
     expect(text).toMatch(/^[hH]ello/);
   });

then I get

[0-0] 2023-08-11T06:49:05.047Z INFO webdriver: COMMAND findElement("css selector", "body > h1")
[0-0] 2023-08-11T06:49:05.047Z INFO webdriver: [POST] http://localhost:4444/session/a1e2795a-f62e-4259-a33f-df8cdfbe133f/element
[0-0] 2023-08-11T06:49:05.047Z INFO webdriver: DATA { using: 'css selector', value: 'body > h1' }
[0-0] 2023-08-11T06:49:05.122Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': 'node-FE6DB46D-13E4-49D0-AE79-DE8C06B344C6'
[0-0] }
[0-0] 2023-08-11T06:49:05.127Z INFO webdriver: COMMAND elementClick("node-FE6DB46D-13E4-49D0-AE79-DE8C06B344C6")
[0-0] 2023-08-11T06:49:05.128Z INFO webdriver: [POST] http://localhost:4444/session/a1e2795a-f62e-4259-a33f-df8cdfbe133f/element/node-FE6DB46D-13E4-49D0-AE79-DE8C06B344C6/click
[0-0] 2023-08-11T06:49:05.135Z WARN webdriver: Request failed with status 500 due to unknown error
...
[0-0] 2023-08-11T06:49:05.192Z ERROR webdriver: Request failed with status 500 due to unsupported operation: unknown error
[0-0] unsupported operation in "Hello Tauri.should be cordial"
unsupported operation: unknown error
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
...
[wry 0.24.3 linux #0-0] 1) Hello Tauri should be cordial
[wry 0.24.3 linux #0-0] unknown error
[wry 0.24.3 linux #0-0] unsupported operation: unknown error
[wry 0.24.3 linux #0-0]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Just in case it was an issue with clicking H1 elements, I tried creating a button and clicking that instead. It could find the button, but failed to click it for presumably the same unknown reason. Manually POSTing the WebdriverIO request gives me this:

$ curl -X POST http://localhost:4444/session/9737f22a-539d-4f14-a911-eeba1e20056b/element/node-AC386962-86F0-46BD-BA8E-06E3914
81B9F/text
{"value":{"error":"unknown command","message":"Unknown command: /session/9737f22a-539d-4f14-a911-eeba1e20056b/element/node-AC386962-86F0-46BD-BA8E-06E391481B9F/text","stacktrace":""}}

compile error because of missing `icons/icon.ico` on windows machine

Hello

I tried to compile this example but did not have luck. I have on two different windows machines the same error:

error: failed to run custom build command for `hello_tauri v0.1.0 (C:\Users\Daimonion\source\tauri-example)`

Caused by:
  process didn't exit successfully: `C:\Users\Daimonion\source\tauri-example\target\debug\build\hello_tauri-eec1dd299d27f27b\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-changed=dist
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=desktop
  cargo:rustc-cfg=dev
  `icons/icon.ico` not found; required for generating a Windows Resource file during tauri-build
warning: build failed, waiting for other jobs to finish...

I don't know what is the problem here and how to solve it.
Is there anything I can do to solve this error?
I tried stable rust toolchain and nightly toolchain

Broken example for WebDriverIO

Hi I have been following along with the example from https://tauri.app/v1/guides/testing/webdriver/example/webdriverio and I am able to run the application locally, but when it comes to running the WebDriverIO tests on Windows it failed. Here is my log

C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\webdriverio>npm test

> [email protected] test
> wdio run wdio.conf.js


Execution of 1 workers started at 2024-03-03T23:29:30.670Z

2024-03-03T23:29:30.680Z INFO @wdio/cli:launcher: Run onPrepare hook
2024-03-03T23:29:30.971Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2024-03-03T23:29:30.972Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
[0-0] 2024-03-03T23:29:31.369Z INFO @wdio/local-runner: Run worker command: run
[0-0] Starting Microsoft Edge WebDriver 122.0.2365.66 (ab363614b8f04700fdbbc3d9d7f9deca8102a1c4) on port 4445
[0-0] To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver
[0-0]
[0-0] Only local connections are allowed.
[0-0] Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
[0-0]
[0-0] RUNNING in undefined - C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\webdriverio\test\specs\example.e2e.js
[0-0] 2024-03-03T23:29:31.492Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2024-03-03T23:29:31.521Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-03-03T23:29:31.521Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': { application: '../../target/release/hello_tauri' }
[0-0]   }
[0-0] }
[0-0] 2024-03-03T23:29:31.546Z WARN webdriver: Request failed with status 400 due to invalid argument: cannot parse capability: ms:edgeOptions
[0-0] from invalid argument: cannot parse webviewOptions
[0-0] from invalid argument: must be a dictionary
[0-0] 2024-03-03T23:29:31.546Z INFO webdriver: Retrying 1/3
[0-0] 2024-03-03T23:29:31.546Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-03-03T23:29:31.546Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': { application: '../../target/release/hello_tauri' }
[0-0]   }
[0-0] }
[0-0] 2024-03-03T23:29:31.548Z WARN webdriver: Request failed with status 400 due to invalid argument: cannot parse capability: ms:edgeOptions
[0-0] from invalid argument: cannot parse webviewOptions
[0-0] from invalid argument: must be a dictionary
[0-0] 2024-03-03T23:29:31.549Z INFO webdriver: Retrying 2/3
[0-0] 2024-03-03T23:29:31.549Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-03-03T23:29:31.549Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': { application: '../../target/release/hello_tauri' }
[0-0]   }
[0-0] }
[0-0] 2024-03-03T23:29:31.550Z WARN webdriver: Request failed with status 400 due to invalid argument: cannot parse capability: ms:edgeOptions
[0-0] from invalid argument: cannot parse webviewOptions
[0-0] from invalid argument: must be a dictionary
[0-0] 2024-03-03T23:29:31.551Z INFO webdriver: Retrying 3/3
[0-0] 2024-03-03T23:29:31.551Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2024-03-03T23:29:31.551Z INFO webdriver: DATA {
[0-0]   capabilities: { alwaysMatch: { 'tauri:options': [Object] }, firstMatch: [ {} ] },
[0-0]   desiredCapabilities: {
[0-0]     'tauri:options': { application: '../../target/release/hello_tauri' }
[0-0]   }
[0-0] }
[0-0] 2024-03-03T23:29:31.552Z ERROR webdriver: Request failed with status 400 due to invalid argument: invalid argument: cannot parse capability: ms:edgeOptions
[0-0] from invalid argument: cannot parse webviewOptions
[0-0] from invalid argument: must be a dictionary
[0-0] 2024-03-03T23:29:31.552Z ERROR webdriver:         GetHandleVerifier [0x00007FF6D06EB852+63538]
[0-0]   Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF6D066F6D2+238290]
[0-0]   (No symbol) [0x00007FF6D04A3407]
[0-0]   (No symbol) [0x00007FF6D04CFDE1]
[0-0]   (No symbol) [0x00007FF6D04CA548]
[0-0]   (No symbol) [0x00007FF6D048EF50]
[0-0]   (No symbol) [0x00007FF6D04C87ED]
[0-0]   (No symbol) [0x00007FF6D04CA548]
[0-0]   (No symbol) [0x00007FF6D048EF50]
[0-0]   (No symbol) [0x00007FF6D04C51DF]
[0-0]   (No symbol) [0x00007FF6D0510F69]
[0-0]   (No symbol) [0x00007FF6D0510B83]
[0-0]   (No symbol) [0x00007FF6D0512251]
[0-0]   (No symbol) [0x00007FF6D0508A83]
[0-0]   (No symbol) [0x00007FF6D04DE55E]
[0-0]   (No symbol) [0x00007FF6D04DD71C]
[0-0]   (No symbol) [0x00007FF6D04DE111]
[0-0]   Microsoft::Applications::Events::EventProperty::to_string [0x00007FF6D08C1D3C+1102764]
[0-0]   (No symbol) [0x00007FF6D05525F6]
[0-0]   (No symbol) [0x00007FF6D05E3DAC]
[0-0]   (No symbol) [0x00007FF6D05DBDA8]
[0-0]   Microsoft::Applications::Events::EventProperty::to_string [0x00007FF6D08C0C85+1098485]
[0-0]   Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF6D0679E91+281233]
[0-0]   Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF6D0674614+258580]
[0-0]   Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF6D067474F+258895]
[0-0]   Microsoft::Applications::Events::ILogConfiguration::operator* [0x00007FF6D0668F21+211745]
[0-0]   BaseThreadInitThunk [0x00007FFA5255257D+29]
[0-0]   RtlUserThreadStart [0x00007FFA53BEAA58+40]
[0-0]
[0-0] 2024-03-03T23:29:31.553Z ERROR @wdio/runner: Error: Failed to create session.
[0-0] invalid argument: cannot parse capability: ms:edgeOptions
[0-0] from invalid argument: cannot parse webviewOptions
[0-0] from invalid argument: must be a dictionary
[0-0]     at Object.startWebDriverSession (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\webdriver\build\utils.js:68:15)
[0-0]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[0-0]     at async WebDriver.newSession (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\webdriver\build\index.js:58:45)
[0-0]     at async Object.remote (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\@wdio\runner\node_modules\webdriverio\build\index.js:67:22)
[0-0]     at async Runner._startSession (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\@wdio\runner\build\index.js:216:56)
[0-0]     at async Runner._initSession (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\@wdio\runner\build\index.js:172:25)
[0-0]     at async Runner.run (C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\node_modules\@wdio\runner\build\index.js:87:19)
[0-0] FAILED in undefined - C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\webdriverio\test\specs\example.e2e.js
2024-03-03T23:29:31.684Z INFO @wdio/cli:launcher: Run onComplete hook

Spec Files:      0 passed, 1 failed, 1 total (100% completed) in 00:00:01

2024-03-03T23:29:31.685Z INFO @wdio/local-runner: Shutting down spawned worker
2024-03-03T23:29:31.939Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2024-03-03T23:29:31.940Z INFO @wdio/local-runner: shutting down
npm ERR! Lifecycle script `test` failed with error:
npm ERR! Error: command failed
npm ERR!   in workspace: [email protected]
npm ERR!   at location: C:\Users\NAME\Documents\Code\NextJS\hello_tauri\webdriver\webdriverio

It seems like the main issue is this line here: Request failed with status 400 due to invalid argument: cannot parse capability: ms:edgeOptions

I am running Edge web driver 122.0.2365.66 x64 for Windows.

My package.json looks like this:

{
  "name": "webdriverio",
  "version": "1.0.0",
  "license": "Apache-2.0",
  "private": true,
  "scripts": {
    "test": "wdio run wdio.conf.js",
    "format": "prettier --write \"./**/*.js\""
  },
  "devDependencies": {
    "@wdio/local-runner": "^7.7.3",
    "@wdio/mocha-framework": "^7.7.3",
    "@wdio/spec-reporter": "^7.7.3"
  }
}

Has anyone got this working in 2024?

Windows 11 support suggestions

Hi,

I appreciate your efforts in putting this repo together. I tried to run the webdriverio example on Windows 11 and could not get it running out of the box, but I think I got close to getting something working.

  1. I had to create an "icons/icon.ico" file
  2. I had to supply "--native-driver", "msedgedriver.exe" as arguments to tauri-driver.
  3. When that tauri-driver runs, it defaults to port 4445 (so I had to update the port in the wdio config to that)
  4. After finally building the tauri app successfully, the webdriver launches a blank Microsoft Edge window, and while the window says "Microsoft Edge is being controlled by automation software" it never seems to load the actual Tauri app.

What might I be missing?
Here's my updated config:

exports.config = {
  port: 4444, <-- needed
  specs: ["./test/specs/**/*.js"],
  maxInstances: 1,
  capabilities: [
    {
      maxInstances: 1,
      "tauri:options": {
        application: "../../target/release/hello_tauri.exe", <-- the ".exe" needed for windows
      },
    },
  ],
  reporters: ["spec"],
  framework: "mocha",
  mochaOpts: {
    ui: "bdd",
    timeout: 60000,
  },

  // ensure the rust project is built since we expect this binary to exist for the webdriver sessions
  onPrepare: () => spawnSync("cargo", ["build", "--release"]),

  // ensure we are running `tauri-driver` before the session starts so that we can proxy the webdriver requests
  beforeSession: () =>
    (tauriDriver = spawn(
      path.resolve(os.homedir(), ".cargo", "bin", "tauri-driver"),
      // ['--native-driver', './msedgedriver.exe'], // <-- Key issue: would start just a blank MSedge window, not the app. Tauri driver was only respecting the PATH env var, not the CLI option. 
      { stdio: [null, process.stdout, process.stderr] }
    )),

  // clean up the `tauri-driver` process we spawned at the start of the session
  afterSession: () => tauriDriver.kill(),
};

I know it sounds trivial, but the CLI help says I can use the "--native-driver" param but only the ENV var was working completely.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.