In my IOS Application I've created a WKWebview of a website that I'm not owning myself. So inside my:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
I've a couple of .evaluateJavascript that add data to textfields, removes elements on the website etc.
But I'm trying to add an .evaluateJavascript (Or other) that will recognize a button click on the website.
I've tried to add this by doing this code:
bookingView.evaluateJavaScript("document.getElementById('optional_button').onclick();") { (key, err) in
if let err = err{
print(err.localizedDescription)
}
else{
print("You tapped the button!")
}
But that doesnt work. Everytime I open up the WebView the app prints out "You tapped the button" even if I didn't.
So, can I detect a button click with evaluateJavascript?