Open richardeschloss opened 1 year ago
Had similar issues, finally got it working on Windows 11 via the Selenium approach.
I also converted my setup to TypeScript. For Reference:
test/test.ts
import os from "os";
import path from "path";
import { expect } from "chai";
import { spawn, spawnSync } from "child_process";
import { Builder, By, Capabilities } from "selenium-webdriver";
import type { WebDriver } from "selenium-webdriver";
import type { ChildProcessByStdio } from "child_process";
let port = 4454;
let nativePort = port + 1;
const isRelease = false;
// create the path to the expected application binary
const application = path.resolve(
__dirname,
"..",
"..",
"..",
"target",
isRelease ? "release" : "debug",
"hello_tauri.exe"
);
console.log(application);
// keep track of the webdriver instance we create
let driver: WebDriver;
// keep track of the tauri-driver process we start
let tauriDriver: ChildProcessByStdio<any, null, null>;
before(async function () {
// set timeout to 2 minutes to allow the program to build if it needs to
this.timeout(120000);
// ensure the program has been built
spawnSync("cargo", ["build", isRelease ? "--release" : "--debug"]);
// start tauri-driver
tauriDriver = spawn(
path.resolve(os.homedir(), ".cargo", "bin", "tauri-driver"),
[
"--port",
port.toString(),
"--native-driver",
"C:/path/to/msedgedriver.exe",
"--native-port",
nativePort.toString(),
],
{ stdio: [null, process.stdout, process.stderr] }
);
const capabilities = new Capabilities();
capabilities.set("tauri:options", { application });
capabilities.setBrowserName("wry");
// start the webdriver client
driver = await new Builder()
.withCapabilities(capabilities)
.usingServer(`http://localhost:${port.toString()}/`)
.build();
});
after(async function () {
// stop the webdriver session
await driver!.quit();
// kill the tauri-driver process
tauriDriver!.kill();
});
describe("Hello Tauri", () => {
it("should be cordial", async () => {
const text = await driver!.findElement(By.css("body > h1")).getText();
expect(text).to.match(/^[hH]ello/);
});
it("should be excited", async () => {
const text = await driver!.findElement(By.css("body > h1")).getText();
expect(text).to.match(/!$/);
});
});
And ran with ts-mocha
ts-mocha -p ./tsconfig.json test/*.ts
package.json
{
"name": "selenium",
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"scripts": {
"test": "mocha",
"test-ts": "ts-mocha -p ./tsconfig.json test/*.ts",
"format": "prettier --write \"./**/*.js\""
},
"dependencies": {
"@types/chai": "^4.3.5",
"@types/selenium-webdriver": "^4.1.15",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"selenium-webdriver": "^4.9.2",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
}
}
Thanks for the port
, now seems like this is also required: webviewOptions
because of cannot parse capability: ms:edgeOptions
.
capabilities.set('tauri:options', {
application: application,
webviewOptions: {},
})
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.
What might I be missing?Here's my updated config: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.