Hi,
I am trying to switch to Webview from native app, but i am not able to do it, Could some one throw light on what piece of code should i put in the statement in order to make it work.
Below are the details:
Code which i tried, please let me know if any piece of change need to be done here:
public class IOS_Phone_306Test {
public static void main(String args[]) throws MalformedURLException, InterruptedException{
DesiredCapabilities capabilities1 = new DesiredCapabilities();
capabilities1.setCapability(MobileCapabilityType.DEVICE_NAME, "MyPhone");
capabilities1.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2.1");
capabilities1.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities1.setCapability(MobileCapabilityType.UDID, "8e3f5a6fbaebfcefd7d09bc321e1efc69a1ce705");
// 8e3f5a6fbaebfcefd7d09bc321e1efc69a1ce705
capabilities1.setCapability(MobileCapabilityType.APP, "/ 3.0.6.app");
// capabilities1.setCapability(MobileCapabilityType.APP, "/Users/parameshmarina/Desktop/Appium_Framework/IOSProject/iOS_CPC_Demo (1).ipa");
//capabilities1.setCapability(MobileCapabilityType.APP, "/Users/parameshmarina/Library/Developer/Xcode/DerivedData/CloudPathClient-gzwfhfibsqpccjbsmphpzywahlzt/Build/Products/Debug-iphoneos/Basic_NBCD_3.0.4.app");
capabilities1.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300);
IOSDriver driver = new IOSDriver( new URL( "http://127.0.0.1:4723/wd/hub" ), capabilities1 );
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[2]/UIAButton[12]").click();
Thread.sleep(3000);
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableGroup[1]/UIASearchBar[1]").sendKeys("optimum");
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableCell[1]/UIAStaticText[1]").click();
Thread.sleep(6000);
//final java.util.Set contextNames = driver.getContextHandles();
for (Object contextName : contextNames) {
System.out.println(contextName);
if (((String) contextName).contains(“UIAWebView”)) {
driver.context((String) contextName);
}
}
driver.findElement(By.xpath(“//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAWebView[1]/UIASecureTextField[1]”)).sendKeys(“pp");//
}
}