From 43dcd8793ee5c9dce7fedd12d0aac0264eebc3ea Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 13 May 2023 03:01:03 +0200 Subject: [PATCH] Add files via upload --- content/press_close_button.json | 3 +++ content/press_close_button.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 content/press_close_button.json create mode 100644 content/press_close_button.py diff --git a/content/press_close_button.json b/content/press_close_button.json new file mode 100644 index 0000000..830d8bc --- /dev/null +++ b/content/press_close_button.json @@ -0,0 +1,3 @@ +{ + "lable_for_close_button": "Schließen" +} \ No newline at end of file diff --git a/content/press_close_button.py b/content/press_close_button.py new file mode 100644 index 0000000..1cdd00c --- /dev/null +++ b/content/press_close_button.py @@ -0,0 +1,19 @@ +import json +import os +from selenium import webdriver +from selenium.webdriver.common.by import By + + +def press_close_button(driver: webdriver.firefox.webdriver.WebDriver): + string_json_path: str = os.path.join("content", "press_close_button.json") + + with open(string_json_path, "r") as file: + string_dict = json.load(file) + + # Press source code button + found_element_list = driver.find_elements(By.TAG_NAME, "a") + for i in found_element_list: + temp_str = str(i.get_dom_attribute("title")) + if temp_str.find(string_dict["lable_for_close_button"]) != -1: + i.click() + break