How to use device.install method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

device.js

Source:device.js Github

copy

Full Screen

1$(document).ready(function() {2 $('#device_install_list').on('click', 'tr.row', function() {3 device_install_Edit(4 $(this).parents('[bind_id]').attr('bind_id'),5 $(this).parents('[object_id]').attr('object_id'),6 $(this).attr('device_install_id')7 );8 });9 $('#device_install_pop tbody').on('click', 'div.device_link', function() {10 device_Edit();11 });12 $('#device_pop').on('click', 'tr.switch', function(){13 if($(this).attr('checked')=='checked'){14 $(this).removeAttr('checked');15 $('#device_pop tr.switch td.text_right').html('Аренда');16 } else {17 $(this).attr('checked','checked');18 $('#device_pop tr.switch td.text_right').html('Продано');19 }20 });21 $('#device_install_pop [name=device]').autocomplete({22 source: function(request, response) {23 $.ajax({ url:'/system/client/object/device/ajax/search_device/', type:'get', dataType:'json',24 data:{25 name: request.term,26 install: true,27 exclude_object: $('#device_install_pop').attr('object_id'),28 limit: 729 },30 success: function(data) {31 response($.map(data['device_list'], function(item) {32 return { label:item.name, device_id:item.id, install:item.install }33 }));34 }35 });36 },37 select: function(event, ui) {38 if(ui.item){39 $(this).attr('device_id',ui.item.device_id);40 $('#device_install_pop .device_link').show();41 console.log(ui.item.install);42 }43 else {44 $(this).val('');45 $(this).removeAttr('device_id');46 }47 },48 change: function(event, ui) {49 if(ui.item){50 $(this).attr('device_id',ui.item.device_id);51 $('#device_install_pop .device_link').show();52 console.log(ui.item.install);53 }54 else {55 $(this).val('');56 $(this).removeAttr('device_id');57 }58 },59 minChars: 2, zIndex: 100, deferRequestBy: 20060 }).data("ui-autocomplete")._renderItem = function( ul, item ) {61 if(item.install=='yes') return $("<li>").append( '<a class="green">' + item.label + "</a>" ).appendTo( ul );62 else return $("<li>").append( "<a>" + item.label + "</a>" ).appendTo( ul );63 };64 $('.user_right').autocomplete({65 source: function(request, response) {66 $.ajax({ url: '/system/sentry_user/ajax/search/', type:'get', dataType: "json", data: {67 full_name: request.term,68 user_post_id: 'all',69 limit: 10 },70 success: function(data) {71 response($.map(data['user_list'], function(item) {72 return {73 label: item.full_name,74 user_id: item.id75 }76 }));77 }78 });79 },80 change: function(event, ui) {81 if(ui.item){82 var user_id = ui.item.user_id;83 $(this).attr('user_id',user_id);84 } else {85 $(this).val('');86 $(this).removeAttr('user_id');87 }88 },89 minChars: 2, zIndex: 100, deferRequestBy: 20090 });91 install_Validate()92});93function device_install_Reset(){94 $('#device_install_pop').removeAttr('device_install_id');95 $("#device_install_pop input").each(function(){ $(this).val(''); });96 $("#device_install_pop textarea").each(function(){ $(this).val(''); });97 $('#device_install_pop [name=device]').removeAttr('disabled').removeAttr('device_id');98}99function device_install_Draw(object_id,device_install_list){100 // Усли есть подключение101 var td_bg = '';102 if($('.object__item[object_id='+object_id+'] [event_type=client_object_disconnect] [name=event_date]').text()!=''){103 td_bg = 'class="bg_red"';104 }105 else if($('.object__item[object_id='+object_id+'] [event_type=client_object_connect] [name=event_date]').text()!=''){106 td_bg = 'class="bg_green"';107 }108 var table_list = $('[object_id='+object_id+'] div.device_list table');109 for(var install_key in device_install_list){110 var td_bg_ = td_bg;111 var install = device_install_list[install_key];112 var priority = install['priority'];113 var uninstall = '';114 if(install['uninstall_date']) {115 uninstall = ' Снято: '+install['uninstall_date']+' / '+install['uninstall_user__full_name'];116 td_bg_ = '123';117 }118 var tr = '<tr class="row" action="device_install" device_install_id="'+install['id']+'" sentry_user_id="'+install['install_user']+'">' +119 '<td class="padding">'+install['device__device_type__name']+'</td>' +120 '<td class="padding">'+install['device__name']+'</td>' +121 '<td class="padding">'+install['install_date']+' / '+install['install_user__full_name']+uninstall+'</td>' +122 '<td '+td_bg_+'><div class="btn_ui btn_28 disabled" action="device_install_priority" icon="'+priority+'"><div class="icon"></div></div></td>' +123 '</tr>';124 table_list.find('thead').show();125 table_list.find('tbody').append(tr);126 }127}128function device_install_Edit(bind_id, object_id, device_install_id){129 //console.log(object_id,device_install_id);130 device_install_Reset();131 $('#device_install_pop').attr('bind_id', bind_id);132 $('#device_install_pop').attr('object_id', object_id);133 $('#device_install_pop .device_link').hide();134 $('#device_install_pop [action=device_install_delete]').hide();135 if(!device_install_id){136 $('#device_install_pop').removeAttr('device_install_id');137 }138 else {139 $('#device_install_pop .device_link').show();140 $('#device_install_pop').attr('device_install_id',device_install_id);141 $('#device_install_pop [name=device]').attr('disabled','disabled');142 $.ajax({ url:'/system/client/object/device/ajax/get_install/?device_install_id='+device_install_id+'&bind_id='+bind_id,143 type:'get', dataType:'json', traditional:true,144 success: function(data){145 $('#device_install_pop [action=device_install_delete]').show();146 data = data['device_install_list'][0];147 $('#device_install_pop').attr('device_install_id', data['id'] );148 $('#device_install_pop [name=device]').val( data['device__name'] );149 $('#device_install_pop [name=device]').attr('device_id', data['device_id'] );150 $('#device_install_pop [name=device__series]').val( data['device__series'] );151 $('#device_install_pop [name=device__number]').val( data['device__number'] );152 $('#device_install_pop [name=install_date]').val( data['install_date'] );153 $('#device_install_pop [name=install_user]').val(data['install_user_id'] );154 $('#device_install_pop [name=uninstall_date]').val( data['uninstall_date'] );155 $('#device_install_pop [name=uninstall_user]').val(data['uninstall_user_id'] );156 $('#device_install_pop [name=comment]').val( data['comment'] );157 eachWire('set',data['data']);158 }159 });160 }161 popMenuPosition('#device_install_pop','single');162}163function device_install_Update(){164 console.log('device install Update');165 var device_array = get_each_value('#device_install_pop');166 device_array['bind'] = $('#device_install_pop').attr('bind_id');167 device_array['object'] = $('#device_install_pop').attr('object_id');168 device_array['device_install'] = $('#device_install_pop').attr('device_install_id');169 var device_id = $('#device_install_pop input[name=device]').attr('device_id');170 if(device_id) device_array['device'] = device_id;171 device_array['data'] = eachWire('get');172 $.ajax({ url:'/system/client/object/device/ajax/install_update/',173 type:'post', dataType:'json', traditional:true, data:device_array,174 success: function(data){175 if(data['error']) alert( data['error'] );176 else {177 popMessage('Сохранено','green');178 contract_Reset();179 $('#device_install_pop').hide();180 }181 }182 });183}184function eachWire(action, data){185 if(action=='get') {186 var data_array = {};187 $("#wires tbody tr").each(function() {188 var check = false;189 if($(this).find('.switch').attr('checked')) check = true;190 data_array[$(this).attr('name')] = {191 'description': $(this).find('[name=description]').val(),192 'zone': $(this).find('[name=zone]').val(),193 'time24': check194 };195 });196 return JSON.stringify(data_array);197 }198 else if(action=='set') {199 console.log(data);200 $('#wires tbody input').val('');201 $('#wires tbody td.switch').attr('checked','checked');202 var wires = jQuery.parseJSON(data);203 for(key in wires){204 console.log(key);205 var wire = wires[key];206 console.log(wire);207 console.log(wire['description']);208 var tr = $('#wires tbody tr[name='+key+']');209 tr.find('[name=description]').val(wire['description']);210 tr.find('[name=zone]').val(wire['zone']);211 if(wire['time24']==false) tr.find('td.switch').removeAttr('checked');212 }213 }214}215function device_install_Delete(){216 var device_install_id = $('#device_install_pop').attr('device_install_id');217 $.ajax({ url:'/system/client/object/device/ajax/install_delete/?device_install_id='+device_install_id,218 type:'get', dataType:'json', traditional:true,219 success: function(data){220 $('#device_install_list tr[device_install_id='+device_install_id+']').remove();221 contract_Reset();222 }223 });224}225function device_install_Priority(install_id){226 var ajax_array = {'install_id': install_id};227 $.ajax({ url:'/system/directory/device/ajax/priority/', type:'post', dataType:'json', data:ajax_array,228 success: function(data){229 device_Edit();230 }231 });232}233function device_Edit(){234 var device_id = $('#device_install_pop input[name=device]').attr('device_id');235 $.ajax({ url:'/system/directory/device/ajax/get/?device='+device_id, type:'get', dataType:'json', traditional:true,236 success: function(data){237 $('#device_pop [name=name]').val( data['device']['name'] );238 $('#device_pop [name=device_type]').val( data['device']['device_type'] );239 $('#device_pop [name=series]').val( data['device']['series'] );240 $('#device_pop [name=number]').val( data['device']['number'] );241 $('#device_pop #device_pop_install_list tbody tr').remove();242 $('#device_pop [name=belong].switch').removeAttr('checked');243 if(data['device']['belong']=='sell'){244 $('#device_pop tr.switch').attr('checked','checked');245 $('#device_pop tr.switch td.text_right').html('Продано');246 } else {247 $('#device_pop tr.switch td.text_right').html('Аренда');248 }249 var install_count = 0;250 for(var key in data['device']['install_list']){251 install_count++;252 var install = data['device']['install_list'][key];253 var item = '<tr install_id="'+install['id']+'"><td class="middle">' +254 '<a class="inline_block" href="/system/client/'+install['client']+'/contract/'+install['contract']+'/" >' +255 '<div class="padding">'+install['object__name']+'</div></a>' +256 '</td><td><div class="btn_ui btn_28 left" action="device_install_priority" icon="'+install['priority']+'"><div class="icon"></div></div></td></tr>';257 $('#device_pop #device_pop_install_list tbody').append(item);258 $('#device_pop #device_pop_install_list').attr('install_count',install_count);259 }260 }261 });262 popMenuPosition('#device_pop','multiple');263}264function device_Update() {265 var device_array = get_each_value('#device_pop');266 device_array['device'] = $('#device_install_pop input[name=device]').attr('device_id');267 if($('#device_pop [name=belong].switch').is('[checked]')) device_array['belong'] = 'sell'; else device_array['sell'] = 'rent';268 if($('#device_pop tr[name=belong]').is('[checked]')) device_array['belong'] = 'sell'; else device_array['belong'] = 'rent';269 device_array['device_type_id'] = $('#device_pop [name=device_type]').val();270 $.ajax({ url:'/system/directory/device/ajax/update/', type:'post', dataType:'json', data:device_array,271 success: function(data){272 if(data['error']){273 alert(data['error']);274 }275 else {276 popMessage('Сохранено','green');277 $('#device_pop').hide();278 contract_Reset();279 }280 }281 });282}283function install_Validate(){284 $.validator.setDefaults({285 submitHandler: function() {286 device_install_Update();287 },288 showErrors: function(map, list) { // there's probably a way to simplify this289 var focussed = document.activeElement;290 if (focussed && $(focussed).is("input, textarea")) {291 $(this.currentForm).tooltip("close", {292 currentTarget: focussed293 }, true)294 }295 this.currentElements.removeAttr("title").removeClass("ui-state-highlight");296 $.each(list, function(index, error) {297 $(error.element).attr("title", error.message).addClass("ui-state-highlight");298 });299 if (focussed && $(focussed).is("input, textarea")) {300 $(this.currentForm).tooltip("open", {301 target: focussed302 });303 }304 }305 });306 // use custom tooltip; disable animations for now to work around lack of refresh method on tooltip307 $('#device_install_pop form').tooltip({308 show: false,309 hide: false310 });311 $('#device_install_pop form').validate({ // validate the comment form when it is submitted312 rules: {313 device: {314 required: true315 },316 install_date: {317 required: true318 },319 install_user: {320 required: true321 }322 },323 messages: {324 device: {325 required: "Необходимо устройство"326 },327 install_date: {328 required: "Необходим день установки"329 },330 install_user: {331 required: "Необходим установщик"332 }333 }334 });...

Full Screen

Full Screen

device.spec.js

Source:device.spec.js Github

copy

Full Screen

...125 });126 it('should get the full target object if only id is specified', () => {127 const targetId = DEVICE_LIST[0];128 spyOn(device, 'resolveTarget').and.returnValue(Promise.resolve(target));129 return device.install(targetId).then(() => {130 expect(device.resolveTarget).toHaveBeenCalledWith(targetId);131 });132 });133 it('should install to the passed target', () => {134 return device.install(target).then(() => {135 expect(AdbSpy.install).toHaveBeenCalledWith(target.target, undefined, jasmine.anything());136 });137 });138 it('should install the correct apk based on the architecture and build results', () => {139 const buildResults = {140 apkPaths: 'path/to/apks',141 buildType: 'debug',142 buildMethod: 'foo'143 };144 const apkPath = 'my/apk/path/app.apk';145 buildSpy.findBestApkForArchitecture.and.returnValue(apkPath);146 return device.install(target, buildResults).then(() => {147 expect(buildSpy.findBestApkForArchitecture).toHaveBeenCalledWith(buildResults, target.arch);148 expect(AdbSpy.install).toHaveBeenCalledWith(jasmine.anything(), apkPath, jasmine.anything());149 });150 });151 it('should uninstall and reinstall app if failure is due to different certificates', () => {152 AdbSpy.install.and.returnValues(153 Promise.reject('Failed to install: INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES'),154 Promise.resolve()155 );156 AdbSpy.uninstall.and.callFake(() => {157 expect(AdbSpy.install).toHaveBeenCalledTimes(1);158 return Promise.resolve();159 });160 return device.install(target).then(() => {161 expect(AdbSpy.install).toHaveBeenCalledTimes(2);162 expect(AdbSpy.uninstall).toHaveBeenCalled();163 });164 });165 it('should throw any error not caused by different certificates', () => {166 const errorMsg = new CordovaError('Failed to install');167 AdbSpy.install.and.returnValues(Promise.reject(errorMsg));168 return device.install(target).then(169 () => fail('Unexpectedly resolved'),170 err => {171 expect(err).toBe(errorMsg);172 }173 );174 });175 it('should unlock the screen on device', () => {176 return device.install(target).then(() => {177 expect(AdbSpy.shell).toHaveBeenCalledWith(target.target, 'input keyevent 82');178 });179 });180 it('should start the newly installed app on the device', () => {181 const packageId = 'unittestapp';182 const activityName = 'TestActivity';183 AndroidManifestFns.getPackageId.and.returnValue(packageId);184 AndroidManifestGetActivitySpy.getName.and.returnValue(activityName);185 return device.install(target).then(() => {186 expect(AdbSpy.start).toHaveBeenCalledWith(target.target, `${packageId}/.${activityName}`);187 });188 });189 });...

