I was trying to automate the hybrid app build using ionic2/Angular2 and typescript.
I am using C# for code writing. test are in BDD - specflow Versions: iOS:9.3.1 Xcode: 7.3 Appium: 1.4.13
I am not able to identify elements after swtiching Context to WEBVIEW.
Calling IOSDriver using below code
private IOSDriver<IOSElement> driver = null;
public IOSDriver<IOSElement> GetDriver(string platformVersion, string deviceName, string udid ,string appPath, string serverUri)
{
Capabilities iosCapabilities = new Capabilities();
DesiredCapabilities capabilities = iosCapabilities.Get(platformVersion, deviceName, udid, appPath);
driver = new IOSDriver<IOSElement>(new Uri(serverUri), capabilities, TimeSpan.FromSeconds(Constants.DriverWaitTime));
driver.Manage ().Timeouts ().ImplicitlyWait (TimeSpan.FromSeconds(Constants.ImplicitWaitTime));
var contextNames = driver.Contexts;
driver.Context = contextNames[1];
driver.FindElement(By.Xpath(locator)).Click();
}
Setting Capabilities as
private DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability ("appium-version", Constants.AppiumVersion);
capabilities.SetCapability ("platformName", Constants.PlatformName);
capabilities.SetCapability("autoWebView", "true");
capabilities.SetCapability("browserName", "iOS");
capabilities.SetCapability ("platformVersion", Constants.PlatformVersion);
capabilities.SetCapability("deviceName", deviceName);
capabilities.SetCapability("app", appPath);
capabilities.SetCapability("udid", udid);
Am I setting the capabilities in correct way?
- Solution tried:
- I checked using browserName capbility as blank/safari but didn't worked
- Also, I installed ios-webkit-debug-proxy and started proxy using terminal in background on my mac
- Problem is i am not able to identify elements in WEBVIEW.
What I am doing
After launching the app, in appium inspector I am able to see all the elements and I am trying to click on textbox to enter some value
Xpath of textbox(as i can view in appium inspector window): "//UIAApplication1/UIAWindow1/UIAScrollView2/UIAWebView1/UIATextField1"
var contextNames = driver.Contexts
is giving me list to views(In my case 2 views: NATIVE_APP, WEBVIEW_1) WebView context is dynamically updating from 1,2,3 and so on..
As soon as I call
diver.Context=contextNames[1]; //setting context to WEBVIEW
and refresh the appium inspector I am not able to see/identify single element.Everything goes away.
Why I am not able to see/identify elements after switching to webview. (Note: As soon as I Switch back to driver.Context="NATIVE_APP" every element becomes visible in appium inspector but still I am not able to click)
It shows error as "An element could not be located using given search parameter"
Manually also when I try to tap or sendkeys using appium inspector it is not letting me do so(after lauching tha app manually using inspector button). What is the issue here. Help would be highly appreciated
Screenshot of Appium inspector:
Error message as displayed in appium window:
Here are the full logs of Appium(ERROR)
Link of Appium logs when not able to identify elements in WEBVIEW