appium_client/commands/
strings.rs1use std::collections::HashMap;
3use async_trait::async_trait;
4use fantoccini::error::CmdError;
5use http::Method;
6use serde_json::json;
7use crate::{AndroidClient, AppiumClientTrait, IOSClient};
8use crate::commands::AppiumCommand;
9
10#[async_trait]
12pub trait HasAppStrings : AppiumClientTrait {
13 async fn app_strings_default_lang(&self) -> Result<HashMap<String, String>, CmdError> {
14 let value = self.issue_cmd(AppiumCommand::Custom(
15 Method::POST,
16 "appium/app/strings".to_string(),
17 None
18 )).await?;
19
20 Ok(serde_json::from_value(value)?)
21 }
22
23 async fn app_strings(&self, lang: &str) -> Result<HashMap<String, String>, CmdError> {
24 let value = self.issue_cmd(AppiumCommand::Custom(
25 Method::POST,
26 "appium/app/strings".to_string(),
27 Some(json!({
28 "language": lang
29 }))
30 )).await?;
31
32 Ok(serde_json::from_value(value)?)
33 }
34
35 async fn app_strings_from_file(&self, lang: &str, file: &str) -> Result<HashMap<String, String>, CmdError> {
36 let value = self.issue_cmd(AppiumCommand::Custom(
37 Method::POST,
38 "appium/app/strings".to_string(),
39 Some(json!({
40 "language": lang,
41 "stringFile": file
42 }))
43 )).await?;
44
45 Ok(serde_json::from_value(value)?)
46 }
47}
48
49#[async_trait]
50impl HasAppStrings for AndroidClient {}
51
52#[async_trait]
53impl HasAppStrings for IOSClient {}