# Using AndroidDriver\<WebElement\> to automate iOS apps

**URL:** <https://discuss.appium.io/t/using-androiddriver-webelement-to-automate-ios-apps/5770>\
**Category:** Support\
**Created:** [August 27, 2015, 9:58am UTC](https://discuss.appium.io/t/using-androiddriver-webelement-to-automate-ios-apps/5770 "2015-08-27T09:58:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rameshwar\_Juptimath](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@Rameshwar\_Juptimath](https://discuss.appium.io/u/Rameshwar_Juptimath)\
**Post date:** [August 27, 2015, 9:58am UTC](https://discuss.appium.io/t/using-androiddriver-webelement-to-automate-ios-apps/5770/1 "2015-08-27T09:58:09Z")

</div>

Continuing the discussion from [I’m unable to set package and activity in the appium](https://discuss.appium.io/t/im-unable-to-set-package-and-activity-in-the-appium/1371/5):

> [@I'm unable to set package and activity in the appium](https://discuss.appium.io/t/im-unable-to-set-package-and-activity-in-the-appium/1371/5):
>
> I had renamed the apk, this caused the error. Anyway thanks for the answer. Could you tell why renaming the apk from the original when is built causes this issue?  
> Thanks once again.

Continuing the discussion from [How can I scroll in android/ios from top to bottom using appium driver?](https://discuss.appium.io/t/how-can-i-scroll-in-android-ios-from-top-to-bottom-using-appium-driver/5686/2):

> [@How can I scroll in android/ios from top to bottom using appium driver?](https://discuss.appium.io/t/how-can-i-scroll-in-android-ios-from-top-to-bottom-using-appium-driver/5686/2):
>
> “mobile: scroll” these gestures are deprecated with java client new versions.
> 
> driver.swipe, Touch Action class help in scrolling. Below code works for me in android. You can modify it as per your needs
> 
> public class TouchActions{
> 
> ```
> public static AndroidDriver<WebElement> _driver;
> 
> @BeforeClass
> public void setUpAppium() throws InterruptedException, IOException {
> DesiredCapabilities capabilities = new DesiredCapabilities();   
> AppCapabilitiesSetUp(capabilities);
> _driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);
> }
> 
> @Test
> public void installAndLaunchSecondAppTest() throws InterruptedException{
> // Wait for launced app to load
> Thread.sleep(10000);
> 
> // Press Home Key to minimize launched app
> _driver.sendKeyEvent(AndroidKeyCode.HOME);
> Thread.sleep(3000);
> 	
> // Press Menu button to view all installed app's
> _driver.findElementByAccessibilityId("Apps").click();
> 	
> // Using Touch Action Classes
> TouchAction tAction=new TouchAction(_driver);
> int startx = _driver.findElement(By.name("Email")).getLocation().getX();
> int starty = _driver.findElement(By.name("Email")).getLocation().getY();
> int endx = _driver.findElement(By.name("Dev Settings")).getLocation().getX();
> int endy = _driver.findElement(By.name("Dev Settings")).getLocation().getY();
> System.out.println(startx + " ::::::: " + starty + " ::::::: " + endx + " ::::::: " +	endy);
> 
> //First tap on the screen and swipe it right using moveTo function
> tAction.press(startx+20,starty+20).moveTo(endx+20,endy+20).release().perform(); 
> Thread.sleep(1000);
> 	
> //Second tap on the screen and swipe it left using moveTo function
> tAction.press(endx+20,endy+20).moveTo(startx+20,starty+20).release().perform();
> Thread.sleep(1000);
> }
> 
> @AfterClass(alwaysRun=true)
> public void teardown(){
> _driver.closeApp();
> _driver.quit();
> }
> 
> public DesiredCapabilities AppCapabilitiesSetUp(DesiredCapabilities cap){
> cap.setCapability(CapabilityType.BROWSER_NAME,"");
> cap.setCapability("platformVersion","4.4.4");
> cap.setCapability("platformName","Android");
> cap.setCapability("deviceName","emulator-5554");
> cap.setCapability("appPackage","appPackage");
> cap.setCapability("appActivity","appActivity");						
> return cap;
> 	
> }
> 
> ```
> 
> }

I see that you are using AndroidDriver to create your driver.

Can I use the same code to create a driver that can be used to automate an iOS app?

---

<div class="post-metadata">

**Author:** ![amitjaincoer191](https://discuss.appium.io/user_avatar/discuss.appium.io/amitjaincoer191/32/5339_2.png) [@amitjaincoer191](https://discuss.appium.io/u/amitjaincoer191)\
**Post date:** [August 27, 2015, 11:42am UTC](https://discuss.appium.io/t/using-androiddriver-webelement-to-automate-ios-apps/5770/2 "2015-08-27T11:42:19Z")

</div>

Yes you can create it

IOSDriverdriver = new IOSDriver(new URL(“localhost/wd/hub”),caps);

---

<div class="post-metadata">

**Author:** ![Rameshwar\_Juptimath](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@Rameshwar\_Juptimath](https://discuss.appium.io/u/Rameshwar_Juptimath)\
**Post date:** [August 27, 2015, 1:25pm UTC](https://discuss.appium.io/t/using-androiddriver-webelement-to-automate-ios-apps/5770/4 "2015-08-27T13:25:47Z")

</div>

Thanks. That works 😄
