This is a migrated thread and some comments may be shown as answers.

UI testing (with UiTest.JS or anything that works)

1 Answer 37 Views
Integration with other JS libraries
This is a migrated thread and some comments may be shown as answers.
Sergei
Top achievements
Rank 1
Sergei asked on 09 Jan 2014, 05:31 PM
Hi Everybody,

We have troubles finding a working solution for UI testing our Phonegap app built with Kendo Mobile. We've tried UiTest.JS Can anybody share a working recipe for JS driven UI testing? The goal is to drive user session in a browser starting with logging in and then using the features. This would also allow us to do BDD style development. 
First, we found that .trigger('click') doesn't do anything in kendo, so we found that .mousedown().mouseup() creates the required effect.  Now, we have an issue with ajax calls out to the API server.  Bottom line, if someone can share a working setup with some best practices, I'll appreciate it.

<div data-role="modalview" id="modalview-login" style="width: 90%;">
        <div data-role="header">
            <div data-role="navbar">
                <span>Login</span>
                <a id="modalview-cancel-button" data-click="closeModalViewLogin" data-role="button" data-align="right">Cancel</a>
            </div>
        </div>
 
        <ul data-role="listview" data-style="inset">
            <li>
                <label for="username">Username:
                    <input type="email" id="username" placeholder="Enter Username" autofocus/>
                </label>
            </li>
            <li>
                <label for="password">Password:
                    <input type="password" id="password" placeholder="Enter Password"/>
                </label>
            </li>
        </ul>
        <a data-click="logMeIn" id="modalview-login-button" type="button" data-role="button">Login</a>
    </div>
function logMeIn() {
    // console.log("function logMeIn() called.");
    $("#logged-in-text").text("Attempting Login.");
    kendoMobileApplication.showLoading();
 
    var uName = $("#username").val();
    var pWord = $("#password").val();
 
    // Create a session object and attempt login
    var sess = new SessionObj();
 
    // console.log("Starting API call.");
    sess.login(window.SESSIONAPI, uName, pWord, window.SITEKEY, function(s) {
        if (s.isAuthenticated) {
            $("#logged-in-text").text("Login Successful.");
            // kendoMobileApplication.navigate("main.html");
            window.location.href = "main.html";
        } else {
            $("#logged-in-text").text("Login Failed.");
        }
 
        kendoMobileApplication.hideLoading();
        $("#modalview-login").kendoMobileModalView("close");
    }); 
}

describe("Bad Login", function() {
        it("Should display error message if login fields are invalid", function () {
            uit.url("/");
            uit.runs(function($) {
                // display login dialog
                $("#modalview-open-button").mousedown().mouseup();
                expect($("#modalview-login").is(":visible")).toBeTruthy();
 
                // fill in fields and submit form
                $("#username").val("");
                $("#password").val("123456");
                $("#modalview-login-button").mousedown().mouseup();
            });
            uit.runs(function($) {
                expect($("#logged-in-text").text()).toBe("Invalid login/password.");
            });
        });
 
        it("Should display error if invalid login.", function() {
            expect(true).toBe(false);
        });
    });

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Georgiev
Telerik team
answered on 10 Jan 2014, 01:10 PM
Hi Sergei,

We do not officially support "UiTest.JS". However, as for now, there are no reports of any incompatibility issues between the two products.

Generally speaking testing PhoneGap application is complex and difficult task to manage. It depends on many factors – the time and resources available, primary target platform, interface of the application, target audience etc. Choosing the right tools and the best practices is a decision you have to make on your own, as you best know what will suit your application testing needs.

Some of our clients use Selenium AndroidDriver to automate the functional testing of their mobile web applications. However, this is also not officially supported option.

We recommend you to check out Telerik TestStudio for iOS at http://www.telerik.com/automated-testing-tools/ios-testing/ios-application-testing.aspx, which may provide the mobile testing functionality you are looking for.

Regards,
Atanas Georgiev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Integration with other JS libraries
Asked by
Sergei
Top achievements
Rank 1
Answers by
Atanas Georgiev
Telerik team
Share this question
or