Add files via upload
This commit is contained in:
parent
6af89e8f92
commit
aee49bc326
4 changed files with 89 additions and 0 deletions
4
content/get_list_wizard_sections.json
Normal file
4
content/get_list_wizard_sections.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"tabmenu-item": "t3js-tabmenu-item",
|
||||||
|
"active-item": "active"
|
||||||
|
}
|
25
content/get_list_wizard_sections.py
Normal file
25
content/get_list_wizard_sections.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
|
||||||
|
def get_list_wizard_sections(
|
||||||
|
driver: webdriver.firefox.webdriver.WebDriver,
|
||||||
|
) -> tuple[int | None, list[str]]:
|
||||||
|
string_json_path: str = os.path.join("content", "get_list_wizard_sections.json")
|
||||||
|
|
||||||
|
with open(string_json_path, "r") as file:
|
||||||
|
string_dict = json.load(file)
|
||||||
|
|
||||||
|
found_element_list = driver.find_elements(By.TAG_NAME, "li")
|
||||||
|
active_element: None | int = None
|
||||||
|
labels: list[str] = []
|
||||||
|
|
||||||
|
for i in found_element_list:
|
||||||
|
if str(i.get_dom_attribute("class")).startswith(string_dict["tabmenu-item"]):
|
||||||
|
if str(i.get_dom_attribute("class")).find(string_dict["active-item"]) != -1:
|
||||||
|
active_element = len(labels)
|
||||||
|
labels.append(i.text)
|
||||||
|
|
||||||
|
return active_element, labels
|
36
content/get_list_wizard_sections_tools.py
Normal file
36
content/get_list_wizard_sections_tools.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
|
||||||
|
def get_list_wizard_sections_tools(
|
||||||
|
driver: webdriver.firefox.webdriver.WebDriver,
|
||||||
|
) -> tuple[list[int], list[int], list[str], list[str]]:
|
||||||
|
center_x: list[int] = []
|
||||||
|
center_y: list[int] = []
|
||||||
|
content_name: list[str] = []
|
||||||
|
image_name: list[str] = []
|
||||||
|
|
||||||
|
found_element_list = driver.find_elements(By.TAG_NAME, "div")
|
||||||
|
for i in found_element_list:
|
||||||
|
if str(i.get_dom_attribute("class")).startswith("tab-pane active"):
|
||||||
|
found_child_list = i.find_elements(By.TAG_NAME, "span")
|
||||||
|
|
||||||
|
for j in found_child_list:
|
||||||
|
if str(j.get_dom_attribute("class")).find("t3js-icon") != -1:
|
||||||
|
content = str(j.get_dom_attribute("class"))
|
||||||
|
content = content.split(" ")[-1]
|
||||||
|
content_name.append(content)
|
||||||
|
|
||||||
|
found_img_list = j.find_elements(By.TAG_NAME, "img")
|
||||||
|
assert len(found_img_list) == 1
|
||||||
|
found_img = found_img_list[0]
|
||||||
|
src_info = found_img.get_dom_attribute("src")
|
||||||
|
src_info = src_info.split("/")[-1]
|
||||||
|
image_name.append(src_info)
|
||||||
|
|
||||||
|
x = found_img.location["x"] + found_img.size["width"] // 2
|
||||||
|
y = found_img.location["y"] + found_img.size["height"] // 2
|
||||||
|
center_x.append(int(x))
|
||||||
|
center_y.append(int(y))
|
||||||
|
|
||||||
|
return center_x, center_y, content_name, image_name
|
24
content/set_wizard_section.py
Normal file
24
content/set_wizard_section.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
from content.get_list_wizard_sections import get_list_wizard_sections
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def set_wizard_section(
|
||||||
|
driver: webdriver.firefox.webdriver.WebDriver, target: str | None
|
||||||
|
):
|
||||||
|
if target is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
active_element, labels = get_list_wizard_sections(driver)
|
||||||
|
while labels[active_element] != target:
|
||||||
|
found_element_list = driver.find_elements(By.TAG_NAME, "a")
|
||||||
|
for i in found_element_list:
|
||||||
|
if i.text == target:
|
||||||
|
i.click()
|
||||||
|
time.sleep(1)
|
||||||
|
break
|
||||||
|
|
||||||
|
active_element, labels = get_list_wizard_sections(driver)
|
||||||
|
|
||||||
|
return
|
Loading…
Reference in a new issue