import { Given, When, Then } from '@cucumber/cucumber';
import LandingPage from '../pageobjects/landing.page';
import LoginPage from '../pageobjects/login.page';
Given(/^I open the demo app$/, async () => {
await console.log('Mobile app is open');
});
When(/^I lock device$/, async () => {
await driver.lock();
});
When(/^I unlock device$/, async () => {
await driver.unlock();
});
When(/^I navigate to login tab$/, async () => {
await LandingPage.btnLogin_tap();
});
When(
/^I initiate login with ([^"]*)? and ([^"]*)?$/,
async (email, password) => {
await LoginPage.txtEmail_setText(email);
await LoginPage.txtPassword_setText(password);
await LoginPage.btnLogin_tap();
},
);
Then(/^I close the app$/, async () => {
await driver.closeApp();
});
'use strict';
(function () {
function getDriver (callback) {
var interval = window.setInterval(function () {
var testCafeDriver = window['%testCafeDriverInstance%'];
if (testCafeDriver) {
window.clearInterval(interval);
callback(testCafeDriver);
}
}, 50);
}
// NOTE: enable interaction with a page when the last test is completed
var UNLOCK_PAGE_FLAG = 'testcafe-live|driver|unlock-page-flag';
// TestCafe > 0.18.5 required
getDriver(function (testCafeDriver) {
var testCafeCore = window['%testCafeCore%'];
var hammerhead = window['%hammerhead%'];
testCafeDriver.setCustomCommandHandlers('unlock-page', function () {
testCafeCore.disableRealEventsPreventing();
testCafeDriver.contextStorage.setItem(UNLOCK_PAGE_FLAG, true);
return hammerhead.Promise.resolve();
});
var chain = testCafeDriver.contextStorage ? hammerhead.Promise.resolve() : testCafeDriver.readyPromise;
chain.then(function () {
if (testCafeDriver.contextStorage.getItem(UNLOCK_PAGE_FLAG))
testCafeCore.disableRealEventsPreventing();
});
});
})();
// https://webdriver.io/docs/api/appium.html
describe('Exercice 3', function() {
it('Can open notifications center', function() {
driver.openNotifications()
driver.pause(3000)
})
it('Can lock device', function() {
driver.lock()
driver.pause(3000)
expect(driver.isLocked()).toBe(true)
driver.unlock()
})
it('Can open settings app', function() {
// android
// adb shell dumpsys window windows | grep -E 'mCurrentFocus'
driver.startActivity('com.android.settings', 'com.android.settings.Settings')
driver.pause(3000)
// ios
// https://emm.how/t/ios-12-list-of-default-apps-and-bundle-id-s/790
// driver.launchApp({ bundleId: "com.apple.Preferences" })
})
})
angular.module("gdCameApp").controller("ItemsController",
[
"$rootScope", "$scope", "gameData", "gdCameApiService",
function ($rootScope, $scope, gameData, gdCameApiService) {
$scope.items = [];
$scope.itemsGroups = [];
gameData.then(function (data) {
$scope.items = data.items;
var indexInGroup = 0;
var itemsGroup = [];
$scope.items.forEach(function (value, index) {
if (indexInGroup === 4) {
$scope.itemsGroups.push(itemsGroup);
itemsGroup = [];
indexInGroup = 0;
}
itemsGroup.push(value);
indexInGroup++;
});
if (itemsGroup.length > 0) {
itemsGroup.push(new Array(4 - itemsGroup.length));
$scope.itemsGroups.push(itemsGroup);
}
});
$scope.$on("update.items",
function (event, value) {
$scope.items = value.items;
});
$scope.buyFundDriver = function (fundDriverId) {
var oldFundDriver = $scope.items.filter(function (item, index) {
return item.id === fundDriverId;
})[0];
if (oldFundDriver && oldFundDriver.unlockBalance > $rootScope.gameData.cash.counters[0].value) {
return;
}
gdCameApiService.buyFundDriver(fundDriverId)
.then(function (value) {
if (value.data == undefined) return;
var itemIndex;
var oldFundDriver = $scope.items.filter(function (item, index) {
itemIndex = index;
return item.id === value.data.itemBuyInfo.id;
})[0];
if (oldFundDriver != undefined) {
oldFundDriver.bought = value.data.itemBuyInfo.bought;
oldFundDriver.price = value.data.itemBuyInfo.price;
if (value.data.modifiedCountersInfo != undefined) {
$rootScope.$broadcast("counters.update", value.data.modifiedCountersInfo);
}
}
});
};
}
]);
/**
* (C) Copyright 2015 Manuel Martins.
*
* This module is inspired by json_file_system.
* (json_file_system is Copyright (c) 2014 Jalal Hejazi,
* Licensed under the MIT license.)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Created by: ManuelMartins
* Created on: 26-01-2016
*
*/
'use strict';
var Memory = require('./memory');
var Disk = require('./disk');
/**
* Provides the most common I/O operations.
*
* @param {object} options
* @param {object} options.db
* @param {object} options.db._
* @param {string} options.db._._driver
* @constructor
*/
function DataHandler(options) {
options = options || {};
var dataHandler = options.db._db._driver || 'disk';
switch (dataHandler) {
// load the driver to be used just once
case 'memory':
this.dataHandlerDriver = new Memory(options);
break;
case 'disk':
default:
this.dataHandlerDriver = new Disk(options);
}
}
/**
* Writes a list of objects to the data driver
*
* @param content the content to write
* @param callback
*/
DataHandler.prototype.set = function write(content, callback) {
return this.dataHandlerDriver.set(content, callback);
};
/**
* Reads a list of objects from the data driver
*
* @param callback
*/
DataHandler.prototype.get = function read(callback) {
return this.dataHandlerDriver.get(callback);
};
/**
* Locks the data provider
*
* @param callback
*/
DataHandler.prototype.lock = function read(callback) {
return this.dataHandlerDriver.lock(callback);
};
/**
* Unlocks the data provider
*
* @param callback
*/
DataHandler.prototype.unlock = function read(callback) {
return this.dataHandlerDriver.unlock(callback);
};
module.exports = DataHandler;
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.