How to use long_click method in uiautomator

Best Python code snippet using uiautomator

test_device_obj.py

Source: test_device_obj.py Github

copy

Full Screen

...118 def test_click_wait(self):119 self.jsonrpc.clickAndWaitForNewWindow.return_value = True120 self.assertTrue(self.obj.click.wait(timeout=321))121 self.jsonrpc.clickAndWaitForNewWindow.assert_called_once_with(self.obj.selector, 321)122 def test_long_click(self):123 self.jsonrpc.longClick.return_value = False124 corners = ["tl", "topleft", "br", "bottomright"]125 for c in corners:126 self.assertFalse(self.obj.long_click(c))127 self.assertEqual(self.jsonrpc.longClick.call_args_list,128 [call(self.obj.selector, c) for c in corners])129 self.jsonrpc.longClick = MagicMock()130 self.jsonrpc.longClick.return_value = True131 corners = ["tl", "topleft", "br", "bottomright"]132 for c in corners:133 self.assertTrue(getattr(self.obj.long_click, c)())134 self.assertEqual(self.jsonrpc.longClick.call_args_list,135 [call(self.obj.selector, c) for c in corners])136 self.jsonrpc.longClick = MagicMock()137 self.jsonrpc.longClick.return_value = True138 self.assertTrue(self.obj.long_click())139 self.jsonrpc.longClick.assert_called_once_with(self.obj.selector)140 def test_long_click_using_swipe(self):141 self.device.long_click.return_value = False142 self.jsonrpc.objInfo.return_value = {143 'longClickable': False,144 'visibleBounds': {145 'top': 0,146 'bottom': 60,147 'left': 0,148 'right': 60149 }150 }151 corners = ["tl", "topleft", "br", "bottomright"]152 for c in corners:153 self.assertFalse(self.obj.long_click(c))154 self.assertEqual(self.device.long_click.call_args_list,155 [call(10, 10), call(10, 10), call(50, 50), call(50, 50)])156 self.device.long_click = MagicMock()157 self.device.long_click.return_value = True158 corners = ["tl", "topleft", "br", "bottomright"]159 for c in corners:160 self.assertTrue(getattr(self.obj.long_click, c)())161 self.assertEqual(self.device.long_click.call_args_list,162 [call(10, 10), call(10, 10), call(50, 50), call(50, 50)])163 self.device.long_click = MagicMock()164 self.device.long_click.return_value = True165 self.assertTrue(self.obj.long_click())166 self.device.long_click.assert_called_once_with(30, 30)167 def test_drag_to(self):168 self.jsonrpc.dragTo.return_value = False169 self.assertFalse(self.obj.drag.to(10, 20, steps=10))170 self.jsonrpc.dragTo.return_value = True171 self.assertTrue(self.obj.drag.to(x=10, y=20, steps=20))172 sel = {"text": "text..."}173 self.assertTrue(self.obj.drag.to(steps=30, **sel))174 self.assertEqual(self.jsonrpc.dragTo.call_args_list,175 [call(self.obj.selector, 10, 20, 10),176 call(self.obj.selector, 10, 20, 20),177 call(self.obj.selector, Selector(**sel), 30)])178 def test_gesture(self):179 self.jsonrpc.gesture.return_value = True...

Full Screen

Full Screen

MyUiautomator.py

Source: MyUiautomator.py Github

copy

Full Screen

...156 log.info('sucess double_click coordinate: {}'.format(css))157 else:158 log.error('double_click Positioning syntax errors: {}, 请传入以下类型: str、 list、 tuble'.format(css))159 raise NameError('double_click Positioning syntax errors: {}, 请传入以下类型: str、 list、 tuble'.format(css))160 def long_click(self, css, secs=0.5):161 """162 uiautomator2长按点击事件163 :param css:传入定位元素或坐标,元素如:text->收藏; 坐标如:[1, 2]/​(1, 2)164 :param secs;长按时间165 :return:166 """167 if type(css) is str:168 self.find_ele(css).long_click(duration=secs)169 log.info('sucess long_click ele: {}'.format(css))170 elif type(css) is list or type(css) is tuple:171 self.app.long_click(css[0], css[1], duration=secs)172 log.info('sucess long_click coordinate: {}'.format(css))173 else:174 log.error('long_click Positioning syntax errors: {}, 请传入以下类型: str、 list、 tuble'.format(css))175 raise NameError('long_click Positioning syntax errors: {}, 请传入以下类型: str、 list、 tuble'.format(css))176 def set_text(self, css, text):177 """输入值,不调用输入法输入"""178 app_element = self.find_ele(css)179 app_element.set_text(text)180 log.info('sucess set text: "{}" /​ "{}"'.format(css, text))181 def send_keys(self, text):182 """183 无法定位时,使用输入法输入,在光标处输入184 :param text: 文本185 :return:...

Full Screen

Full Screen

local_positioning1.py

Source: local_positioning1.py Github

copy

Full Screen

...3from poco.drivers.unity3d.test.tutorial.case import TutorialCase4class LocalPositioning1Tutorial(TutorialCase):5 def runTest(self):6 image = self.poco('fish').child(type='Image')7 image.focus('center').long_click()8 time.sleep(0.2)9 image.focus([0.1, 0.1]).long_click()10 time.sleep(0.2)11 image.focus([0.9, 0.9]).long_click()12 time.sleep(0.2)13 image.focus([0.5, 0.9]).long_click()14 time.sleep(0.2)15if __name__ == '__main__':16 import pocounit...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Testing Modern Applications With Playwright ????

Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

7 Skills of a Top Automation Tester in 2021

With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.

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 uiautomator 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