# How to initliaze Android driver

**URL:** <https://forum.katalon.com/t/how-to-initliaze-android-driver/9019>\
**Category:** Mobile Testing\
**Tags:** mobile-testing, katalon-studio\
**Created:** [January 24, 2018, 7:06am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019 "2018-01-24T07:06:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 24, 2018, 7:06am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/1 "2018-01-24T07:06:46Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [January 24, 2018, 8:00am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/2 "2018-01-24T08:00:53Z")

</div>

For mobile testing, it will be like this:

**import** com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

**import** io.appium.java\_client.AppiumDriver

AppiumDriver\<?\> driver = MobileDriverFactory._getDriver_()

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 24, 2018, 8:23am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/3 "2018-01-24T08:23:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 24, 2018, 4:31pm UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/4 "2018-01-24T16:31:06Z")

</div>

Hi Vinh,

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

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [January 25, 2018, 2:57am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/5 "2018-01-25T02:57:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 25, 2018, 3:40am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/6 "2018-01-25T03:40:19Z")

</div>

Yes, i am using correct function.

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

![](https://s3.amazonaws.com/katalon-forum/editor/ib/9bw8uaj3sjs7.png "Image: https://s3.amazonaws.com/katalon-forum/editor/ib/9bw8uaj3sjs7.png") ![](https://s3.amazonaws.com/katalon-forum/editor/da/tf5yupohbwhw.png)

[Eclipse Image.png](https://s3.amazonaws.com/katalon-forum/editor/ib/9bw8uaj3sjs7.png)

[Katalon Image1.png](https://s3.amazonaws.com/katalon-forum/editor/da/tf5yupohbwhw.png)

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 26, 2018, 6:54am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/7 "2018-01-26T06:54:34Z")

</div>

Hi Vinh,

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

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [January 28, 2018, 9:26am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/8 "2018-01-28T09:26:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sudheer\_D\_J](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sudheer_d_j/32/16104_2.png) [@Sudheer\_D\_J](https://forum.katalon.com/u/Sudheer_D_J)\
**Post date:** [January 29, 2018, 7:19am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/9 "2018-01-29T07:19:13Z")

</div>

I am using driverTest instead of driver.

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

---

<div class="post-metadata">

**Author:** ![Aalok](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aalok](https://forum.katalon.com/u/Aalok)\
**Post date:** [June 8, 2018, 9:21am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/10 "2018-06-08T09:21:13Z")

</div>

I have tried below code :-

Option1:-  
AppiumDriver\<?\> driver = MobileDriverFactory.getDriver()

driver.findElementById(“btnLogin”).click()  
Option2:-  
AppiumDriver\<?\> driver = MobileDriverFactory.getDriver()  
driver.findElementByXPath("([//android.widget.Button](https://android.widget.Button))[0]").click()

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: [http://seleniumhq.org/exceptions/no\_such\_element.html](http://seleniumhq.org/exceptions/no_such_element.html)

Can someone guide me on this issue?

---

<div class="post-metadata">

**Author:** ![Vincent\_Van](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@Vincent\_Van](https://forum.katalon.com/u/Vincent_Van)\
**Post date:** [September 26, 2018, 3:39am UTC](https://forum.katalon.com/t/how-to-initliaze-android-driver/9019/11 "2018-09-26T03:39:53Z")

</div>

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