@bootstrap - Long Click on a coordinate. Can you give a Java example?

358 views
Skip to first unread message

Andrew Dinh

unread,
Apr 3, 2014, 2:34:34 PM4/3/14
to appium-...@googlegroups.com
Hi bootstrap,

I know about a month ago, you implemented Long Click on a coordinate with duration.   


I haven't had a chance til now to circle around and investigate it.  

Can you show me how to long click a coordinate with a duration argument using JAVA.  I think others can also benefit from this.  Thanks a lot!

Andrew

bootstrap online

unread,
Apr 3, 2014, 2:36:11 PM4/3/14
to Andrew Dinh, appium-...@googlegroups.com
Appium 1.0 is making changes to all the mobile methods. Documentation
is a work in progress and it'll include the longClick example in Java.
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/d/optout.

Andrew Dinh

unread,
Apr 3, 2014, 2:53:49 PM4/3/14
to appium-...@googlegroups.com, Andrew Dinh
Great!  I look forward to it.

BTW, if we use git to clone the project, then we should be able to get the latest already, right?  Thanks.


bootstrap online

unread,
Apr 3, 2014, 2:56:19 PM4/3/14
to Andrew Dinh, appium-...@googlegroups.com
On Thu, Apr 3, 2014 at 2:53 PM, Andrew Dinh <trieu...@gmail.com> wrote:
> BTW, if we use git to clone the project, then we should be able to get the
> latest already, right? Thanks.

Yes. Documentation isn't written yet because the code is still
changing. Once 1.0 ships, this will all be much easier.

Andrew Dinh

unread,
Apr 3, 2014, 6:20:32 PM4/3/14
to appium-...@googlegroups.com, Andrew Dinh
For other people's info, I have tried longClick with the default duration and it worked.

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Integer> longTapObject = new HashMap<String, Integer>();
longTapObject.put("x", x_coordinate); // in pixels from left
longTapObject.put("y", y_coordinate); // in pixels from top
js.executeScript("mobile: longClick", longTapObject);


But, you should wait for the documentation like bootstrap said, cuz it could change.  

James Farrier

unread,
Apr 10, 2014, 7:12:29 PM4/10/14
to appium-...@googlegroups.com, Andrew Dinh
Any chance of some C# examples as well?  I don't seem to be able to click/tap on a location using c# as it requires a webelement.  Will Selendroid implement the same actions as part of moving to Selenium 3?

bootstrap online

unread,
Apr 10, 2014, 9:35:40 PM4/10/14
to James Farrier, appium-...@googlegroups.com, Andrew Dinh
c# examples are planned. In terms of Selendroid's roadmap, you'd have
to ask them. I hope they do implement the same spec.

James Farrier

unread,
Apr 11, 2014, 12:27:05 AM4/11/14
to appium-...@googlegroups.com, James Farrier
Awesome.

At present I can't find a way to click on a co-ordinate in Selendroid, they require clicking on an webelement.  So it would be even better if Selendroid would mirror Appium's changes

Thanks bootsraponline.

Andrew Dinh

unread,
Apr 14, 2014, 6:29:24 PM4/14/14
to James Farrier, appium-...@googlegroups.com
For tapping, with x_coordinates and y_coordinates being integers.
 
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Integer> tapObject = new HashMap<String, Integer>();
tapObject.put("x", x_coordinate); // in pixels from left
tapObject.put("y", y_coordinate); // in pixels from top
js.executeScript("mobile: tap", tapObject);
 
For long-tapping:
 
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Integer> longTapObject = new HashMap<String, Integer>();
longTapObject.put("x", x_coordinate); // in pixels from left
longTapObject.put("y", y_coordinate); // in pixels from top
js.executeScript("mobile: longClick", longTapObject);
 
Currently these codes work for me.  You can use them until Appium changes.  :)
 
 
 
 

--
http://appium.io
---
You received this message because you are subscribed to a topic in the Google Groups "Appium-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/appium-discuss/sYC9Prq81Sk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to appium-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages