@@ -766,6 +766,43 @@ def process_command(self, command):
766766 self .devtools .type_text (command ['target' ])
767767 elif command ['command' ] == 'keypress' :
768768 self .devtools .keypress (command ['target' ])
769+ elif command ['command' ] == 'mouseClick' :
770+ if 'target' in command :
771+ target = command ['target' ]
772+ separator = target .find ('=' )
773+ if separator == - 1 :
774+ separator = target .find ("'" )
775+ if separator >= 0 :
776+ attribute = target [:separator ]
777+ attr_value = target [separator + 1 :]
778+ try :
779+ query = "JSON.stringify(document.querySelector('[{0}=\" {1}\" ]').getBoundingClientRect())" .format (
780+ attribute , attr_value )
781+ resp = self .devtools .execute_js (query , use_execution_context = True )
782+ resp_json = json .loads (resp )
783+
784+ value = command ['value' ]
785+ button = 'left'
786+ clickCount = 1
787+ if value in ['left' , 'right' ]:
788+ button = value
789+ elif value == 'double' :
790+ clickCount = 2
791+ elif value is not None :
792+ logging .info ("Click type is not defined." )
793+
794+ if 'x' in resp_json and 'y' in resp_json and 'width' in resp_json and 'height' in resp_json :
795+ x = int (float (resp_json ['x' ])) + int (float (resp_json ['width' ]))/ 2
796+ y = int (float (resp_json ['y' ])) + int (float (resp_json ['height' ]))/ 2
797+ command_options = {}
798+ command_options ['x' ] = x
799+ command_options ['y' ] = y
800+ command_options ['button' ] = button
801+ command_options ['clickCount' ] = clickCount
802+ self .devtools .mouse_click (command_options )
803+ except :
804+ self .task ['error' ] = 'Exception parsing mouseClick arguments.'
805+ logging .error (self .task ['error' ])
769806 elif command ['command' ] == 'waitfor' :
770807 try :
771808 self .devtools .wait_for_script = command ['target' ] if command ['target' ] else None
0 commit comments