I want to automate Microsoft Edge with rust-headless-chrome without opening any windows.
I started Edge in headless mode with the following Rust code:
use headless_chrome::browser::{Browser, LaunchOptions};
use std::ffi::OsStr;
use std::path::PathBuf;
use std::{thread, time::Duration};
fn main() {
let _browser = Browser::new(LaunchOptions {
headless: true,
path: Some(PathBuf::from(r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")),
args: vec![OsStr::new("--profile-directory=Default")],
..Default::default()
}).unwrap();
thread::sleep(Duration::from_secs(5));
}
Then the following unknown window appeared:
I tried adding the following arguments, which seemed promising to improve the problem, but the results did not change.
--headless
--silent-launch
--disable-logging
fn main() {
let _browser = Browser::new(LaunchOptions {
headless: true,
path: Some(PathBuf::from(r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")),
args: vec![
OsStr::new("--profile-directory=Default"),
OsStr::new("--headless"),
OsStr::new("--silent-launch"),
OsStr::new("--disable-logging")],
..Default::default()
}).unwrap();
thread::sleep(Duration::from_secs(5));
}
My environment is as follows:
rust-headless-chrome
): 1.0.5Is it possible to run Edge with rust-headless-chrome
automatically without opening any windows?
I solved the problem by updating the crate from 1.0.5 to 1.0.6 released on October 23, 2023.
Thank you for your help and suggestions. I will mark this question as resolved.
It seems that there was a change in the update to 1.0.6 that prevents the pop-up screen from appearing when launching the browser.