How to work with custom attributes after going into web view of an ios hybrid app


In my hybrid app of ios. After changing context view of an app in the web. Appium studio doesn’t recognize custom attributes as a locator with XPath strategy. Code snippets as below:
driver.findElement(By. xpath ("//span[@test-id=‘countofAccounts’]")).getText();

Here test-id is a custom attribute. How to work with it. By cssSelector also tried, but not working properly.
Getting context as persnippetode snippest:

Set contextName = ((AndroidDriver) driver).getContextHandles();
System. out .println(contextName);

for (Object o : contextName) {

String data=o.toString();

System. out .println(the data);


Please do not focus on driver name declaration. I know for android app , ihave to use android driver and for ios, ihave to use ios driver.
After applying above code, only getting NATIVE_APP as a context view of an app.
But hardcoded and static way, driver.context(“WEBVIEW_1”) is working. No error thrown.
So what to do for same?

Same problem is also facing in android as well. Same to same problem.

Appium studio version is 12_1_73, Mac machine. Device: iPhone 6s



Did you set the autoWebView “capability” to true ?



Yes did that. Still Same problem persist.