@@ -751,7 +751,7 @@ def execute_javascript(data_set):
751751
752752# Method to click on element; step data passed on by the user
753753@logger
754- def Click_Element (data_set ):
754+ def Click_Element (data_set , retry = 0 ):
755755 """ Click using element or location """
756756
757757 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
@@ -815,27 +815,16 @@ def Click_Element(data_set):
815815 errMsg = "Could not select/click your element."
816816 return CommonUtil .Exception_Handler (sys .exc_info (), None , errMsg )
817817 except StaleElementReferenceException :
818- try :
819- CommonUtil .ExecLog (
820- sModuleInfo ,
821- "javascript for the element is not fully loaded so trying again after 2 seconds" ,
822- 2
823- )
824- time .sleep (2.0 ) # wait 2 sec and try again
825- if use_js :
826- selenium_driver .execute_script ("arguments[0].click();" , Element )
827- else :
828- Element .click ()
829- CommonUtil .TakeScreenShot (sModuleInfo )
830- CommonUtil .ExecLog (sModuleInfo , "Successfully clicked the element" , 1 )
831- return "passed"
832- except :
833- element_attributes = Element .get_attribute ("outerHTML" )
818+ if retry == 5 :
834819 CommonUtil .ExecLog (
835- sModuleInfo , "Element Attributes: %s" % ( element_attributes ) , 3
820+ sModuleInfo , "Could not perform click because javascript of the element is not fully loaded" , 3
836821 )
837- errMsg = "Could not select/click your element."
838- return CommonUtil .Exception_Handler (sys .exc_info (), None , errMsg )
822+ return "failed"
823+ CommonUtil .ExecLog (
824+ "" , "Javascript of the element is not fully loaded. Trying again after 1 second delay" , 2
825+ )
826+ time .sleep (1 )
827+ return Click_Element (data_set , retry + 1 )
839828
840829 except Exception :
841830 element_attributes = Element .get_attribute ("outerHTML" )
0 commit comments