From 39f152bfb58bd478cc974a5ba305d1b0c688c4a9 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 13 May 2023 02:49:03 +0200 Subject: [PATCH] Add files via upload --- content/change_url.py | 16 ++++++++++++++++ content/press_sourcecode_button.json | 3 +++ content/press_sourcecode_button.py | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 content/change_url.py create mode 100644 content/press_sourcecode_button.json create mode 100644 content/press_sourcecode_button.py diff --git a/content/change_url.py b/content/change_url.py new file mode 100644 index 0000000..ac1d1b4 --- /dev/null +++ b/content/change_url.py @@ -0,0 +1,16 @@ +import time +from selenium import webdriver + + +def change_url(driver: webdriver.firefox.webdriver.WebDriver, new_url: str): + # Login + driver.get(new_url) + print_new_line: bool = False + while driver.current_url != new_url: + print(".", end="") + time.sleep(1) + print_new_line = True + + if print_new_line is True: + print() + time.sleep(1) diff --git a/content/press_sourcecode_button.json b/content/press_sourcecode_button.json new file mode 100644 index 0000000..0ff4979 --- /dev/null +++ b/content/press_sourcecode_button.json @@ -0,0 +1,3 @@ +{ + "lable_for_source_code_button": "Quellcode" +} \ No newline at end of file diff --git a/content/press_sourcecode_button.py b/content/press_sourcecode_button.py new file mode 100644 index 0000000..f46dc26 --- /dev/null +++ b/content/press_sourcecode_button.py @@ -0,0 +1,19 @@ +import json +import os +from selenium import webdriver +from selenium.webdriver.common.by import By + + +def press_sourcecode_button(driver: webdriver.firefox.webdriver.WebDriver): + string_json_path: str = os.path.join("content", "press_sourcecode_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_source_code_button"]) != -1: + i.click() + break