From 6af89e8f92c440b09ffad93cf81aa58f254b3b10 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 13 May 2023 21:25:27 +0200 Subject: [PATCH] Add files via upload --- content/press_wizzard_button.json | 5 ++++ content/press_wizzard_button.py | 45 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 content/press_wizzard_button.json create mode 100644 content/press_wizzard_button.py diff --git a/content/press_wizzard_button.json b/content/press_wizzard_button.json new file mode 100644 index 0000000..a3e3d46 --- /dev/null +++ b/content/press_wizzard_button.json @@ -0,0 +1,5 @@ +{ + "wizard_button": "Toggle Drag In Wizard", + "wizard_button_close": "t3js-modal-close close", + "wizard_open": "new-element-drag-in-wizard" +} \ No newline at end of file diff --git a/content/press_wizzard_button.py b/content/press_wizzard_button.py new file mode 100644 index 0000000..0af5867 --- /dev/null +++ b/content/press_wizzard_button.py @@ -0,0 +1,45 @@ +import json +import os +from selenium import webdriver +from selenium.webdriver.common.by import By + +import time + + +def press_wizzard_button(driver: webdriver.firefox.webdriver.WebDriver): + string_json_path: str = os.path.join("content", "press_wizzard_button.json") + + with open(string_json_path, "r") as file: + string_dict = json.load(file) + + wizard_open: bool = False + found_element_list = driver.find_elements(By.TAG_NAME, "div") + for i in found_element_list: + if str(i.get_dom_attribute("id")) == string_dict["wizard_open"]: + wizard_open = True + break + + while wizard_open is False: + 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["wizard_button"]) != -1: + i.click() + break + + time.sleep(2) + found_element_list = ["not empty"] # type: ignore + while len(found_element_list) > 0: + found_element_list = driver.find_elements(By.TAG_NAME, "button") + for i in found_element_list: + temp_str = str(i.get_dom_attribute("class")) + if temp_str.find(string_dict["wizard_button_close"]) != -1: + i.click() + break + time.sleep(1) + + found_element_list = driver.find_elements(By.TAG_NAME, "div") + for i in found_element_list: + if str(i.get_dom_attribute("id")) == string_dict["wizard_open"]: + wizard_open = True + break