Best Python code snippet using robotframework-appiumlibrary_python
test_element.py
Source:test_element.py
...264 el.get_width = MagicMock()265 el.get_width.return_value = 1266 result = el.get_width()267 assert type(result) == int268def test_click_a_point():269 el = Click()270 el.click_a_point = MagicMock()271 el.click_a_point.return_value = True272 result = el.click_a_point(x=MagicMock(), y=MagicMock())...
AircvLibrary.py
Source:AircvLibrary.py
...106 index -= 1107 re = result[index]108 self._mobilelib._info(re)109 if self._mobilelib._is_android():110 self._mobilelib.click_a_point(re['result'][0], re['result'][1])111 if self._mobilelib._is_ios():112 _scale = self.scale()113 self._mobilelib.click_a_point(re['result'][0]/_scale, re['result'][1]/_scale)114 return re115 def mobile_click_image(self, target, index=1):116 """117 :param target: the target image that should be clicked118 :param index: select the N-th element; 0 -> the last one119 :return: match info120 """121 return self._image_click(target, index)122 def mobile_click_in(self, parent_image, sub_image):123 """ click the sub image in the parent image124 """125 return self._parse_image_in(parent_image, sub_image, 'click')126 def mobile_get_image_location_in(self, parent_image, sub_image):127 """ get the sub image's coordinate which in the parent image128 """129 return self._parse_image_in(parent_image, sub_image, 'coordinate')130 def _parse_image_in(self, parent_image, sub_image, phase_type='click'):131 print 'Here is sub search img'132 self._prepare()133 if self.img_path:134 parent_image = os.path.join(self.img_path, parent_image)135 sub_image = os.path.join(self.img_path, sub_image)136 else:137 self._mobilelib._info("[>>>] img path not set")138 im_source = ac.imread(self._screen.decode('utf-8').encode('gbk'))139 im_parent = ac.imread(parent_image.decode('utf-8').encode('gbk'))140 im_sub = ac.imread(sub_image.decode('utf-8').encode('gbk'))141 intermediate = ac.find_template(im_source, im_parent, self.TH)142 in_rect = intermediate['rectangle']143 result = ac.find_all_template(im_source, im_sub, self.TH)144 for i in range(0, len(result), 1):145 result_rect = result[i]['rectangle']146 # only cmp left-top && right-down 's coordinate147 # rectangle[0~1]: left-top,left-down148 # rectangle[2~3]: right-top,right-down149 if self._coordinate_cmp(result_rect[0], in_rect[0]): # left-top150 if self._coordinate_cmp(in_rect[3], result_rect[3]): # right-down151 try:152 if 'click' in phase_type:153 if self._mobilelib._is_android():154 self._mobilelib.click_a_point(result[i]['result'][0], result[i]['result'][1])155 if self._mobilelib._is_ios():156 _scale = self.scale()157 self._mobilelib.click_a_point(result[i]['result'][0]/_scale, result[i]['result'][1]/_scale)158 elif 'coordinate' in phase_type:159 if self._mobilelib._is_android():160 return result[i]['result'][0], result[i]['result'][1]161 if self._mobilelib._is_ios():162 _scale = self.scale()163 return result[i]['result'][0]/_scale, result[i]['result'][1]/_scale164 except Exception, e:165 print '[xxx]: %s ' % traceback.format_exc()166 # Todo : return valid value167 return -1168 def mobile_get_images_num(self, target):169 """ get sum of the image in current screen170 """171 return self._parse_images(target)...
_touch.py
Source:_touch.py
...55 el = self._element_find(locator, True, True)56 action = TouchAction(driver)57 action.tap(el).perform()58 59 def click_a_point(self, x=0, y=0):60 """ Click on a point"""61 self._info("Clicking on a point (%s,%s)." % (x,y))62 driver = self._current_application()63 action = TouchAction(driver)64 try:65 action.press(x=float(x), y=float(y)).perform()66 except:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!