How to initliaze Android driver


I am trying to automate mobile native app and i want to use UI selector class in my script. Please can any one tell me how to intilaize it.

For web application i am using like this. WebDriver driver = DriverFactory.getWebDriver()

In the similar manner i want it for Android driver

For mobile testing, it will be like this:


import io.appium.java_client.AppiumDriver

AppiumDriver<?> driver = MobileDriverFactory.getDriver()

Thank you,

i am trying to get the text from driver.findElementByAndroidUIAutomator(“new UiSelector().className(\“android.view.View\”).index(11)”)

But, i am not getting getText()

How to get the text?

Hi Vinh,

Could you please respond to my question. I am stuck on this. Without this i cannot move forward in my application.

The function you are using related to Appium itself, so do you double check if you are using correct className and its function?

Yes, i am using correct function.

When i am writting same code in Eclipse i am getting all the appropriate methods like getText(), click()…

Eclipse Image.png

Katalon Image1.png

Hi Vinh,

I had attached the screenshots. Awaiting for your reply. Please help me to solve this.

I think you should use this instead:
driver.findElementByAndroidUIAutomator(“new UiSelector().className(“android.view.View”).index(11)”)

I am using driverTest instead of driver.

I declared the variable with the name as ‘driverTest’. Both are same.

I have tried below code :-

AppiumDriver<?> driver = MobileDriverFactory.getDriver()

AppiumDriver<?> driver = MobileDriverFactory.getDriver()

But getting below error in both attempt:-

est1 FAILED because (of) org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

For documentation on this error, please visit:

Can someone guide me on this issue?

@Aalok try driver.findElement(MobileBy by) instead of findElementByXXX()