Add files via upload
This commit is contained in:
parent
aecb33c1cf
commit
92318c4fa4
1 changed files with 30 additions and 0 deletions
30
content/set_input_field.py
Normal file
30
content/set_input_field.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
|
||||||
|
|
||||||
|
def set_input_field(
|
||||||
|
driver: webdriver.firefox.webdriver.WebDriver,
|
||||||
|
field_name: str | None,
|
||||||
|
new_text: str | None,
|
||||||
|
):
|
||||||
|
if (field_name is None) or (new_text is None):
|
||||||
|
return
|
||||||
|
|
||||||
|
found_element_list = driver.find_elements(By.TAG_NAME, "input")
|
||||||
|
for i in found_element_list:
|
||||||
|
temp_str = i.get_dom_attribute("data-formengine-input-name")
|
||||||
|
if temp_str is not None:
|
||||||
|
data_lines = temp_str.split("[")
|
||||||
|
if len(data_lines) > 0:
|
||||||
|
data = data_lines[-1]
|
||||||
|
if len(data) > 1:
|
||||||
|
data = data[:-1]
|
||||||
|
else:
|
||||||
|
data = None
|
||||||
|
if data == field_name:
|
||||||
|
while i.get_attribute("value") != new_text:
|
||||||
|
i.clear()
|
||||||
|
i.send_keys(new_text)
|
||||||
|
break
|
||||||
|
|
||||||
|
return
|
Loading…
Reference in a new issue