I have a hybrid iOS application. One of the view's is a WkWebView which loads a html file.
To test this app, I have used Google's EarlGrey framework. It works great with iOS's native UI elements. However, I am unable to test the UI elements in the html. Here is the line that fails while running the XCTest:
EarlGrey.select(elementWithMatcher: grey_accessibilityID("page_view")).perform(grey_javaScriptExecution("document.getElementById('myLegend').click()", nil))
The failure message is:
Exception Name: ConstraintFailedException
Exception Reason: Cannot perform action due to constraint(s) failure.
Exception with Action: {
"Action Name" : "Execute JavaScript",
"Element Description" : "<WKWebView:0x7ff6ca0b2a00; AX=N; AX.id='page_view'; AX.frame={{0, 0}, {414, 736}}; AX.activationPoint={207, 368}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 736}}; opaque; alpha=1>",
"Failed Constraint(s)" : "kindOfClass('UIWebView')",
"All Constraint(s)" : "(!(isSystemAlertViewShown) && kindOfClass('UIWebView'))",
"Recovery Suggestion" : "Adjust element properties so that it matches the failed constraint(s)."
}
I have checked the UI hierarchy stack that EarlGrey prints in the console, I cannot spot the UI elements in the html.
Any suggestions on how EarlGrey can be used to test html loaded in WKWebView?
Thanks, Reshma