fix UIWeb Highlight TODO SetAttribute and StyleAttribute

dev-linux
Ivan Maslov 2 years ago
parent 182c551ba7
commit 42fdd6712b

@ -75,20 +75,50 @@ def UIOTextGet(inUIO) -> str:
def UIOAttributeGet(inUIO, inAttributeStr) -> str:
return inUIO.get_attribute(inAttributeStr)
def UIOAttributeStyleGet(inUIO, inAttributeStr) -> str:
return inUIO.get_attribute(inAttributeStr)
#TODO
#def UIOAttributeSet(inUIO, inAttributeStr) -> str:
#def UIOAttributeStyleSet(inUIO, inAttributeStr) -> str:
def UIOClick(inUIO):
inUIO.click()
def UIOSelectorDraw(inUIOSelectorStr: str, inIsFirst:bool=False):
lList = UIOSelectorList(inUIOSelectorStr=inUIOSelectorStr)
def UIOSelectorHighlight(inUIOSelectorStr: str, inIsFirst:bool=False, inDurationSecFloat:float=3.0, inColorStr:str="green"):
global gBrowser
lBrowserRect = gBrowser.get_window_rect()
lViewportHeightInt = PageJSExecute(inJSStr=f"return $(window).height();")
lBrowserRect["y"]= lBrowserRect["y"] + (lBrowserRect["height"] - lViewportHeightInt)
if inIsFirst == True and len(lList)>0: lList = [lList[0]]
for lItem in lList:
lRect = lItem.rect
lBox = Screen.BoxCreate(inTopInt=round(lRect['y']+lBrowserRect['y']), inLeftInt=round(lRect['x']+lBrowserRect['x']), inHeightInt=round(lRect['height']), inWidthInt=round(lRect['width']))
Screen.BoxDraw(inBox=lBox)
if inIsFirst == True:
lJSStr = \
f"var lElementList = document.querySelectorAll(\"{inUIOSelectorStr}\");" \
f"if (lElementList.length>0) {{ lElementList=[lElementList[0]]; }}" \
f"for (var lIndexInt=0; lIndexInt<lElementList.length;lIndexInt++) {{" \
f" lElement=lElementList[lIndexInt];" \
f" lElement.ORPABackupStyleOutline = lElement.style[\"outline\"];" \
f" lElement.style[\"outline\"]=\"2px solid {inColorStr}\";" \
f"}}" \
f"window.ORPAOutlineList = lElementList;"
PageJSExecute(inJSStr=lJSStr)
else:
lJSStr = \
f"var lElementList = document.querySelectorAll(\"{inUIOSelectorStr}\");" \
f"for (var lIndexInt=0; lIndexInt<lElementList.length;lIndexInt++) {{" \
f" lElement=lElementList[lIndexInt];" \
f" lElement.ORPABackupStyleOutline = lElement.style[\"outline\"];" \
f" lElement.style[\"outline\"]=\"2px solid {inColorStr}\";" \
f"}}" \
f"window.ORPAOutlineList = lElementList;"
PageJSExecute(inJSStr=lJSStr)
time.sleep(inDurationSecFloat)
lJSStr = \
f"var lElementList = window.ORPAOutlineList;" \
f"for (var lIndexInt=0; lIndexInt<lElementList.length;lIndexInt++) {{" \
f" lElement=lElementList[lIndexInt];" \
f" lElement.style[\"outline\"]=lElement.ORPABackupStyleOutline;" \
f"}}" \
f"delete window.ORPAOutlineList;"
PageJSExecute(inJSStr=lJSStr)
def UIOSelectorClick(inUIOSelectorStr: str):
PageJSExecute(inJSStr=f"document.querySelector('{inUIOSelectorStr}').click()")
@ -100,13 +130,13 @@ def UIOSelectorWaitAppear(inUIOSelectorStr:str, inWaitSecFloat:float=UIO_WAIT_SE
lResultList = UIOSelectorList(inUIOSelectorStr=inUIOSelectorStr)
if len(lResultList)>0: break
time.sleep(inWaitIntervalSecFloat)
if time.time() - lStartSecFloat > inWaitSecFloat: raise Exception(f"Wait time is over. No element has been appear")
return lResultList
def UIOSelectorWaitDisappear(inUIOSelectorStr:str, inWaitSecFloat:float=UIO_WAIT_SEC_FLOAT, inWaitIntervalSecFloat:float = UIO_WAIT_INTERVAL_SEC_FLOAT):
lStartSecFloat = time.time()
lResultList=[]
while time.time() - lStartSecFloat < inWaitSecFloat:
lResultList = UIOSelectorList(inUIOSelectorStr=inUIOSelectorStr)
if len(lResultList)==0: break
time.sleep(inWaitIntervalSecFloat)
return lResultList
if time.time() - lStartSecFloat > inWaitSecFloat: raise Exception(f"Wait time is over. No element has been disappear")
Loading…
Cancel
Save