Home > Software design >  The custom view added in the WKWebview is not listed during UITesting
The custom view added in the WKWebview is not listed during UITesting

Time:04-26

I have a UITableview with the below view hierarchy.

UIViewController
  |--UITableView
     |--WKWebview
        |--ScrollView
           |--UIView

The UIView is added once the Webview load is completed and the view appeared properly in the UI. When I run the UITestcases the dynamically added content is not listed during the UITesting.

The below approaches are tried and didn't work.

  • Set isAccessibilityElement false to all the views in the mentioned hierarchy
  • print the app.debugDescription the newly added view contents are not displayed
  • print the XCUIApplication() and here also the newly added view contents are not displayed
  • added the accessibilityIdentifier to all the views the newly added contents are not listed

Not sure whether this is expected behavior or am I doing something wrong here in adding the contents.

Subview code:

[tableViewCell.webView.scrollView addSubview:customView]

Help Appreciated

CodePudding user response:

The issue is fixed by adding the custom view to the accessibility elements list.

[self.view setAccessibilityElements:@[customView]];
  • Related