Browse Source

feat(driver): add `args` to `tauri:options` (#3154)

Lucas Fernandes Nogueira 3 years ago
parent
commit
d0970e3499

+ 5 - 0
.changes/webdriver-args.md

@@ -0,0 +1,5 @@
+---
+"tauri-driver": patch
+---
+
+Add `args` field (array of application CLI arguments) to the `tauri:options` capabilities.

+ 1 - 1
docs/usage/guides/webdriver/example/selenium.md

@@ -148,7 +148,7 @@ before(async function() {
   );
 
   const capabilities = new Capabilities();
-  capabilities.set("tauri:options", { application });
+  capabilities.set("tauri:options", { application, args: ["app", "cli", "args"] });
   capabilities.setBrowserName("wry");
 
   // start the webdriver client

+ 1 - 0
docs/usage/guides/webdriver/example/webdriverio.md

@@ -128,6 +128,7 @@ exports.config = {
       maxInstances: 1,
       "tauri:options": {
         application: "../../target/release/hello-tauri-webdriver",
+        args: ["app", "cli", "args"]
       },
     },
   ],

+ 7 - 2
tooling/webdriver/src/server.rs

@@ -22,6 +22,8 @@ const TAURI_OPTIONS: &str = "tauri:options";
 #[derive(Debug, Deserialize)]
 struct TauriOptions {
   application: PathBuf,
+  #[serde(default)]
+  args: Vec<String>,
 }
 
 impl TauriOptions {
@@ -30,7 +32,7 @@ impl TauriOptions {
     let mut map = Map::new();
     map.insert(
       "webkitgtk:browserOptions".into(),
-      json!({"binary": self.application}),
+      json!({"binary": self.application, "args": self.args}),
     );
     map
   }
@@ -40,7 +42,10 @@ impl TauriOptions {
     let mut map = Map::new();
     map.insert("ms:edgeChromium".into(), json!(true));
     map.insert("browserName".into(), json!("webview2"));
-    map.insert("ms:edgeOptions".into(), json!({"binary": self.application}));
+    map.insert(
+      "ms:edgeOptions".into(),
+      json!({"binary": self.application, "args": self.args}),
+    );
     map
   }
 }