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();
}
}