uiautomator icon indicating copy to clipboard operation
uiautomator copied to clipboard

Double and Triple Click / Tap ?!

Open gokulakv opened this issue 10 years ago • 18 comments

There is no functionality for Double and Triple Click / Tap, its simple to change in server rite Please change and let me know your repo client uiautomator.py So that I can use it

gokulakv avatar Jun 27 '14 11:06 gokulakv

No comments on this? Atleast say any workaround for this please!

gokulakv avatar Jun 30 '14 06:06 gokulakv

I didn't use double click before. Is it possible to call click twice on uiautomator?

xiaocong avatar Jul 02 '14 11:07 xiaocong

UiObject selectImage = new UiObject(new UiSelector().className("android.widget.RelativeLayout").index(3)); Configurator cc = Configurator.getInstance(); cc.setActionAcknowledgmentTimeout(40); selectImage.click(); selectImage.click();

This does the Job in Java UIAutomator Is this possible to be added? Barely needed

gokulakv avatar Jul 02 '14 13:07 gokulakv

I want triple click also... Please add that also in your list of todos

gokulakv avatar Jul 02 '14 14:07 gokulakv

Thank @gokulakv, I will add it.

xiaocong avatar Jul 02 '14 14:07 xiaocong

If it's possible please add it soon and give local version, as it's very crucial for our project. If you don't mind, is there an ETA for this?

-----Original Message----- From: ºØÏþ´Ï [[email protected]] Received: Wednesday, 02 Jul 2014, 20:05 To: xiaocong/uiautomator [[email protected]] CC: V, Gokulakrishnan [[email protected]] Subject: Re: [uiautomator] Double and Triple Click / Tap ?! (#53)

Thank @gokulakvhttps://github.com/gokulakv, I will add it.

¡ª Reply to this email directly or view it on GitHubhttps://github.com/xiaocong/uiautomator/issues/53#issuecomment-47783801.

gokulakv avatar Jul 02 '14 14:07 gokulakv

Please refer to below code and check if it can resolve your case.

def double_click(*args, **kwargs):
  # set ack timeout
  config = d.server.jsonrpc.getConfigurator()
  config['actionAcknowledgmentTimeout'] = 40
  d.server.jsonrpc.setConfigurator(config)
  # double click
  d(*args, **kwargs).click()
  d(*args, **kwargs).click()
  # restore previous config
  config['actionAcknowledgmentTimeout'] = 3000
  d.server.jsonrpc.setConfigurator(config)

Notes: Configurator requires Android 4.3+

xiaocong avatar Jul 02 '14 15:07 xiaocong

Likewise I want another module: TRIPLE CLICK Yea these two should solve mine

gokulakv avatar Jul 02 '14 16:07 gokulakv

Yea atlast let me know how to update these changes into my code framework

gokulakv avatar Jul 02 '14 16:07 gokulakv

from uiautomator import device as d

# define double click function
def double_click(*args, **kwargs):
  # set ack timeout
  config = d.server.jsonrpc.getConfigurator()
  config['actionAcknowledgmentTimeout'] = 40
  d.server.jsonrpc.setConfigurator(config)
  # double click
  d(*args, **kwargs).click()
  d(*args, **kwargs).click()
  # restore previous config
  config['actionAcknowledgmentTimeout'] = 3000
  d.server.jsonrpc.setConfigurator(config)

# call the function on view with text ...
double_click(text='...')

xiaocong avatar Jul 03 '14 02:07 xiaocong

No Server / Build Changes needed huh? I thought I had to build again

gokulakv avatar Jul 03 '14 06:07 gokulakv

Hey, Do we have to import anything? because I see that the Configurator class is not detected.

yeshwanth24 avatar Feb 05 '15 16:02 yeshwanth24

@yeshwanth24,

Please make sure:

  1. Install py-uiautomator using pip install uiautomator. It will install the jsonrpc jar files with py-uiautomator package.
  2. Do not launch jsonrpc server by yourself. py-uiautomator will launch correct jsonrpc server for you.

If you meet the issue again, please help upload the logcat when you are running the script, else I could not help you on this.

xiaocong avatar Feb 06 '15 05:02 xiaocong

Hi @xiaocong

My double tap is not working , below code I am using for it. It always does the single click.

config = d.server.jsonrpc.getConfigurator() config['actionAcknowledgmentTimeout'] = 40 d.server.jsonrpc.setConfigurator(config) d(ELEMENT).click() d(ELEMENT).click() config['actionAcknowledgmentTimeout'] = 3000 d.server.jsonrpc.setConfigurator(config)

sudhuhegde avatar Mar 17 '16 07:03 sudhuhegde

Hi @xiaocong @sudhuhegde it is working , i add xiaocong 's code( just changed a little) to uiautomator.py as:


def double_click(self, x=500, y=500): config = self.server.jsonrpc.getConfigurator() config['actionAcknowledgmentTimeout'] = 40 self.server.jsonrpc.setConfigurator(config) self.click(x, y) self.click(x, y) config['actionAcknowledgmentTimeout'] = 3000 self.server.jsonrpc.setConfigurator(config)


then, it worked very well.

yanglikai0806 avatar Mar 13 '17 10:03 yanglikai0806

for i in xrange(1,3):
	    d.click()
    	   sleep(0.01)

This works for me. You should sleep a while after click the view . @yanglikai0806 @yeshwanth24

yemengsky avatar Jul 28 '17 09:07 yemengsky

Hi @xiaocong

I tried running your code

def double_click(*args, **kwargs): # set ack timeout config = d.server.jsonrpc.getConfigurator() config['actionAcknowledgmentTimeout'] = 40 d.server.jsonrpc.setConfigurator(config) # double click d(*args, **kwargs).click() d(*args, **kwargs).click() # restore previous config config['actionAcknowledgmentTimeout'] = 3000 d.server.jsonrpc.setConfigurator(config) #calling the function

double_click(resourceId="com.amazon.photos:id/photo_view")

But i am getting an error as

Traceback (most recent call last): File "C:/Users/dikaushi/PycharmProjects/Amozon_Pheripharals_Automation0.1/Module_TestScripts/TestScripts.py", line 133, in main() File "C:/Users/dikaushi/PycharmProjects/Amozon_Pheripharals_Automation0.1/Module_TestScripts/TestScripts.py", line 130, in main TS.TS004_SwipeSpeeds() File "C:/Users/dikaushi/PycharmProjects/Amozon_Pheripharals_Automation0.1/Module_TestScripts/TestScripts.py", line 125, in TS004_SwipeSpeeds obj.double_click() File "C:\Users\dikaushi\PycharmProjects\Amozon_Pheripharals_Automation0.1\CommonLib\UIAKeywords.py", line 277, in double_click config = self.server.jsonrpc.getConfigurator() AttributeError: UIAKeywords instance has no attribute 'server'

Process finished with exit code 1

Could you tell me what is this issue

ananthandivya avatar Oct 13 '17 06:10 ananthandivya

@ananthandivya You need to use device instance. Instead of config = self.server.jsonrpc.getConfigurator() use config = d.server.jsonrpc.getConfigurator()

siva-kranthi avatar Oct 13 '17 07:10 siva-kranthi