cookie notice seems to be optional

This commit is contained in:
Sebastian Hugentobler 2024-10-01 15:43:11 +02:00
parent d7c865663b
commit 4588d5b434
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
3 changed files with 12 additions and 8 deletions

2
Cargo.lock generated
View File

@ -910,7 +910,7 @@ dependencies = [
[[package]]
name = "nzz-cookie"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"anyhow",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "nzz-cookie"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = { workspace = true }
authors = { workspace = true }

View File

@ -22,7 +22,7 @@ pub async fn run(args: Config, pw: &str) -> Result<()> {
let (stop_tx, stop_rx) = oneshot::channel();
let driver_handle = geckodriver::run(stop_rx).await?;
let driver_args = json!({ "moz:firefoxOptions": {"args": ["-headless"]} });
let driver_args = json!({ "moz:firefoxOptions": {"args": []} });
let client = ClientBuilder::native()
.capabilities(driver_args.as_object().unwrap().clone())
@ -32,12 +32,16 @@ pub async fn run(args: Config, pw: &str) -> Result<()> {
client.goto(LOGIN_URL).await?;
sleep(Duration::from_millis(500)).await;
// Sometimes cookie notice has to bee accepted, not sure when though
if client.find(Locator::Css(".cmpboxbtncustom")).await.is_ok() {
let fu_open_button: Element = element_from_css(&client, ".cmpboxbtncustom").await?;
fu_open_button.click().await?;
let fu_button: Element = element_from_css(&client, ".cmpboxbtn.cmpboxbtnyes.cmpboxbtnyescustomchoices.cmptxt_btn_save").await?;
sleep(Duration::from_millis(500)).await;
fu_button.click().await?;
}
let login_button: Element = element_from_css(&client, ".fup-menu-login-container").await?;