View
453
Download
3
Category
Tags:
Preview:
DESCRIPTION
What is the meaning of "Mobile UI Automation"? How does it help in making quality assurance more effective? How is automation conducted in practice, and what are the challenges? The source code conversion approach of Eqela can also be used to address the challenges of mobile UI automation. (Presentation slides as presented in the Softech.ph conference)
Citation preview
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
1
Automated testing of mobileapplications on multiple
platforms
Markku Kero / Job and Esther Technologies
June 2014 / Softech.ph
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
2
What is the meaning of “Mobile
UI Automation”?
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
3
Traditional QA procedure
… #100 … #1000 … hours and hours of testing … for each release …
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
4
UI Automation
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
5
import com.android.uiautomator.core.*;import com.android.uiautomator.testrunner.*;
public class MyTestCase extends UiAutomatorTestCase{ public void testnumberone() throws UiObjectNotFoundException, android.os.RemoteException { getUiDevice().wakeUp(); getUiDevice().pressEnter(); UiObject textfield = new UiObject(new UiSelector().className("android.widget.EditText")); textfield.clearTextField(); textfield.setText("This is really cool"); UiObject button = new UiObject(new UiSelector().className("android.widget.Button")); button.click(); UiObject textview = new UiObject(new UiSelector().className("android.widget.TextView").index(1)); assertEquals("Text is incorrect", "This is really cool", textview.getText()); }}
$ <apache-ant-dir>/bin/ant build$ <adt-dir>/sdk/platform-tools adb push bin/MyTestProgram.jar /data/local/tmp$ <adt-dir>/sdk/platform-tools/adb shell uiautomator runtest MyTestProgram.jar \ -c MyTestCase
1. Write the test program
2. Run the tests
3. Read the report
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
6
With automation, full test of an app will no longer take hours
but minutes
The tests are easily repeated for every release
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
7
Perfect, right?
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
.. FOR EACH PLATFORM
BUT TEST PROGRAMS NEED TO BE WRITTEN ..
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
MANY MOBILE PLATFORMS HAVE BUILT-IN CAPABILITIESFOR USER INTERFACE AUTOMATION
UI Automation
JavaScript
UIAutomator
Java
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
public class Main : LayerWidget, EventReceiver{
TextInputWidget input;LabelWidget label;
public void initialize() {base.initialize();var box = BoxWidget.vertical().set_spacing(px("1mm"))
.set_margin(px("1mm"));box.add(input = TextInputWidget.instance());input.set_widget_id("input");box.add(label = LabelWidget.for_string("(enter text)")
.set_font(Font.instance("7mm")));box.add(ButtonWidget.for_string("Click me").set_event("clickme")
.set_widget_id("clickme"));add(CanvasWidget.for_color(Color.instance("#AAAAAA")));add(box);set_draw_color(Color.instance("black"));
}
public void cleanup() {base.cleanup();input = null;label = null;
}
public void on_event(Object o) {label.set_text(input.get_text());
}}
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
// standard iOS UI Automation framework initializationvar target = UIATarget.localTarget();var app = target.frontMostApp();var window = app.mainWindow();
// Set the contents of the text input field// to string "Something"window.textFields()["input"].setValue("Something");
// Click the "Click me" buttonwindow.buttons()["clickme"].tap();
UI Automation test script for iOS
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
import com.android.uiautomator.core.*;import com.android.uiautomator.testrunner.*;
public class MyTestCase extends UiAutomatorTestCase{
public void testSample() throwsUiObjectNotFoundException,android.os.RemoteException
{UiObject textfield = new UiObject(new UiSelector()
.description("input"));textfield.clearTextField();textfield.setText("Something");UiObject button = new UiObject(new UiSelector()
.description("clickme"));button.click();
}}
UIAutomator test script for Android
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
public class MyTestCase extends UiAutomatorTestCase{
public void testSample() throwsUiObjectNotFoundException,android.os.RemoteException
{UiObject textfield = new UiObject(new UiSelector()
.description("input"));textfield.clearTextField();textfield.setText("Something");UiObject button = new UiObject(new UiSelector()
.description("clickme"));button.click();
}}
var target = UIATarget.localTarget();var app = target.frontMostApp();var window = app.mainWindow();window.textFields()["input"].setValue("Something");window.buttons()["clickme"].tap();
SAME PROGRAM WRITTEN TWICE ..
.. SEEMS LIKE A WASTE OF EFFORT
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
BUT TWICE WOULDNOT BE ENOUGH
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
19
Programming LanguageTranslator
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
class MyTestCase : UIAutomatorTestCase{
public void execute() {get_text_field("input").set_text("Something");get_button("clickme").click();
}}
package sample;public class MyTestCase extends com.eqela.libuiautomator.UIAutomatorTestCase{@Override public void execute() {((com.eqela.libuiautomator.UIAutomatorTestCase)this).get_text_field(eq.api.StringStatic.eq_api_StringStatic_for_strptr("input")).set_text(eq.api.StringStatic.eq_api_StringStatic_for_strptr("Something"));((com.eqela.libuiautomator.UIAutomatorTestCase)this).get_button(eq.api.StringStatic.eq_api_StringStatic_for_strptr("clickme")).click();}}
sample.MyTestCase=function(){ com.eqela.libuiautomator.UIAutomatorTestCase.call(this);};// ...P.execute=function(){com.eqela.libuiautomator.UIAutomatorTestCase.prototype.get_text_field.call(this,eq.api.StringStatic.for_strptr("input")).set_text(eq.api.StringStatic.for_strptr("Something"));com.eqela.libuiautomator.UIAutomatorTestCase.prototype.get_button.call(this,eq.api.StringStatic.for_strptr("clickme")).click();}
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
public class UIAutomatorTextFieldAndroid : UIAutomatorTextField{
public static UIAutomatorTextFieldAndroid for_id(String id) {return(new UIAutomatorTextFieldAndroid().initialize(id));
}
ptr field;
public UIAutomatorTextFieldAndroid initialize(String id) {ptr ff;var ip = id.to_strptr();embed {{{
ff = new UiObject(new UiSelector().description(ip));}}}if(ff == null) {
return(null);}field = ff;return(this);
}
public void set_text(String text) {var ff = field;var tp = text.to_strptr();embed {{{
ff.clearTextField();ff.setText(tp);
}}}}
}
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
public class UIAutomatorTextFieldIOS : UIAutomatorTextField{
public static UIAutomatorTextFieldIOS for_id(String id) {return(new UIAutomatorTextFieldIOS().initialize(id));
}
ptr field;
public UIAutomatorTextFieldIOS initialize(String id) {ptr ff;var ip = id.to_strptr();embed {{{
ff = window.textfields()[ip];}}}if(ff == null) {
return(null);}field = ff;return(this);
}
public void set_text(String text) {var ff = field;var tp = text.to_strptr();embed {{{
ff.setValue(tp);}}}
}}
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
public class MyTestCase extends UiAutomatorTestCase{
public void testSample() throwsUiObjectNotFoundException,android.os.RemoteException
{UiObject textfield = new UiObject(new UiSelector()
.description("input"));textfield.clearTextField();textfield.setText("Something");UiObject button = new UiObject(new UiSelector()
.description("clickme"));button.click();
}}
var target = UIATarget.localTarget();var app = target.frontMostApp();var window = app.mainWindow();window.textFields()["input"].setValue("Something");window.buttons()["clickme"].tap();
NO WASTED EFFORT. WRITE THE SCRIPT ONLY ONCE
class MyTestCase : UIAutomatorTestCase{
public void execute() {get_text_field("input").set_text("Something");get_button("clickme").click();
}}
Copyright (c) 2014 Job and Esther Technologies, Inc. All Rights reserved.
24
Ask for more information
markku.kero@jobandesther.com
www.jobandesther.com
www.eqela.com
Recommended