Scrolling to element in android app using java

you started again. cssSelector NEVER! should have “android.view.View” as far as ‘cssSelector’ CAN work ONLY in webview.

hi @Aleksei,

How will I able to click or select if its shown below, the only unique value is alt and the text, but as per the rule, no css selector on text and contains has been removed

Still receiving error as no elements found
driver.findElement(By.cssSelector(“div[alt=‘contact-detail’]”)).click();

Hi @Aleksei,

I have tried like this, still not working here for the 3 code i tried
driver.findElement(By.cssSelector(“list-count:nth-of-type(1)”)).click();
or
driver.findElement(By.cssSelector(".count:nth-of-type(1)")).click();
or
driver.findElement(By.cssSelector(“img[alt=‘contact-details’]”)).click();

Hi @Aleksei,

Is there a different line of code when handling a dialog box when clicking a button for Appium Webview? The scenario is, the button will only appear or display once you key-in your number which is appearing but unable to click the button on the dialog box even it is displayed already.Appium Webview.txt (78.5 KB)

Appium Error Log: Appium Error Log.txt (8.1 KB)

I used explicit, implicit and even thread wait for the command button to display, which is displaying but I am receiving an error given below:

[WD Proxy] Got an unexpected response with status 400: {“value”:{“error”:“element click intercepted”,“message”:"element click intercepted: Element … is not clickable at point (179, 260). Other element would receive the click:

I coded like this:

AndroidDriver driver = Capabilities();

	System.out.println("----> Resume Flow Automation Testing");
	Thread.sleep(12000);
	
	driver.findElementByXPath("//android.view.View[@text='Done this before? Resume your application']").click();   	
			
	Set<String> contexts = driver.getContextHandles();	
	
	for(String contextName: contexts)
	{			
		System.out.println(contextName);
	}
			
	driver.context("WEBVIEW_com.cimb.ekyc");
	
	driver.findElement(By.cssSelector("input[placeholder='Enter Mobile Number']")).sendKeys("0100101891");
	Thread.sleep(5000);
	driver.findElement(By.cssSelector("input[placeholder='Enter NRIC number']")).sendKeys("890413158452");
	
	// explicit wait - to wait for the compose button to be click-able	

// WebDriverWait wait = new WebDriverWait(driver,10);
// wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(“button.primary-btn”)));
// click on the compose button as soon as the “Request SMS OTP Code” button is visible
// driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(12000);
driver.findElement(By.cssSelector(“button.primary-btn”)).click();

It is perfectly working. Great work Gim.

Is there any which we can control the speed of scroll. I’m using uiautomator what happens is when the device is in landscape mode scroll is way too fast so the element which is desired becomes hidden during the scrolling process.

You can use precise scroll to element or from tricks from “ultimate scroll guide” https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/tutorial/swipe-tutorial.md

This works like charm. Thanks @Gim_Nguy_n and @Aleksei :slight_smile:

this is my solution :smiley:

public void scrollToText(String text) {
MobileElement scroll = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(
new UiSelector()).scrollIntoView(” + “new UiSelector().description(” + “”" + text + “”"+ “));”));
}