Add files via upload
This commit is contained in:
parent
a7afcb4b30
commit
aecb33c1cf
2 changed files with 37 additions and 0 deletions
4
content/set_textarea.json
Normal file
4
content/set_textarea.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"segment_pre": "WYSIWYG-Editor, data_tt_content__",
|
||||
"segment_post": "__bodytext_"
|
||||
}
|
33
content/set_textarea.py
Normal file
33
content/set_textarea.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
|
||||
def set_textarea(
|
||||
driver: webdriver.firefox.webdriver.WebDriver, content_id: int, new_text: str | None
|
||||
):
|
||||
if new_text is None:
|
||||
return
|
||||
|
||||
string_json_path: str = os.path.join("content", "set_textarea.json")
|
||||
|
||||
with open(string_json_path, "r") as file:
|
||||
string_dict = json.load(file)
|
||||
|
||||
target_textarea: str = (
|
||||
f"{string_dict['segment_pre']}{content_id}{string_dict['segment_post']}"
|
||||
)
|
||||
found_element_list = driver.find_elements(By.TAG_NAME, "textarea")
|
||||
|
||||
for i in found_element_list:
|
||||
temp_str = str(i.get_dom_attribute("title"))
|
||||
|
||||
if temp_str.find(target_textarea) != -1:
|
||||
while i.get_attribute("value") != new_text:
|
||||
i.clear()
|
||||
i.send_keys(new_text)
|
||||
break
|
||||
|
||||
return
|
Loading…
Reference in a new issue