How to use swipe_by_percent method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

adbkit.py

Source:adbkit.py Github

copy

Full Screen

...395 return self.adb_device.click(x, y)396 else:397 logging.error("click_by_percent(x, y) 预期为小于等于1.0的值,请检查参数")398399 def swipe_by_percent(self, sx, sy, ex, ey, duration: float = 1.0):400 """通过比例发送滑动事件,Android 4.4以上可选 duration(ms)"""401 wx, wy = self.window_size()402 sx *= wx403 sy *= wy404 ex *= wx405 ey *= wy406 logging.debug(f"滑动事件 ==> ({sx}, {sy}, {ex}, {ey}, duration={duration})")407 return self.adb_device.swipe(sx, sy, ex, ey, duration=duration)408409 def swipe_to_left(self):410 """左滑屏幕"""411 self.swipe_by_percent(0.8, 0.5, 0.2, 0.5)412413 def swipe_to_right(self):414 """右滑屏幕"""415 self.swipe_by_percent(0.2, 0.5, 0.8, 0.5)416417 def swipe_to_up(self):418 """上滑屏幕"""419 self.swipe_by_percent(0.5, 0.8, 0.5, 0.2)420421 def swipe_to_down(self):422 """下滑屏幕"""423 self.swipe_by_percent(0.5, 0.2, 0.5, 0.8)424425 def gen_file_name(self, suffix=None):426 """生成文件名称,用于给截图、日志命名"""427 now = datetime.datetime.now()428 str_time = now.strftime('%y%m%d_%H%M%S')429 device = self.manufacturer().lower()430 if not suffix:431 return f"{device}_{str_time}"432 return f"{device}_{str_time}.{suffix}"433434 def screenshot(self, pc_path):435 """获取当前设备的截图,导出到指定目录436 usage:437 screenshot("/Users/lan/Downloads/") ...

Full Screen

Full Screen

_touch.py

Source:_touch.py Github

copy

Full Screen

...35 Android 'Swipe' is not working properly, use ``offset_x`` and ``offset_y`` as if these are destination points.36 """37 driver = self._current_application()38 driver.swipe(start_x, start_y, offset_x, offset_y, duration)39 def swipe_by_percent(self, start_x, start_y, end_x, end_y, duration=1000):40 """41 Swipe from one percent of the screen to another percent, for an optional duration. 42 Normal swipe fails to scale for different screen resolutions, this can be avoided using percent.43 Args:44 - start_x - x-percent at which to start45 - start_y - y-percent at which to start46 - end_x - x-percent distance from start_x at which to stop47 - end_y - y-percent distance from start_y at which to stop48 - duration - (optional) time to take the swipe, in ms.49 50 Usage:51 | Swipe By Percent | 90 | 50 | 10 | 50 | # Swipes screen from right to left. |52 _*NOTE: *_53 This also considers swipe acts different between iOS and Android....

Full Screen

Full Screen

runner.py

Source:runner.py Github

copy

Full Screen

...21 return self.height, self.width22 # swipe one page23 def swipe_up_one_page(self, times=1, duration=0.5):24 print 'swiping up one page for {} times'.format(times)25 return self.swipe_by_percent(start_x_per=0.5, start_y_per=0.8, end_y_per=0.3, end_x_per=0.5, times=times, duration=duration)26 # swipe interface27 def swipe_by_percent(self, start_x_per, start_y_per, end_x_per, end_y_per, times=1, duration=0.5):28 while times:29 try:30 height = self.height31 width = self.width32 start_x = width * start_x_per33 start_y = height * start_y_per34 end_x = width * end_x_per35 end_y = height * end_y_per36 print ("swiping by percent with fx={}, fy={}, tx={}, ty={}, duration={}".format(start_x, start_y, end_x, end_y, duration))37 self.driver.swipe(start_x, start_y, end_x, end_y, duration)38 times -= 139 sleep(1)40 except BaseException as e:41 print (e.message)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-appiumlibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful