Tap is sometime longer {android}

i use tap action in chrome browser with this method :
until yesterday morning it was working very well …

   /**
    	 * tap in chrome with actionTouch by changing context to native context else it's doesn't work
    	 *
    	 * @param androidDriver the current driver
    	 * @param fElement      the WebElement targeted to be tap
    	 */
	public static void WebTap(AndroidDriver androidDriver, WebElement fElement) throws IOException, InterruptedException {
		WebElement element = fElement;
		Point point = getElementCenter(androidDriver, element);
		double elementCenterX = point.getX();
		double elementCenterY = point.getY();
		String originalContext = androidDriver.getContext();
		androidDriver.context("NATIVE_APP");
		while (elementCenterY < 241) {
			androidDriver.context(originalContext);
			AndroidEnvironnement.swipeDown(androidDriver);
			AndroidEnvironnement.setAndroidTouchArg(androidDriver);
			point = getElementCenter(androidDriver, element);
			elementCenterX = point.getX();
			elementCenterY = point.getY();
			androidDriver.context("NATIVE_APP");
		}
		try {
			androidDriver.tap(1, (int) elementCenterX, (int) elementCenterY, 100);
		} catch (Exception e) {
			if (elementCenterY > AndroidEnvironnement.screenSize.getHeight()) {
				androidDriver.context(originalContext);
				AndroidEnvironnement.swipeUp(androidDriver);
				AndroidEnvironnement.setAndroidTouchArg(androidDriver);
				WebTap(androidDriver, fElement);
				androidDriver.context("NATIVE_APP");
			} else if (elementCenterY < AndroidEnvironnement.screenSize.getHeight()) {
				androidDriver.context(originalContext);
				AndroidEnvironnement.swipeDown(androidDriver);
				AndroidEnvironnement.setAndroidTouchArg(androidDriver);
				WebTap(androidDriver, fElement);
				androidDriver.context("NATIVE_APP");
			}
		}
		androidDriver.context(originalContext);
	}

now sometimes the tap is longer than usual , my speed is 100 ms so it’s it’s pretty speedy^^
the fact that is longer make my test crash because long press open a popup in chrome with the url of the button.
thx in advance to help me.

mmmh i think that was because my device was low batterie now it’s working again … i don’t know how to close useless topic sorry any advice ?

You can leave the topic open. Someone in the future might end up searching for this topic for a similar problem they might have.

100 ms is a bit long. I’m usually happy with just keeping it a 1 ms tap, unless there’s some device specific issue that prevents you from trimming that tap time down. But, as I say for automation: whatever works. :smiley:

1 Like

Before i was tapping during 500 ms :slight_smile: on nexus 9 with android 6.0.1 so i thought 100 ms should be quick ^^ . i thought the device maybe don’t reconize if it’s too short …
so i’ll try with 1 ms to see

thx afwang