From 42fdd6712bf84d2e367a61b647fa830658eb52dc Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sun, 17 Jul 2022 10:41:31 +0300 Subject: [PATCH] fix UIWeb Highlight TODO SetAttribute and StyleAttribute --- Sources/pyOpenRPA/Robot/UIWeb.py | 54 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/Sources/pyOpenRPA/Robot/UIWeb.py b/Sources/pyOpenRPA/Robot/UIWeb.py index 33f6efec..ca4692b1 100644 --- a/Sources/pyOpenRPA/Robot/UIWeb.py +++ b/Sources/pyOpenRPA/Robot/UIWeb.py @@ -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; lIndexInt0: 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") \ No newline at end of file