What is the difference between using IOSDriver and RemoteWebDriver to launch the Simulator?

Hey All,
Can anyone help me understand what is the difference between these two codes?
One uses IOS Driver and one uses RemoteWebDriver. Which one is better? Why would people use one and not the other? I got the code from a book and the other from online. Which one do people usually use to launch the iOS simulator? Which one is outdated and which one is the correct standard?
Thanks.

public class IOSSimulatorWithIOSDriver {
//@SuppressWarnings(“rawtypes”)
@SuppressWarnings(“rawtypes”)
public static void main(String… args) throws InterruptedException, MalformedURLException{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(“platformName”, “iOS”);
desiredCapabilities.setCapability(“platformVersion”, “9.0”);
desiredCapabilities.setCapability(“deviceName”, “iPhone 6”);
desiredCapabilities.setCapability(“app”, “safari”);

	IOSDriver<?> driver;
    driver= new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities);
    driver.get("http://www.google.com");
    WebElement ele =driver.findElement(By.name("q"));
    ele.click();
    ele.sendKeys("Packt Publishing");
    WebElement searchButton =
    driver.findElement(By.name("btnG"));
    System.out.println(searchButton.getSize());
    searchButton.click();
    Thread.sleep(5000);
    driver.quit();
}

}

public class IOSSimulatorWithRemoteWebDriver {

public static void main(String... args) throws InterruptedException{
   DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
   desiredCapabilities.setCapability("platformName", "iOS");
   desiredCapabilities.setCapability("platformVersion", "9.0");
   desiredCapabilities.setCapability("deviceName", "iPhone 6");
   desiredCapabilities.setCapability("app", "safari");
   URL url = null;

   try {
        url = new URL("http://127.0.0.1:4723/wd/hub");
   } 
   catch (MalformedURLException e) 
   {
               e.printStackTrace();
   }
   
    WebDriver remoteWebDriver = new RemoteWebDriver(url, desiredCapabilities);
    remoteWebDriver.get("http://www.google.com");
    WebElement ele = remoteWebDriver.findElement(By.name("q"));
    ele.click();
    ele.sendKeys("Packt Publishing");
    WebElement searchButton = remoteWebDriver.findElement(By.name("btnG"));
    System.out.println(searchButton.getSize());
    searchButton.click();
    Thread.sleep(50000);
    remoteWebDriver.quit();
} 

}

@seleniumappiumnewbie, Its preferable to use IOSDriver to launch iOS simulator.

According to my understanding, as you can see in attachment. The IOSDriver extends from AppiumDriver and AppiumDriver extends from RemoteWebDriver. This means if you want to use some specific function on IOS, it’s better that select IOSDriver.

Continue on this topic. i am not very clear what’s the relationship between MobileDriver and AppiumDriver. Or what’s the difference and when we will use MobileDriver and When we can use AppiumDriver ?

Thanks. I will start using IOSDriver only. I have to remember to suppress the raw types warnings for IOSDriver. Is there a way to handle the IOSDriver raw types without suppressing the warnings?

@seleniumappiumnewbie, I am also getting same warning , I am also searching for reliable solution to suppress warning. Refer this link, I have raised this problem in appium discussion forum.

Thanks Selvi for the link.

1 Like

Hello,

Could you please let me know why I can’t instantiate IOSDriver ? I can’t get my head around it.
Kind regards,

Tony

Where do I get IOSDriver? Can’t find anything in the documentation

Same here. Can’t find it anywhere

import io.appium.java_client.ios.IOSDriver;

IOSDriver iosdriver = new IOSDriver(new URL(“http://127.0.0.1:”+strAppiumPort+“/wd/hub”), capabilities);

Thank you, but where do i find the class online?