Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/rust/tests/output_tests.rs
2885 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
use crate::common::{get_selenium_manager, get_stderr, get_stdout};
19
20
use selenium_manager::logger::{JsonOutput, MinimalJson, DRIVER_PATH};
21
use std::path::Path;
22
23
mod common;
24
25
#[test]
26
fn json_output_test() {
27
let mut cmd = get_selenium_manager();
28
cmd.args(["--browser", "chrome", "--output", "json"])
29
.assert()
30
.success()
31
.code(0);
32
33
let stdout = get_stdout(&mut cmd);
34
35
let json: JsonOutput = serde_json::from_str(&stdout).unwrap();
36
assert!(!json.logs.is_empty());
37
38
let output_code = json.result.code;
39
assert_eq!(output_code, 0);
40
41
let driver = Path::new(&json.result.driver_path);
42
assert!(driver.exists());
43
}
44
45
#[test]
46
fn shell_output_test() {
47
let mut cmd = get_selenium_manager();
48
cmd.args(["--browser", "chrome", "--output", "shell"])
49
.assert()
50
.success()
51
.code(0);
52
53
let stdout = get_stdout(&mut cmd);
54
assert!(stdout.contains(DRIVER_PATH));
55
}
56
57
#[test]
58
fn mixed_output_test() {
59
let mut cmd = get_selenium_manager();
60
cmd.args(["--browser", "chrome", "--output", "mixed"])
61
.assert()
62
.success()
63
.code(0);
64
65
let stdout = get_stdout(&mut cmd);
66
let json: MinimalJson = serde_json::from_str(&stdout).unwrap();
67
let driver = Path::new(&json.driver_path);
68
assert!(driver.exists());
69
70
let stderr = get_stderr(&mut cmd);
71
assert!(!stderr.is_empty());
72
}
73
74