Hello,
I’m new to Appium. I decided to dig into Appium because, from my understanding, the NativeScript team uses it. I have an app that I’m building with NativeScript. I would like to write my functional tests using Jasmine. However, I have not found an example of testing a NativeScript app via Appium. For example, I have the following:
login.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<GridLayout columns="*, *" rows="auto, auto, auto, auto, auto, auto" marginLeft="8" marginRight="8">
<Border backgroundColor="red" row="0" col="0" colSpan="2">
<Label text="{{ errorMessage }}" />
</Border>
<Label text="Username" row="1" col="0" class="label" colSpan="2" />
<Border borderWidth="1" borderColor="#000" row="2" col="0" colSpan="2">
<TextField text="{{ username }}" hint="username" />
</Border>
<Label text="Password" row="3" col="0" class="label" colSpan="2" />
<Border borderWidth="1" borderColor="#000" row="4" col="0" colSpan="2">
<TextField text="{{ password }}" hint="password" secure="true" />
</Border>
<Button text="Login" tap="loginButton_Tap" row="5" col="0" />
</GridLayout>
</Page>
login.js
var LoginViewModel = require('./loginViewModel');
var frameModule = require("ui/frame");
var viewModel = new LoginViewModel();
function pageLoaded(args) {
var page = args.object;
page.bindingContext = viewModel;
page.actionBar.title = 'Login';
}
exports.pageLoaded = pageLoaded;
function loginButton_Tap(args) {
viewModel.authenticate();
}
exports.loginButton_Tap = loginButton_Tap;
loginViewModel.js
var observable = require("data/observable");
function LoginViewModel() {
this.errorMessage = 'Oops';
}
LoginViewModel.prototype = new observable.Observable();
LoginViewModel.prototype.authenticateUser = function() {
if(this.username.length === 0) {
this.errorMessage = 'Where is your username?';
return;
}
this.errorMessage = 'Not connected to internet.';
};
module.exports = LoginViewModel;
I would love to figure out how to test my login page using Appium with Jasmine. Yet, I’m totally lost at this point. I have two big challenges that are throwing me for a loop:
- How to start a test from gulp. I know how to run Jasmine tests from Gulp. However, I can’t figure out how to do it with Appium.
- How to actually interact with the elements on the screen. For example, how do I enter values into the form and click the button with an automated test using Appium.
Thank you for any insights.