Add files via upload
This commit is contained in:
parent
2f7dfc219f
commit
45a951e16b
7 changed files with 122 additions and 1 deletions
17
content/action_chain_drag_and_drop.py
Normal file
17
content/action_chain_drag_and_drop.py
Normal file
|
@ -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()
|
22
content/get_xy_singlegrid.py
Normal file
22
content/get_xy_singlegrid.py
Normal file
|
@ -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
|
23
content/get_xy_tab.py
Normal file
23
content/get_xy_tab.py
Normal file
|
@ -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
|
22
content/get_xy_textmedia.py
Normal file
22
content/get_xy_textmedia.py
Normal file
|
@ -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
|
|
@ -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:
|
||||
|
|
3
content/scroll_down_content_page.json
Normal file
3
content/scroll_down_content_page.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"Tag": "Deutsch"
|
||||
}
|
31
content/scroll_down_content_page.py
Normal file
31
content/scroll_down_content_page.py
Normal file
|
@ -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
|
Loading…
Reference in a new issue