diff --git a/content/action_chain_drag_and_drop.py b/content/action_chain_drag_and_drop.py new file mode 100644 index 0000000..1e58389 --- /dev/null +++ b/content/action_chain_drag_and_drop.py @@ -0,0 +1,17 @@ +from selenium import webdriver +from selenium.webdriver.common.action_chains import ActionChains + + +def action_chain_drag_and_drop( + driver: webdriver.firefox.webdriver.WebDriver, + x_from: int, + y_from: int, + x_to: int, + y_to: int, +): + actions = ActionChains(driver) + actions.move_by_offset(x_from, y_from) + actions.click_and_hold() + actions.move_by_offset(x_to - x_from, y_to - y_from) + actions.release() + actions.perform() diff --git a/content/get_xy_singlegrid.py b/content/get_xy_singlegrid.py new file mode 100644 index 0000000..722cd80 --- /dev/null +++ b/content/get_xy_singlegrid.py @@ -0,0 +1,22 @@ +from selenium import webdriver +from content.press_wizzard_button import press_wizzard_button +from content.get_list_wizard_sections import get_list_wizard_sections +from content.set_wizard_section import set_wizard_section +from content.get_list_wizard_sections_tools import get_list_wizard_sections_tools + + +def get_xy_singlegrid(driver: webdriver.firefox.webdriver.WebDriver): + press_wizzard_button(driver) + + _, labels = get_list_wizard_sections(driver) + + raster_tools: str = labels[-1] + raster_tool_id_singlegrid: int = 7 + set_wizard_section(driver, raster_tools) + + center_x, center_y, _, _ = get_list_wizard_sections_tools(driver) + + x = center_x[raster_tool_id_singlegrid] + y = center_y[raster_tool_id_singlegrid] + + return x, y diff --git a/content/get_xy_tab.py b/content/get_xy_tab.py new file mode 100644 index 0000000..bd3efeb --- /dev/null +++ b/content/get_xy_tab.py @@ -0,0 +1,23 @@ +from selenium import webdriver +from content.press_wizzard_button import press_wizzard_button +from content.get_list_wizard_sections import get_list_wizard_sections +from content.set_wizard_section import set_wizard_section +from content.get_list_wizard_sections_tools import get_list_wizard_sections_tools +import time + + +def get_xy_tab(driver: webdriver.firefox.webdriver.WebDriver): + press_wizzard_button(driver) + + _, labels = get_list_wizard_sections(driver) + + raster_tools: str = labels[-1] + raster_tool_id_tabs: int = 3 + set_wizard_section(driver, raster_tools) + + center_x, center_y, _, _ = get_list_wizard_sections_tools(driver) + + x = center_x[raster_tool_id_tabs] + y = center_y[raster_tool_id_tabs] + + return x, y diff --git a/content/get_xy_textmedia.py b/content/get_xy_textmedia.py new file mode 100644 index 0000000..338af63 --- /dev/null +++ b/content/get_xy_textmedia.py @@ -0,0 +1,22 @@ +from selenium import webdriver +from content.press_wizzard_button import press_wizzard_button +from content.get_list_wizard_sections import get_list_wizard_sections +from content.set_wizard_section import set_wizard_section +from content.get_list_wizard_sections_tools import get_list_wizard_sections_tools + + +def get_xy_textmedia(driver: webdriver.firefox.webdriver.WebDriver): + press_wizzard_button(driver) + + _, labels = get_list_wizard_sections(driver) + + media_tools: str = labels[-2] + media_tool_id_textmedia: int = 2 + set_wizard_section(driver, media_tools) + + center_x, center_y, _, _ = get_list_wizard_sections_tools(driver) + + x = center_x[media_tool_id_textmedia] + y = center_y[media_tool_id_textmedia] + + return x, y diff --git a/content/press_wizzard_button.py b/content/press_wizzard_button.py index 0af5867..af852a0 100644 --- a/content/press_wizzard_button.py +++ b/content/press_wizzard_button.py @@ -28,15 +28,18 @@ def press_wizzard_button(driver: webdriver.firefox.webdriver.WebDriver): break time.sleep(2) - found_element_list = ["not empty"] # type: ignore + found_element_list: 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() + found_element_list = ["not empty"] # type: ignore break time.sleep(1) + found_element_list = [] found_element_list = driver.find_elements(By.TAG_NAME, "div") for i in found_element_list: diff --git a/content/scroll_down_content_page.json b/content/scroll_down_content_page.json new file mode 100644 index 0000000..47cc818 --- /dev/null +++ b/content/scroll_down_content_page.json @@ -0,0 +1,3 @@ +{ + "Tag": "Deutsch" +} \ No newline at end of file diff --git a/content/scroll_down_content_page.py b/content/scroll_down_content_page.py new file mode 100644 index 0000000..b8af7a6 --- /dev/null +++ b/content/scroll_down_content_page.py @@ -0,0 +1,31 @@ +import selenium +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.actions.wheel_input import ScrollOrigin +from selenium.webdriver.common.action_chains import ActionChains +import os +import json + + +def scroll_down_content_page(driver: webdriver.firefox.webdriver.WebDriver): + string_json_path: str = os.path.join("content", "scroll_down_content_page.json") + + with open(string_json_path, "r") as file: + string_dict = json.load(file) + + height = driver.execute_script("return document.body.scrollHeight") + + found_element_list = driver.find_elements(By.TAG_NAME, "h2") + found_element = None + for element in found_element_list: + if element.text == string_dict["Tag"]: + found_element = element + break + assert found_element is not None + + try: + actions = ActionChains(driver) + actions.scroll_from_origin(ScrollOrigin.from_element(found_element), 0, height) + actions.perform() + except selenium.common.exceptions.MoveTargetOutOfBoundsException: + pass