2

My screen size is (800, 1280)

I have determained the screen size using:

Dimension size = driver.manage().window().getSize();

Now I want to tab at a given coordinates of the screen so can anyone tell me how to do that?

4
  • What do you mean by tab at point? It doesn't really make sense from a user point of view, especially on a mobile device.
    – Florent B.
    Oct 13, 2016 at 14:20
  • I just want to tab at any one coordinates, therefore I tried swipe.tap(startx, starty).perform(); but it isn't working
    – Sandeep
    Oct 14, 2016 at 9:13
  • Please, Accept the answer which helped you the most. So this question will no longer will be in Active state. Jan 6, 2017 at 12:57
  • I didn't get my answer Narendra.
    – Sandeep
    Jan 9, 2017 at 7:12

1 Answer 1

1

Solution:

  • You have already found screen size by using

Dimension size = driver.manage().window().getSize();

  • Just to calculate center point of height of the screen

int point_to_tap = (int) (size.getHeight() * 0.5);

  • To calculate center point of width of the screen

int point_to_tap = (int) (size.getWidth() * 0.5);

  • Then you can simply tap providing point_to_tap as a parameter
6
  • You Mean by using swipe.tap(point_to_tap_width, point_to_tap_height).perform();
    – Sandeep
    Oct 14, 2016 at 5:16
  • yeah - you can turn it anyway you want to. You can use for swipe, tap, touch. Does it making sense? Oct 14, 2016 at 6:01
  • I tried swipe.tap(startx, starty).perform(); But it is giving me NullPointerException
    – Sandeep
    Oct 14, 2016 at 8:57
  • Your question is only belongs to finding the co-ordinates. [Ask new question - If needed] Let me know what actually case you wanted to automate? Oct 14, 2016 at 9:02
  • The question is same, I just want to tab at any one coordinates, therefore I tried swipe.tap(startx, starty).perform(); but it isn't working
    – Sandeep
    Oct 14, 2016 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.