Full Screen

Full Screen

PairDevice.js

Source:PairDevice.js Github

copy

Full Screen

1/**2 * comma SetupEonPairing Screen3 */4import React, {useState, useEffect} from 'react';5import {View, Linking, StyleSheet, Text, Button} from 'react-native';6import {useNavigation} from '@react-navigation/native';7import Permissions from 'react-native-permissions';8import QRCodeScanner from 'react-native-qrcode-scanner';9import X from '../../theme';10import BasePage from '../Util/BasePage';11// import WideButton from '../../components/Util/WideButton';12// import {Alert, Spinner} from '../../components';13import {14 pilotPair,15 fetchDevices,16 fetchDevice,17 fetchDeviceSubscription,18} from '../../actions/Devices';19import gStyles from '../../constants/styles';20export default SetupEonPairing = () => {21 const [wantsCameraPermissions, setWantsCameraPermissions] = useState(false);22 const [hasCameraPermissions, setHasCameraPermissions] = useState(false);23 const [attemptingPair, setAttemptingPair] = useState(false);24 const navigation = useNavigation();25 useEffect(() => {26 Permissions.check('camera').then((response) => {27 if (response == 'authorized') {28 setHasCameraPermissions(true);29 }30 });31 }, []);32 const pairDevice = (imei, serial, pairToken) => {33 return pilotPair(imei, serial, pairToken)34 .then((dongleId) => {35 // dispatch(fetchDevices());36 return Promise.all([37 fetchDevice(dongleId),38 fetchDeviceSubscription(dongleId),39 ]);40 })41 .then(([device, deviceSubscription]) => {42 if (deviceSubscription && deviceSubscription.trial_claimable) {43 navigation.navigate('PrimeSignup', {dongleId: device.dongle_id});44 } else {45 navigation.navigate('AppDrawer');46 }47 });48 };49 const handleConfirmPressed = () => {50 setWantsCameraPermissions(true);51 };52 const handleDismissPressed = () => {53 navigation.navigate('Home');54 };55 const handleViewSetupGuidePressed = () => {56 Linking.openURL('https://comma.ai/setup');57 };58 const handleScannedQRCode = (e) => {59 setAttemptingPair(true);60 let imei, serial, pairToken;61 let qrDataSplit = e.data.split('--');62 if (qrDataSplit.length === 2) {63 imei = qrDataSplit[0];64 serial = qrDataSplit[1];65 } else if (qrDataSplit.length >= 3) {66 imei = qrDataSplit[0];67 serial = qrDataSplit[1];68 pairToken = qrDataSplit.slice(2).join('--');69 }70 if (imei === undefined || serial === undefined) {71 setAttemptingPair(false);72 }73 pairDevice(imei, serial, pairToken).catch((err) => {74 setAttemptingPair(false);75 console.log(err);76 });77 };78 if (attemptingPair) {79 return (80 <View style={styles.setupEonPairingContainer}>81 <Text style={{color: '#fff', fontSize: 20}}>Spinner</Text>82 {/* <Spinner spinnerMessage="Pairing Device..." /> */}83 </View>84 );85 // } else if (wantsCameraPermissions || hasCameraPermissions) {86 } else {87 return (88 <BasePage title="Pair Your Device">89 <View style={styles.setupEonPairingContainer}>90 <X.Entrance style={styles.setupEonPairingCamera}>91 <QRCodeScanner92 onRead={handleScannedQRCode}93 topContent={null}94 bottomContent={null}95 cameraProps={{captureAudio: false}}96 />97 </X.Entrance>98 <View style={styles.setupEonPairingInstruction}>99 <X.Text style={styles.setupEonPairingInstructionText}>100 Place the QR code from your device during setup within the frame.101 </X.Text>102 <Button103 onPress={handleViewSetupGuidePressed}104 title="View Setup Guide"105 color="#fff"></Button>106 </View>107 </View>108 </BasePage>109 );110 // } else {111 // return (112 // <BasePage>113 // <View style={styles.setupEonPairingContainer}>114 // <X.Entrance style={{height: '100%'}}>115 // <Text style={{color:'#fff', fontSize: 20}}>Alert</Text>116 {117 /* <Alert118 title="Camera Access"119 message="We need camera access so you can finish setting up your device"120 dismissButtonAction={handleDismissPressed}121 confirmButtonAction={handleConfirmPressed}122 dismissButtonTitle="Not now"123 confirmButtonTitle="Yes!"124 /> */125 }126 // </X.Entrance>127 // </View>128 // </BasePage>129 // );130 }131};132const styles = StyleSheet.create({133 setupDevicesContainer: {134 backgroundColor: '#080808',135 height: '100%',136 width: '100%',137 },138 setupDevicesHeader: {139 alignItems: 'center',140 paddingLeft: 30,141 paddingRight: 30,142 },143 setupDevicesOptions: {144 marginTop: '10%',145 },146 setupDeviceOptionEON: {147 backgroundColor: 'rgba(255,255,255,.1)',148 borderRadius: 8,149 height: 240,150 marginBottom: '10%',151 alignItems: 'center',152 justifyContent: 'center',153 width: '100%',154 },155 setupDeviceOptionEONImage: {156 maxHeight: 120,157 marginBottom: 20,158 width: '80%',159 },160 setupDeviceOptionPanda: {161 justifyContent: 'center',162 backgroundColor: 'rgba(255,255,255,.1)',163 borderRadius: 8,164 flexDirection: 'row',165 height: 160,166 width: '100%',167 },168 setupDeviceOptionPandaImage: {169 maxWidth: 100,170 },171 setupDeviceOptionPandaText: {172 alignSelf: 'center',173 paddingLeft: '8%',174 },175 setupDeviceOptionShopText: {176 textAlign: 'center',177 },178 setupDeviceContainer: {179 width: '100%',180 },181 setupDeviceHeader: {182 alignItems: 'center',183 height: 50,184 },185 setupDeviceBody: {186 paddingLeft: '3%',187 paddingRight: '3%',188 },189 setupDeviceBodyCentered: {190 height: '90%',191 alignItems: 'center',192 justifyContent: 'center',193 paddingBottom: '20%',194 },195 setupDeviceIntroBodyItem: {196 marginTop: '10%',197 },198 setupDeviceIntroBodyItemHeader: {199 marginBottom: '3.5%',200 },201 setupEonPairingContainer: {202 height: '100%',203 width: '100%',204 },205 setupEonPairingCamera: {206 backgroundColor: 'rgba(255,255,255,.02)',207 height: '50%',208 },209 setupEonPairingInstruction: {210 alignItems: 'center',211 height: '30%',212 justifyContent: 'center',213 padding: '15%',214 paddingBottom: '5%',215 paddingTop: 0,216 fontSize: 30,217 },218 setupEonPairingInstructionHdr: {219 textAlign: 'center',220 color: '#fff',221 fontSize: 30,222 fontWeight: '700',223 },224 setupEonPairingInstructionText: {225 marginTop: '6%',226 marginBottom: '12%',227 textAlign: 'center',228 color: '#aaa',229 fontSize: gStyles.text.small,230 },231 setupEonPairingInstructionButton: {232 backgroundColor: '#fff',233 borderRadius: 30,234 height: 60,235 width: 60,236 },237 setupDeviceInstallPrepContainer: {238 height: '100%',239 width: '100%',240 },241 setupDeviceInstallPrepHeader: {},242 setupDeviceInstallPrepBody: {243 justifyContent: 'center',244 flex: 1,245 },246 setupDeviceInstallSteps: {247 borderTopColor: 'rgba(255,255,255,.2)',248 borderTopWidth: 1,249 paddingTop: 20,250 },251 setupDeviceInstallStep: {252 flexDirection: 'row',253 paddingTop: 20,254 paddingBottom: 20,255 },256 setupDeviceInstallStepNumber: {257 alignItems: 'center',258 backgroundColor: '#fff',259 borderRadius: 15,260 height: 26,261 justifyContent: 'center',262 width: 26,263 },264 setupDeviceInstallStepCopy: {265 paddingLeft: 15,266 paddingRight: 20,267 },268 setupDeviceInstallVideo: {269 backgroundColor: '#fff',270 borderColor: '#fff',271 borderRadius: 8,272 borderWidth: 10,273 marginTop: 10,274 marginBottom: 30,275 height: 200,276 width: '100%',277 alignSelf: 'center',278 },279 setupDeviceInstallVideoCover: {280 borderRadius: 8,281 height: 148,282 },283 setupDeviceInstallVideoButton: {284 alignItems: 'center',285 backgroundColor: '#fff',286 justifyContent: 'center',287 height: 40,288 paddingTop: 10,289 },...

