Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/rust/tests/config_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_browser, assert_driver, get_selenium_manager, get_stdout};
19
20
use rstest::rstest;
21
22
use std::fs::File;
23
use std::io::{BufWriter, Write};
24
use tempfile::Builder;
25
26
mod common;
27
28
#[rstest]
29
#[case("chrome")]
30
#[case("firefox")]
31
#[case("edge")]
32
fn config_test(#[case] browser_name: String) {
33
let tmp_dir = Builder::new().prefix("sm-config-test").tempdir().unwrap();
34
let config_path = tmp_dir.path().join("se-config.toml");
35
let config_file = File::create(config_path.as_path()).unwrap();
36
let mut writer = BufWriter::new(config_file);
37
writer
38
.write_all(format!(r#"browser="{}""#, browser_name).as_bytes())
39
.unwrap();
40
writer.flush().unwrap();
41
42
let mut cmd = get_selenium_manager();
43
cmd.args([
44
"--output",
45
"json",
46
"--debug",
47
"--cache-path",
48
tmp_dir.path().to_str().unwrap(),
49
])
50
.assert()
51
.success()
52
.code(0);
53
54
let stdout = get_stdout(&mut cmd);
55
56
assert!(!stdout.contains("WARN") && !stdout.contains("ERROR"));
57
assert_driver(&mut cmd);
58
assert_browser(&mut cmd);
59
}
60
61