// If this method is called inside a test the script will check if the device has a resolution
 // lower than 500x500 and if so will use
 // a different set of images when trying to find a image. These images are located in
 // /queryimages/low_res
 public void setQueryImageFolder() {
   Dimension size = driver.manage().window().getSize();
   log("Screen size: " + size.toString());
   if ((size.getHeight() <= 500) || (size.getWidth() <= 500)) {
     queryimageFolder = "low_res/";
   }
 }
  // Taps at relative coordinates on the screen.
  // "x_offset" and "y_offset" set the X and Y coordinates.
  // "taps" sets the number of taps that are performed.
  // "frequency" sets the frequency of the taps.
  public void tapAtRelativeCoordinates(double x_offset, double y_offset, int taps, double frequency)
      throws Exception {
    Dimension size = driver.manage().window().getSize();
    Point middle = new Point(size.getWidth(), size.getHeight());
    Point middleWithOffset = new Point(middle.x * x_offset, middle.y * y_offset);

    log(
        "Tapping at coordinates: "
            + middleWithOffset.toString()
            + "  when size of the screen is: "
            + size.toString());
    for (int i = 0; i < taps; i++) {
      if (automationName.equalsIgnoreCase("selendroid")) {
        selendroidTapAtCoordinate((int) middleWithOffset.x, (int) middleWithOffset.y, 1);
      } else {
        driver.tap(1, (int) middleWithOffset.x, (int) middleWithOffset.y, 1);
      }
      sleep(frequency);
    }
  }