Full Screen

Full Screen

__init__.js

Source:__init__.js Github

copy

Full Screen

1$(document).ready(function(){2 client_id = $('.middleBlock').attr('client_id');3 object_id = $('.middleBlock').attr('object_id');4 contract_id = $('.middleBlock').attr('contract_id');5 if(!contract_id) contract_Add();6 else contract_Reset();7 $('#contract, #object_list').on('click', 'tr', function(){8 var action = $(this).attr('action');9 if(action=='contract'){10 contract_Edit();11 }12 else if(action=='object'){13 object_Edit(14 $(this).parents('.object__item').attr('object_id'),15 $(this).parents('.object__item').attr('bind_id')16 );17 }18 else if(action=='cost'){19 cost_Edit( $(this).parents('[bind_id]').attr('bind_id'), $(this).attr('object_cost_id') );20 }21 else if(action=='event'){22 var contract_id = $(this).parents('#contract').attr('contract_id');23 var bind_id = $(this).parents('[bind_id]').attr('bind_id');24 var object_id = $(this).parents('[object_id]').attr('object_id');25 event_Edit(contract_id, bind_id, object_id, $(this).attr('event_type'), $(this).attr('event_id'));26 }27 else if(action=='bonus') bonus_Edit(28 $(this).parents('.object__item').attr('object_id'),29 $(this).attr('event_type_id'),30 $(this).attr('event_id')31 );32 else if(action=='pause'){33 var bind_id = $(this).parents('.object__item').attr('bind_id');34 var object_cost_id = $(this).parents('.object__item').find('[object_cost_id]').attr('object_cost_id');35 // Без подключения не приостанавается36 var client_object_connect = $(this).parents('.object__item').find('[event_type=client_object_connect] [name=event_date]').text();37 if(client_object_connect=='') popMessage('Не произведено подключение','red');38 else if(!object_cost_id) popMessage('Стоимость не определена','red');39 else if(!!object_cost_id) {40 cost_Edit(bind_id, object_cost_id, 'pause');41 }42 }43 else if(action=='device_install'){44 device_install_Edit(45 $(this).parents('[bind_id]').attr('bind_id'),46 $(this).parents('[object_id]').attr('object_id'),47 $(this).attr('device_install_id'));48 }49 });50 $(document).on('click', 'td[name=pause_list] div.pause__item', function(){51 cost_Edit( $(this).parents('.object__item').attr('bind_id'), $(this).attr('object_cost_id') );52 });53 $(document).on('click', '.btn_ui:not(.disabled)', function(){54 var action = $(this).attr('action');55 if(action=='contract_reset') contract_Reset();56 else if(action=='contract_edit') contract_Edit();57 else if(action=='contract_delete'){58 if(confirm('Удалить договор?')) contract_Delete();59 }60 else if(action=='object_add') object_Edit();61 else if(action=='object_hide') object_Show('hide', $(this).parents('.object__item').attr('bind_id'));62 else if(action=='object_show') object_Show('show', $(this).parents('.object__item').attr('bind_id'));63 else if(action=='object_edit') object_Edit(64 $(this).parents('.object__item').attr('object_id'),65 $(this).parents('.object__item').attr('bind_id')66 );67 else if(action=='object_reset') object_Edit( $('#object_pop').attr('object_id') );68 else if(action=='object_archive') {69 object_Archive($(this).parents('[bind_id]').attr('bind_id'));70 }71 else if(action=='object_unarchive') {72 object_Archive($(this).parents('[bind_id]').attr('bind_id'), 'unarchive');73 }74 else if(action=='search_archive') {75 searchShow();76 }77 else if(action=='object_task') client_object_Task();78 else if(action=='top_object_edit'){79 object_Edit($(this).parents('#contract').attr('service_id'));80 }81 else if(action=='top_object_cost_edit'){82 cost_Edit( $(this).parents('#contract').attr('service_id'), $(this).parents('#contract').attr('object_cost_id') );83 }84 else if(action=='object_delete'){85 //if(8>0){86 if(confirm('Удалить объект?')){ client_object_Delete() }87 //}88 }89 else if(action=='device_install_add'){90 device_install_Edit(91 $(this).parents('[bind_id]').attr('bind_id'),92 $(this).parents('[object_id]').attr('object_id')93 );94 }95 else if(action=='device_install_priority'){96 device_install_Priority( $(this).parents('tr').attr('install_id') );97 }98 else if(action=='device_install_delete'){99 if(confirm('Удалить подключение?')) device_install_Delete();100 }101 else if(action=='device_install_reset'){102 device_install_Edit($('#device_install_pop').attr('service_id'), $('#device_install_pop').attr('device_install_id'));103 }104 else if(action=='device_update') device_Update();105 else if(action=='event_delete'){106 event_Update('event_delete');107 }108 else if(action=='bonus_add'){109 bonus_Edit($(this).parents('.object__item').attr('object_id'), 'manager');110 }111 });112 $('.pop').on('change', 'select', function() {113 var select_name = $(this).attr('name');114 if(select_name=='service_type'){115 service_subtype('set_type',$(this).val());116 }117 /*118 if(select_name=='service_organization' || select_name=='service_type'){119 contract_number_Interval();120 }121 */122 });123 $.datepicker.setDefaults( $.extend($.datepicker.regional["ru"]) );124 $('.datepicker').datepicker({125 showOn: "both",126 changeMonth: true,127 changeYear: true,128 dateFormat: "dd.mm.yy",129 showButtonPanel: true,130 monthNamesShort: $.datepicker.regional[ "ru" ].monthNames,131 onClose: function( selectedDate ) {132 $( "#stopValue" ).datepicker( "option", "minDate", selectedDate );133 }134 });...

Full Screen

Full Screen

run.js

Source:run.js Github

copy

Full Screen

...49 }50 }51 return build.run(build_type).then(function() {52 if (install_target == '--device') {53 return device.install();54 } else if (install_target == '--emulator') {55 return emulator.list_started().then(function(started) {56 var p = started && started.length > 0 ? Q() : emulator.start();57 return p.then(function() { emulator.install(); });58 });59 } else if (install_target) {60 var devices, started_emulators, avds;61 return device.list()62 .then(function(res) {63 devices = res;64 return emulator.list_started();65 }).then(function(res) {66 started_emulators = res;67 return emulator.list_images();68 }).then(function(res) {69 avds = res;70 if (devices.indexOf(install_target) > -1) {71 return device.install(install_target);72 } else if (started_emulators.indexOf(install_target) > -1) {73 return emulator.install(install_target);74 } else {75 // if target emulator isn't started, then start it.76 var emulator_ID;77 for(avd in avds) {78 if(avds[avd].name == install_target) {79 return emulator.start(install_target)80 .then(function() { emulator.install(emulator_ID); });81 }82 }83 return Q.reject('Target \'' + install_target + '\' not found, unable to run project');84 }85 });86 } else {87 // no target given, deploy to device if available, otherwise use the emulator.88 return device.list()89 .then(function(device_list) {90 if (device_list.length > 0) {91 console.log('WARNING : No target specified, deploying to device \'' + device_list[0] + '\'.');92 return device.install(device_list[0]);93 } else {94 return emulator.list_started()95 .then(function(emulator_list) {96 if (emulator_list.length > 0) {97 console.log('WARNING : No target specified, deploying to emulator \'' + emulator_list[0] + '\'.');98 return emulator.install(emulator_list[0]);99 } else {100 console.log('WARNING : No started emulators found, starting an emulator.');101 return emulator.best_image()102 .then(function(best_avd) {103 if(best_avd) {104 return emulator.start(best_avd.name)105 .then(function(emulator_ID) {106 console.log('WARNING : No target specified, deploying to emulator \'' + emulator_ID + '\'.');...

Full Screen

Full Screen

list_devices.js

Source:list_devices.js Github

copy

Full Screen

1import { getDevicesList } from '@/views/BroadcastApp/apis/index.js'2import { LOG_TAG } from '@/views/BroadcastApp/assets/js/index.js'3/**4 * @description 查询设备信息初始化组织树5 */6export function listDeviceList () {7 let params = {8 deviceType: 20199 }10 let idx = 011 let treeD = []12 /**13 * @description 调用设备查询接口14 * @param {Object} params15 */16 getDevicesList(Object.assign({}, params))17 .then(res => {18 if (res.data.code === '00000') {19 let devcList = res.data.data.deviceList20 devcList.forEach((item, index) => {21 if (item.subDeviceList.length > 0) {22 treeD[idx] = {}23 treeD[idx].label = item.deviceName24 treeD[idx].id = item.deviceID25 treeD[idx].children = []26 item.subDeviceList.forEach(function (cur, _idx) {27 if (cur.subDeviceInstallAddress !== null && cur.subDeviceInstallAddress !== '') {28 treeD[idx].children.push({29 subDeviceInstallAddress: cur.subDeviceInstallAddress,30 id: cur.subDeviceID,31 label: cur.subOrgName + ' ' + cur.subDeviceName,32 parentId: item.deviceID,33 parentName: item.deviceName,34 subDeviceInfo: cur.subDeviceID + ':' + cur.subOrgName + '_' + cur.subDeviceName35 })36 }37 })38 idx = idx + 139 }40 })41 this.treeData = treeD42 }43 }).catch(err => {44 console.warn(LOG_TAG + err)45 })...

Full Screen

Full Screen

DeviceApi.js

Source:DeviceApi.js Github

copy

Full Screen

1import RestApi from './RestApi'2let _data = {3}4class DeviceApi {5 static installPathFull(device, ctSerial) {6 //debugger7 let installPath = device.installPath || '',8 installPostScript = device.installPostScript || ''9 if (installPostScript != '')10 installPostScript = '(' + installPostScript + ')'11 if (ctSerial) {12 // let installPostScript1 = device.installPostScript || ''13 return installPath + installPostScript + '-' + device.serial14 }15 return installPath + installPostScript16 }17 static fillDevice(devices, ctSerial) {18 //debugger19 for (let i = 0; i < devices.length; i++) {20 let installPathFull = DeviceApi.installPathFull(devices[i], ctSerial)21 devices[i].installPathFull = installPathFull22 }23 return devices24 }25 static findDevicesBySerial(devices, serial) {26 //debugger27 for (let i = 0; i < devices.length; i++) {28 if (devices[i].serial == serial)29 return i30 }31 return -132 }33}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var assert = require('assert');3var By = webdriver.By;4var until = webdriver.until;5var driver = new webdriver.Builder()6 .forBrowser('selenium')7 .build();8driver.findElement(By.name('q')).sendKeys('webdriver');9driver.findElement(By.name('btnG')).click();10driver.wait(until.titleIs('webdriver - Google Search'), 1000);11driver.quit();12var webdriver = require('selenium-webdriver');13var assert = require('assert');14var By = webdriver.By;15var until = webdriver.until;16var driver = new webdriver.Builder()17 .forBrowser('selenium')18 .build();19driver.findElement(By.name('q')).sendKeys('webdriver');20driver.findElement(By.name('btnG')).click();21driver.wait(until.titleIs('webdriver - Google Search'), 1000);22driver.quit();23var webdriver = require('selenium-webdriver');24var assert = require('assert');25var By = webdriver.By;26var until = webdriver.until;27var driver = new webdriver.Builder()28 .forBrowser('selenium')29 .build();30driver.findElement(By.name('q')).sendKeys('webdriver');31driver.findElement(By.name('btnG')).click();32driver.wait(until.titleIs('webdriver - Google Search'), 1000);33driver.quit();34var webdriver = require('selenium-webdriver');35var assert = require('assert');36var By = webdriver.By;37var until = webdriver.until;38var driver = new webdriver.Builder()39 .forBrowser('selenium')40 .build();41driver.findElement(By.name('q')).sendKeys('webdriver');42driver.findElement(By.name('btnG')).click();43driver.wait(until.titleIs('webdriver - Google Search'), 1000);44driver.quit();45var webdriver = require('s

Full Screen

Using AI Code Generation

copy

Full Screen

1const app = require('appium-xcuitest-driver');2const appiumServer = app.AppiumDriver;3const device = app.Device;4const desiredCaps = {5};6const server = new appiumServer();7const driver = await server.createSession(desiredCaps);8await driver.installApp('path/to/my.app', true);9await driver.removeApp('com.mycompany.myapp');10await driver.launchApp();11await driver.terminateApp('com.mycompany.myapp');12Please read [CONTRIBUTING.md](

Full Screen

Using AI Code Generation

copy

Full Screen

1const appium = require('appium');2const {fs, tempDir} = appium.support;3const {util} = appium;4const { XCUITestDriver } = require('appium-xcuitest-driver');5const { iosUtils } = require('appium-ios-driver');6const { simctl } = iosUtils;7const { getSimulator } = simctl;8(async () => {9 const driver = new XCUITestDriver();10 const caps = {11 };12 await driver.createSession(caps);13 const udid = await getSimulator(caps.udid, caps.platformVersion, caps.deviceName);14 const app = await fs.which(caps.app);15 const tmpRoot = await tempDir.openDir();16 const tmpDir = await tempDir.openDir(tmpRoot);17 const { bundleId, appWithBundleId } = await driver.configureApp(app, tmpDir, false);18 await driver.installApp(bundleId, appWithBundleId, udid);19 await driver.deleteSession();20})();21{22 "scripts": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var appPath = "/Users/username/Downloads/MyApp.app";2var screenshotPath = "/Users/username/Downloads/MyAppScreenshot.png";3var bundleId = "com.company.MyApp";4var deviceName = "iPhone 5";5var platformVersion = "9.3";6var platformName = "iOS";

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const path = require('path');4const desiredCaps = {5 app: path.resolve(__dirname, 'app', 'TestApp.app.zip'),6};7const driver = wd.promiseChainRemote('localhost', 4723);8before(async function () {9 this.timeout(200000);10 await driver.init(desiredCaps);11});12after(async function () {13 await driver.quit();14});15it('should install the app on the device', async function () {16 this.timeout(200000);17 await driver.installApp();18 await driver.sleep(10000);19});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful