Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/rust/tests/grid_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::{assert_output, get_selenium_manager, get_stdout};
19
20
use exitcode::DATAERR;
21
use rstest::rstest;
22
use selenium_manager::logger::JsonOutput;
23
use selenium_manager::{NIGHTLY, SNAPSHOT};
24
use std::path::Path;
25
use std::str;
26
27
mod common;
28
29
#[test]
30
fn grid_latest_test() {
31
let mut cmd = get_selenium_manager();
32
cmd.args(["--grid", "--output", "json"])
33
.assert()
34
.success()
35
.code(0);
36
37
let stdout = get_stdout(&mut cmd);
38
let json: JsonOutput = serde_json::from_str(&stdout).unwrap();
39
assert!(!json.logs.is_empty());
40
41
let output_code = json.result.code;
42
assert_eq!(output_code, 0);
43
44
let jar = Path::new(&json.result.driver_path);
45
assert!(jar.exists());
46
47
let jar_name = jar.file_name().unwrap().to_str().unwrap();
48
assert!(jar_name.contains("selenium-server"));
49
}
50
51
#[rstest]
52
#[case("4.8.0")]
53
#[case("4.9.0")]
54
#[case("4.10.0")]
55
#[case("nightly")]
56
fn grid_version_test(#[case] grid_version: &str) {
57
let mut cmd = get_selenium_manager();
58
cmd.args(["--grid", grid_version, "--output", "json"])
59
.assert()
60
.success()
61
.code(0);
62
63
let stdout = get_stdout(&mut cmd);
64
65
let json: JsonOutput = serde_json::from_str(&stdout).unwrap();
66
let jar = Path::new(&json.result.driver_path);
67
let jar_name = jar.file_name().unwrap().to_str().unwrap();
68
let version_label = if grid_version.eq_ignore_ascii_case(NIGHTLY) {
69
SNAPSHOT
70
} else {
71
grid_version
72
};
73
assert!(jar_name.contains(version_label));
74
}
75
76
#[rstest]
77
#[case("bad-version")]
78
#[case("99.99.99")]
79
fn grid_error_test(#[case] grid_version: &str) {
80
let mut cmd = get_selenium_manager();
81
let result = cmd.args(["--grid", grid_version]).assert().try_success();
82
83
assert_output(&mut cmd, result, vec!["There was an error"], DATAERR);
84
}
85
86