@Override public void handleJsPrompt( String url, String message, String defaultValue, JsPromptResultReceiver receiver) { TraceEvent.begin(); if (mWebChromeClient != null) { final JsPromptResult res = new JsPromptResultReceiverAdapter(receiver).getPromptResult(); if (TRACE) Log.d(TAG, "onJsPrompt"); if (!mWebChromeClient.onJsPrompt(mWebView, url, message, defaultValue, res)) { new JsDialogHelper(res, JsDialogHelper.PROMPT, defaultValue, message, url) .showDialog(mWebView.getContext()); } } else { receiver.cancel(); } TraceEvent.end(); }
@Override public boolean onJsPrompt( WebView view, String url, String message, String defaultValue, JsPromptResult r) { if (message != null && message.startsWith("calabash:")) { r.confirm("CALABASH_ACK"); System.out.println("onJsPrompt: " + message); result.message = message.replace("calabash:", ""); eventHandled.open(); return true; } else { if (mWebChromeClient == null) { r.confirm("CALABASH_ERROR"); return true; } else { return mWebChromeClient.onJsPrompt(view, url, message, defaultValue, r); } } }
/** * Overrides onJsPrompt in order to create {@code WebElement} objects based on the web elements * attributes prompted by the injections of JavaScript */ @Override public boolean onJsPrompt( WebView view, String url, String message, String defaultValue, JsPromptResult r) { if (message != null && (message.contains(";,") || message.contains("robotium-finished"))) { if (message.equals("robotium-finished")) { webElementCreator.setFinished(true); } else { webElementCreator.createWebElementAndAddInList(message, view); } r.confirm(); return true; } else { if (originalWebChromeClient != null) { return originalWebChromeClient.onJsPrompt(view, url, message, defaultValue, r); } return true; } }