I'm using Selenium and Selendroid in order to test my hybrid application. My application contains a native part and WebView. In the WebView I perform ajax calls, listening to async events (using PostMessage).
My problem is: I want to connect my Selendroid test (I'm using Java) to the WebView callbacks. The meaning is I want to be aware in my Selendroid test about events I got in the WebView. For example, I want my test to wait until an event is received in the WebView (inside the JavaScript code).
In my native application I'm using addJavascriptInterface in order to connect my native part and the WebView, so my native app is aware about the events. How can I pass these event to the test code?
My first try was to add EditText inside my native part, and when any event is received in the webview, the native part is notified via the JavaScriptInterface an update this EditText. Then I tried to wait until the text to be present in the element ( using wait.until(ExpectedConditoins.textToBePresentInElement(...)) ) but the problem is the WebView is opened and hides the native EditText view so I can't actually listen for changes in the EditText and my test getting error.
My second try was to create a log file and write every log from the native into this file. Then in the test code to connect to this file and wait for new line to be shown. The problem is I don't know if I can, and how to do this.
My question is, what is the best way to be aware in the test code about events received in the JavaScript code inside the WebView.
0 comments:
Post a Comment