tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[help] getting a basic example of using Tauri driver and testing invoked commands working

Open stephen-h-d opened this issue 1 year ago • 2 comments

I am trying to test a full demo application with Selenium. By "full" I mean not just the testing as demonstrated by the Hello Tauri app which references this example code but instead something that invokes a command in Rust. I am using the app I made by following this tutorial, and it runs normally with cargo tauri dev --release, but when I try to test it with Mocha and Selenium, the application does not appear to start properly. That is, the binary gets run, and it pops up a Tauri app that says "Could not connect: Connection refused".

I have two questions:

  1. Should it be possible to test a Tauri app with Selenium, including the invoking of Rust commands?
  2. If the answer to question 1 is "yes", do you know what I am doing wrong? I made this repo which contains all the relevant code. I can provide more details if needed.

(I previously opened a support post in the Tauri Apps discord server but haven't gotten a response yet.)

stephen-h-d avatar Sep 13 '23 19:09 stephen-h-d

Do you have the custom-protocol feature enabled on your Tauri project? For me, it worked when I tried changing

[dependencies]
tauri = { version = "1.4", features = [..., "process-command-api"] }
...

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
...

to

[dependencies]
tauri = { version = "1.4", features = [ ..., "custom-protocol"] }
...

[features]
# this is necessary to prevent the Tauri CLI from complaining about the lack of a
# custom-protocol feature during compilation
custom-protocol = []

amosjyng avatar Feb 09 '24 03:02 amosjyng

@amosjyng thanks for the response. I did as you suggested, and it did not work for me. This is what I get:

yarn run v1.22.19
warning ../../../../../package.json: No license field
$ mocha



** (testing_tauri_driver:701189): WARNING **: 12:00:43.093: webkit_settings_set_enable_offline_web_application_cache is deprecated and does nothing.
  Hello Tauri
Asset `index.html` not found; fallback to index.html.html
    1) should generate the correct greeting message


  0 passing (3s)
  1 failing

  1) Hello Tauri
       should generate the correct greeting message:
     NoSuchFrameError: Callback was not called before the unload event.
      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async WebDriver.execute (node_modules/selenium-webdriver/lib/webdriver.js:745:17)
      at async WebDriver.findElements (node_modules/selenium-webdriver/lib/webdriver.js:1089:17)



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The "Asset index.html not found" message seems like an indication of an important issue to me, though I don't know how to address it. What OS are you on? I am on Ubuntu 22.

stephen-h-d avatar Apr 25 '24 16:04 stephen-h-d