How to use recorder.stop method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

flash-audio-recorder.js

Source:flash-audio-recorder.js Github

copy

Full Screen

1(function() {2 function FlashAudioRecorder(onStatusUpdate){3 var Recorder = this;4 var RECORDED_AUDIO_TYPE = "audio/wav";5 Recorder.name = "audio";6 Recorder.filename = "audio.wav"7 var recorder = null;8 var recorderOriginalWidth = 24;9 var recorderOriginalHeight = 24;10 //uploadFormId: null,11 //uploadFieldName: null,12 var isReady = false;13 Recorder.initialize = initialize;14 Recorder.connect = connect;15 Recorder.playBack = playBack;16 Recorder.pausePlayBack = pausePlayBack;17 Recorder.playBackFrom = playBackFrom;18 Recorder.record = record;19 Recorder.stopRecording = stopRecording;20 Recorder.stopPlayBack = stopPlayBack;21 Recorder.observeLevel = observeLevel;22 Recorder.stopObservingLevel = stopObservingLevel;23 Recorder.observeSamples = observeSamples;24 Recorder.stopObservingSamples = stopObservingSamples;25 Recorder.resize = resize;26 Recorder.defaultSize = defaultSize;27 Recorder.show = show;28 Recorder.hide = hide;29 Recorder.duration = duration;30 Recorder.getBase64 = getBase64;31 Recorder.getBlob = getBlob;32 Recorder.getCurrentTime = getCurrentTime;33 Recorder.isMicrophoneAccessible = isMicrophoneAccessible;34 Recorder.updateForm = updateForm;35 Recorder.showPermissionWindow = showPermissionWindow;36 Recorder.configure = configure;37 Recorder.setUseEchoSuppression = setUseEchoSuppression;38 Recorder.setLoopBack = setLoopBack;39 Recorder.base64toBlob = base64toBlob;40 Recorder.get_wav_data = get_wav_data;41 Recorder.fwr_event_handler = fwr_event_handler;42 //Report interface43 Recorder.start = record;44 Recorder.stop = stopRecording;45 Recorder.getWavData = get_wav_data;46 function initialize(onStatusUpdate){47 Recorder.onStatusUpdate = onStatusUpdate;48 var $level = $('.level .progress');49 var flashvars = {'upload_image': 'static/images/mic.png'};50 var params = {};51 var attributes = {'id': RECORDER_APP_ID, 'name': RECORDER_APP_ID, "wmode": "transparent"};52 swfobject.embedSWF("static/swf/recorder.swf", "flashcontent", recorderOriginalWidth, recorderOriginalHeight, "11.0.0", "", flashvars, params, attributes);53 window.fwr_event_handler = fwr_event_handler;54 };55 function connect(name, attempts) {56 if(navigator.appName.indexOf("Microsoft") != -1) {57 Recorder.recorder = window[name];58 } else {59 Recorder.recorder = document[name];60 }61 if(attempts >= 40) {62 return;63 }64 // flash app needs time to load and initialize65 if(Recorder.recorder && Recorder.recorder.init) {66 Recorder.recorderOriginalWidth = Recorder.recorder.width;67 Recorder.recorderOriginalHeight = Recorder.recorder.height;68 /*if(Recorder.uploadFormId && $) {69 var frm = $(Recorder.uploadFormId);70 Recorder.recorder.init(frm.attr('action').toString(), Recorder.uploadFieldName, frm.serializeArray());71 }*/72 Recorder.recorder.show();73 Recorder.showPermissionWindow();74 Recorder.onStatusUpdate({status: "ready"})75 return;76 }77 setTimeout(function() {Recorder.connect(name, attempts+1);}, 100);78 }79 function playBack(name) {80 // TODO: Rename to `playback`81 Recorder.recorder.playBack(name);82 }83 function pausePlayBack(name) {84 // TODO: Rename to `pausePlayback`85 Recorder.recorder.pausePlayBack(name);86 }87 function playBackFrom(name, time) {88 // TODO: Rename to `playbackFrom`89 Recorder.recorder.playBackFrom(name, time);90 }91 function record(name, filename) {92 Recorder.recorder.record(Recorder.name, Recorder.filename);93 }94 function stopRecording() {95 Recorder.recorder.stopRecording();96 }97 function stopPlayBack() {98 // TODO: Rename to `stopPlayback`99 Recorder.recorder.stopPlayBack();100 }101 function observeLevel() {102 Recorder.recorder.observeLevel();103 }104 function stopObservingLevel() {105 Recorder.recorder.stopObservingLevel();106 }107 function observeSamples() {108 Recorder.recorder.observeSamples();109 }110 function stopObservingSamples() {111 Recorder.recorder.stopObservingSamples();112 }113 function resize(width, height) {114 Recorder.recorder.width = width + "px";115 Recorder.recorder.height = height + "px";116 }117 function defaultSize() {118 Recorder.resize(Recorder.recorderOriginalWidth, Recorder.recorderOriginalHeight);119 }120 function show() {121 Recorder.recorder.show();122 }123 function hide() {124 Recorder.recorder.hide();125 }126 function duration(name) {127 // TODO: rename to `getDuration`128 return Recorder.recorder.duration(name || Recorder.uploadFieldName);129 }130 function getBase64(name) {131 var data = Recorder.recorder.getBase64(name);132 return 'data:' + RECORDED_AUDIO_TYPE + ';base64,' + data;133 }134 function getBlob(name) {135 var base64Data = Recorder.getBase64(name).split(',')[1];136 return base64toBlob(base64Data, RECORDED_AUDIO_TYPE);137 }138 function getCurrentTime(name) {139 return Recorder.recorder.getCurrentTime(name);140 }141 function isMicrophoneAccessible() {142 return Recorder.recorder.isMicrophoneAccessible();143 }144 function updateForm() {145 /*var frm = $(Recorder.uploadFormId);146 Recorder.recorder.update(frm.serializeArray());*/147 }148 function showPermissionWindow (options) {149 Recorder.resize(240, 160);150 // need to wait until app is resized before displaying permissions screen151 var permissionCommand = function() {152 if (options && options.permanent) {153 Recorder.recorder.permitPermanently();154 } else {155 Recorder.recorder.permit();156 }157 };158 setTimeout(permissionCommand, 1);159 }160 function configure(rate, gain, silenceLevel, silenceTimeout) {161 rate = parseInt(rate || 22);162 gain = parseInt(gain || 100);163 silenceLevel = parseInt(silenceLevel || 0);164 silenceTimeout = parseInt(silenceTimeout || 4000);165 switch(rate) {166 case 44:167 case 22:168 case 11:169 case 8:170 case 5:171 break;172 default:173 throw("invalid rate " + rate);174 }175 if(gain < 0 || gain > 100) {176 throw("invalid gain " + gain);177 }178 if(silenceLevel < 0 || silenceLevel > 100) {179 throw("invalid silenceLevel " + silenceLevel);180 }181 if(silenceTimeout < -1) {182 throw("invalid silenceTimeout " + silenceTimeout);183 }184 Recorder.recorder.configure(rate, gain, silenceLevel, silenceTimeout);185 }186 function setUseEchoSuppression(val) {187 if(typeof(val) != 'boolean') {188 throw("invalid value for setting echo suppression, val: " + val);189 }190 Recorder.recorder.setUseEchoSuppression(val);191 }192 function setLoopBack(val) {193 if(typeof(val) != 'boolean') {194 throw("invalid value for setting loop back, val: " + val);195 }196 Recorder.recorder.setLoopBack(val);197 }198 function base64toBlob(b64Data, contentType, sliceSize) {199 contentType = contentType || '';200 sliceSize = sliceSize || 512;201 var byteCharacters = atob(b64Data);202 var byteArrays = [];203 for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {204 var slice = byteCharacters.slice(offset, offset + sliceSize);205 var byteNumbers = new Array(slice.length);206 for (var i = 0; i < slice.length; i++) {207 byteNumbers[i] = slice.charCodeAt(i);208 }209 var byteArray = new Uint8Array(byteNumbers);210 byteArrays.push(byteArray);211 }212 return new Blob(byteArrays, {type: contentType});213 }214 function get_wav_data(){215 var b64Data = Recorder.recorder.getBase64(Recorder.name);216 var byteCharacters = atob(b64Data);217 var buffer = new ArrayBuffer(byteCharacters.length);218 var view = new DataView(buffer);219 for (var index = 0; index < byteCharacters.length; ++index) {220 view.setUint8(index, byteCharacters.charCodeAt(index));221 }222 return buffer;223 }224 function fwr_event_handler() {225 var name, $controls;226 switch (arguments[0]) {227 case "ready":228 //FWRecorder.uploadFormId = "#uploadForm";229 //FWRecorder.uploadFieldName = "upload_file[filename]";230 Recorder.connect(RECORDER_APP_ID, 0);231 Recorder.recorderOriginalWidth = appWidth;232 Recorder.recorderOriginalHeight = appHeight;233 console.info('ready');234 break;235 case "microphone_user_request":236 Recorder.showPermissionWindow();237 console.info('microphone_user_request');238 break;239 case "permission_panel_closed":240 Recorder.defaultSize();241 console.info('permission_panel_closed');242 break;243 case "recording":244 //Recorder.hide();245 //Recorder.observeLevel();246 console.info('Flash recording');247 break;248 case "recording_stopped":249 //Recorder.show();250 //Recorder.stopObservingLevel();251 Recorder.onStatusUpdate({status: "record_finish"});252 console.info('recording_stopped');253 //$level.css({height: 0});254 break;255 case "microphone_level":256 Recorder.onStatusUpdate({status: "microphone_level", level: arguments[1]});257 break;258 case "save_pressed":259 //Recorder.updateForm();260 console.info('save_pressed');261 break;262 case "saving":263 name = arguments[1];264 console.info('saving started', name);265 break;266 case "saved":267 name = arguments[1];268 var response = arguments[2];269 console.info('saving success', name, response);270 break;271 case "save_failed":272 name = arguments[1];273 var errorMessage = arguments[2];274 console.info('saving failed', name, errorMessage);275 break;276 case "save_progress":277 name = arguments[1];278 var bytesLoaded = arguments[2];279 var bytesTotal = arguments[3];280 console.info('saving progress', name, bytesLoaded, '/', bytesTotal);281 break;282 }283 }284 }285 window.FlashAudioRecorder = FlashAudioRecorder;...

Full Screen

Full Screen

100_touch_components.t.js

Source:100_touch_components.t.js Github

copy

Full Screen

...34//35// function () {36// var recorderActions = recorder.getRecordedActions();37//38// recorder.stop();39//40// t.is(recorderActions.length, 1);41// t.is(recorderActions[ 0 ].action, 'click');42// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets textfield[name=someField] => .x-form-text');43// }44// )45// })46//47// t.it('Combo field', function (t) {48// var recorder = getRecorder();49//50// t.chain(51// { click : '>> combobox[my=combo]' },52// { click : '[my=combo] => .x-form-arrow-trigger' },53// { click : '[my=combo].getPicker() => .x-boundlist-item:contains(Bar)' },54//55// function () {56// var recorderActions = recorder.getRecordedActions();57//58// recorder.stop();59//60// t.is(recorderActions.length, 3);61// t.is(recorderActions[ 0 ].action, 'click');62// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets combobox[my=combo] => .x-form-text');63//64// t.is(recorderActions[ 1 ].action, 'click');65// t.is(recorderActions[ 1 ].getTarget().target, '#form-widgets combobox[my=combo] => .x-form-trigger');66//67// t.is(recorderActions[ 2 ].action, 'click');68// t.is(recorderActions[ 2 ].getTarget().target, /*#form-widgets */'combobox[my=combo].getPicker() => .x-boundlist-item:contains(Bar)');69// }70// )71// })72//73// t.it('Combo field loaded remotely', function (t) {74// t.requireOk('Ext.ux.ajax.SimManager', function () {75//76// Ext.ux.ajax.SimManager.init({77// delay : 30078// }).register(79// {80// 'foo' : {81// stype : 'json', // use JsonSimlet (stype is like xtype for components)82// data : [83// { id : 1, name : 'user1', age : 25 },84// { id : 2, name : 'user2', age : 35 },85// { id : 3, name : 'user3', age : 45 }86// ]87// }88// }89// );90//91// var recorder = getRecorder();92//93// t.chain(94// { click : '>> combobox[my=combo2]' },95// { click : '[my=combo2] => .x-form-arrow-trigger' },96// { click : '[my=combo2].getPicker() => .x-boundlist-item:contains(user2)' },97//98// function () {99// var recorderEvents = recorder.getRecordedActions();100//101// recorder.stop();102//103// t.is(recorderEvents.length, 3);104// t.is(recorderEvents[0].action, 'click');105// t.is(recorderEvents[0].getTarget().target, '#form-widgets combobox[my=combo2] => .x-form-text');106//107// t.is(recorderEvents[1].action, 'click');108// t.is(recorderEvents[1].getTarget().target, '#form-widgets combobox[my=combo2] => .x-form-trigger');109//110// t.is(recorderEvents[2].action, 'click');111// t.is(recorderEvents[2].getTarget().target, /*#form-widgets */'combobox[my=combo2].getPicker() => .x-boundlist-item:contains(user2)');112// }113// )114// })115// })116//117// t.it('Date field', function (t) {118// var recorder = getRecorder();119//120// t.chain(121// { click : '>> datefield' },122// { click : 'datefield => .x-form-trigger' },123// { click : 'datefield[name=date].getPicker() => .x-datepicker-cell:contains(15)' },124//125// function () {126// var recorderActions = recorder.getRecordedActions();127//128// recorder.stop();129//130// t.is(recorderActions.length, 3);131// t.is(recorderActions[ 0 ].action, 'click');132// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets datefield[name=date] => .x-form-text');133//134// t.is(recorderActions[ 1 ].action, 'click');135// t.is(recorderActions[ 1 ].getTarget().target, '#form-widgets datefield[name=date] => .x-form-trigger');136//137// t.is(recorderActions[ 2 ].action, 'click');138// t.is(recorderActions[ 2 ].getTarget().target, 'datefield[name=date].getPicker() => .x-datepicker-date:contains(15)');139// }140// )141// })142//143// t.it('Time field', function (t) {144// var recorder = getRecorder();145//146// t.chain(147// { click : '>> timefield' },148//149// function () {150// var recorderActions = recorder.getRecordedActions();151//152// recorder.stop();153//154// t.is(recorderActions.length, 1);155// t.is(recorderActions[ 0 ].action, 'click');156// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets timefield[name=time] => .x-form-text');157// }158// )159// })160//161// t.it('Number field', function (t) {162// var recorder = getRecorder();163//164// t.chain(165// { click : '>> numberfield' },166// { click : 'numberfield => .x-form-spinner-up' },167// { click : 'numberfield => .x-form-spinner-down' },168//169// function () {170// var recorderActions = recorder.getRecordedActions();171//172// recorder.stop();173//174// t.is(recorderActions.length, 3);175//176// t.is(recorderActions[ 0 ].action, 'click');177// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets numberfield[name=number] => .x-form-text');178//179// t.is(recorderActions[ 1 ].action, 'click');180// t.is(recorderActions[ 1 ].getTarget().target, '#form-widgets numberfield[name=number] => .x-form-spinner-up');181//182// t.is(recorderActions[ 2 ].action, 'click');183// t.is(recorderActions[ 2 ].getTarget().target, '#form-widgets numberfield[name=number] => .x-form-spinner-down');184// }185// )186// })187//188// t.it('Text area', function (t) {189// var recorder = getRecorder();190//191// t.chain(192// { click : '>> textareafield[name=message]' },193//194// function () {195// var recorderActions = recorder.getRecordedActions();196//197// recorder.stop();198//199// t.is(recorderActions.length, 1);200//201// t.is(recorderActions[ 0 ].action, 'click');202// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets textareafield[name=message] => .x-form-text');203// }204// )205// })206//207// t.it('Checkboxes', function (t) {208// var recorder = getRecorder();209//210// t.chain(211// { click : '#fooChkInput' },212//213// function () {214// var recorderActions = recorder.getRecordedActions();215//216// recorder.stop();217//218// t.is(recorderActions.length, 1);219//220// t.is(recorderActions[ 0 ].action, 'click');221// t.is(recorderActions[ 0 ].getTarget().target, '#fooChkInput');222// }223// )224// })225//226// t.it('Radio', function (t) {227// var recorder = getRecorder();228//229// t.chain(230// { click : '>>[name=radios]' },231//232// function () {233//234// var recorderActions = recorder.getRecordedActions();235//236// recorder.stop();237//238// t.is(recorderActions.length, 1);239//240// t.is(recorderActions[ 0 ].action, 'click');241// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets radiogroup radiofield[name=radios] => .x-form-radio');242// }243// )244// })245//246// t.it('Field set', function (t) {247// var recorder = getRecorder();248//249// t.chain(250// { click : 'fieldset tool[type=toggle] => .x-tool-img' },251// { click : 'fieldset tool[type=toggle] => .x-tool-img' },252// { click : '>>[baa] checkboxfield' },253//254// function () {255// var recorderActions = recorder.getRecordedActions();256//257// recorder.stop();258//259// t.is(recorderActions.length, 3);260//261// t.is(recorderActions[ 0 ].action, 'click');262// t.is(recorderActions[ 1 ].action, 'click');263// t.is(recorderActions[ 2 ].action, 'click');264//265// t.is(recorderActions[ 0 ].getTarget().target, '#form-widgets fieldset[my=checkboxfieldset] tool[type=toggle] => .x-tool-img');266// t.is(recorderActions[ 1 ].getTarget().target, '#form-widgets fieldset[my=checkboxfieldset] tool[type=toggle] => .x-tool-img');267// t.is(recorderActions[ 2 ].getTarget().target, '#form-widgets fieldset[my=checkboxfieldset] checkbox => .x-form-checkbox');268// }269// )270// })271})

Full Screen

Full Screen

AudioRecorder.test.js

Source:AudioRecorder.test.js Github

copy

Full Screen

1//2// This file is part of Canvas.3// Copyright (C) 2017-present Instructure, Inc.4//5// This program is free software: you can redistribute it and/or modify6// it under the terms of the GNU Affero General Public License as7// published by the Free Software Foundation, either version 3 of the8// License, or (at your option) any later version.9//10// This program is distributed in the hope that it will be useful,11// but WITHOUT ANY WARRANTY; without even the implied warranty of12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13// GNU Affero General Public License for more details.14//15// You should have received a copy of the GNU Affero General Public License16// along with this program. If not, see <https://www.gnu.org/licenses/>.17//18/* @flow */19import React from 'react'20import {21 Alert,22} from 'react-native'23import renderer from 'react-test-renderer'24import AudioRecorder from '../AudioRecorder'25import explore from '../../../../test/helpers/explore'26import { AudioRecorder as RNAudioRecorder } from 'react-native-audio'27jest28 .mock('react-native/Libraries/Components/Button', () => 'Button')29 .mock('react-native/Libraries/Components/Touchable/TouchableHighlight', () => 'TouchableHighlight')30 .mock('react-native/Libraries/Components/Touchable/TouchableOpacity', () => 'TouchableOpacity')31 .mock('react-native-audio', () => ({32 AudioRecorder: {33 prepareRecordingAtPath: jest.fn(),34 startRecording: jest.fn(),35 stopRecording: jest.fn(),36 onProgress: jest.fn(),37 onFinished: jest.fn(),38 },39 AudioUtils: require.requireActual('react-native-audio').AudioUtils,40 }))41describe('AudioRecorder', () => {42 const data = {43 status: 'OK',44 audioFileURL: 'file://somewhere.m4a',45 }46 let recorder47 let props48 beforeEach(() => {49 jest.resetAllMocks()50 props = {51 onCancel: jest.fn(),52 onFinishedRecording: jest.fn(),53 }54 recorder = renderer.create(<AudioRecorder {...props} />)55 })56 it('renders default state', () => {57 expect(recorder.toJSON()).toMatchSnapshot()58 })59 it('renders recording state', () => {60 RNAudioRecorder.startRecording = jest.fn(() => RNAudioRecorder.onProgress({61 currentTime: 0,62 }))63 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')64 recordBtn.props.onPress()65 expect(recorder.toJSON()).toMatchSnapshot()66 })67 it('renders stopped state', () => {68 RNAudioRecorder.stopRecording = jest.fn(() => RNAudioRecorder.onFinished(data))69 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')70 recordBtn.props.onPress()71 const stopBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.stopButton')72 stopBtn.props.onPress()73 expect(recorder.toJSON()).toMatchSnapshot()74 })75 it('renders reset state', () => {76 RNAudioRecorder.stopRecording = jest.fn(() => RNAudioRecorder.onFinished(data))77 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')78 recordBtn.props.onPress()79 const stopBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.stopButton')80 stopBtn.props.onPress()81 const resetBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.clearButton')82 resetBtn.props.onPress()83 expect(recorder.toJSON()).toMatchSnapshot()84 })85 it('calls cancel', async () => {86 const cancelBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.cancelButton')87 await cancelBtn.props.onPress()88 expect(props.onCancel).toHaveBeenCalled()89 })90 it('calls onFinishedRecording with data', () => {91 RNAudioRecorder.stopRecording = jest.fn(() => RNAudioRecorder.onFinished(data))92 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')93 recordBtn.props.onPress()94 const stopBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.stopButton')95 stopBtn.props.onPress()96 const doneBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.sendButton')97 doneBtn.props.onPress()98 expect(props.onFinishedRecording).toHaveBeenCalledWith({99 fileName: expect.any(String),100 filePath: data.audioFileURL,101 })102 })103 it('removes cancel button while recording', () => {104 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')105 recordBtn.props.onPress()106 const cancelBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.cancelButton')107 expect(cancelBtn).toBeNull()108 })109 it('alerts start recording errors', () => {110 const spy = jest.fn()111 // $FlowFixMe112 Alert.alert = spy113 RNAudioRecorder.startRecording = jest.fn(() => { throw new Error('fail') })114 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')115 recordBtn.props.onPress()116 expect(spy).toHaveBeenCalled()117 })118 it('alerts stop recording errors', () => {119 const spy = jest.fn()120 // $FlowFixMe121 Alert.alert = spy122 RNAudioRecorder.stopRecording = jest.fn(() => { throw new Error('fail') })123 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')124 recordBtn.props.onPress()125 const stopBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.stopButton')126 stopBtn.props.onPress()127 expect(spy).toHaveBeenCalled()128 })129 it('records finish recording errors', () => {130 const spy = jest.fn()131 // $FlowFixMe132 Alert.alert = spy133 const error = {134 status: 'NOT OK',135 }136 RNAudioRecorder.stopRecording = jest.fn(() => RNAudioRecorder.onFinished(error))137 const recordBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.recordButton')138 recordBtn.props.onPress()139 const stopBtn: any = explore(recorder.toJSON()).selectByID('AudioRecorder.stopButton')140 stopBtn.props.onPress()141 expect(spy).toHaveBeenCalledWith('Recording failed')142 })...

Full Screen

Full Screen

video-recorder.js

Source:video-recorder.js Github

copy

Full Screen

1const sakaiVideoRecorder = {2 recorder: null,3 // Chrome, Safari and Firefox compatibility is related to the mime type and the codec used.4 // See https://caniuse.com/webm for more information.5 // vp8 codec is not supported by firefox for recording.6 // vp9 codec is supported by firefox for recording and playing.7 mimeType: 'video/webm;codecs=vp9',8 player: document.getElementById('submission-preview-player'),9 recordingHiddenInput: document.getElementById('video-submission'),10 recorderSubmissionMimetype: document.getElementById('video-submission-mimetype'),11 recorderStartButton: document.getElementById('btn-start-recording'),12 recorderStopButton: document.getElementById('btn-stop-recording'),13 getBase64 (file) {14 return new Promise( (resolve, reject) => {15 const reader = new FileReader();16 reader.readAsDataURL(file);17 reader.onload = () => resolve(reader.result);18 reader.onerror = (error) => reject(error);19 });20 },21 captureCamera (callback) {22 navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then( function(camera) {23 callback(camera);24 }).catch( function(error) {25 alert('Unable to capture your camera. Please check console logs.');26 console.error(error);27 });28 },29 stopRecordingCallback () {30 sakaiVideoRecorder.player.src = sakaiVideoRecorder.player.srcObject = null;31 sakaiVideoRecorder.player.muted = false;32 sakaiVideoRecorder.player.volume = 1;33 sakaiVideoRecorder.player.src = URL.createObjectURL(sakaiVideoRecorder.recorder.getBlob());34 // TODO: Ideally we want a different mechanism to send the file to the backend as it's sent by a classic form post.35 // Would be good to work on formats and browser support, this could be a serious problem with Safari.36 let fileObject = new File([sakaiVideoRecorder.recorder.getBlob()], "video.webm", {type: sakaiVideoRecorder.mimeType});37 sakaiVideoRecorder.getBase64(fileObject).then(38 (data) => sakaiVideoRecorder.recordingHiddenInput.value = data39 );40 sakaiVideoRecorder.recorder.camera.stop();41 sakaiVideoRecorder.recorder.destroy();42 sakaiVideoRecorder.recorder = null;43 },44 bindStartRecordingButton () {45 sakaiVideoRecorder.recorderStartButton.onclick = function() {46 sakaiVideoRecorder.player.style.display = 'block';47 let submissionPlayers = document.querySelectorAll('#submission-player');48 if (submissionPlayers) {49 submissionPlayers.forEach( (submissionPlayer) => submissionPlayer.style.display = 'none');50 }51 this.disabled = true;52 sakaiVideoRecorder.captureCamera(async function(camera) {53 sakaiVideoRecorder.player.muted = true;54 sakaiVideoRecorder.player.volume = 0;55 sakaiVideoRecorder.player.srcObject = camera;56 sakaiVideoRecorder.recorderSubmissionMimetype.value = sakaiVideoRecorder.mimeType;57 sakaiVideoRecorder.recorder = RecordRTC(camera, {58 type: 'video',59 mimeType: sakaiVideoRecorder.mimeType60 });61 sakaiVideoRecorder.recorder.startRecording();62 // release camera on stopRecording63 sakaiVideoRecorder.recorder.camera = camera;64 sakaiVideoRecorder.recorderStopButton.disabled = false;65 // Scroll the view to the stop recording button.66 setTimeout(() => {67 sakaiVideoRecorder.recorderStopButton.scrollIntoView({block: 'center', behavior: "smooth" })68 }, 100);69 // Important: The default Sakai file size is 20MB so by default is recording around 2:30 of video, increase this value if your instance allows bigger files.70 // TODO: Could be interesting to calculate this depending on the server side property content.upload.max, maybe as future improvement.71 const sleep = (m) => new Promise( (r) => setTimeout(r, m));72 await sleep(150000);73 sakaiVideoRecorder.recorderStopButton.disabled = true;74 sakaiVideoRecorder.recorder.stopRecording(sakaiVideoRecorder.stopRecordingCallback);75 sakaiVideoRecorder.recorderStartButton.disabled = false;76 });77 };78 },79 bindStopRecordingButton () {80 sakaiVideoRecorder.recorderStopButton.onclick = function() {81 this.disabled = true;82 sakaiVideoRecorder.recorder.stopRecording(sakaiVideoRecorder.stopRecordingCallback);83 sakaiVideoRecorder.recorderStartButton.disabled = false;84 };85 }86};87sakaiVideoRecorder.bindStartRecordingButton();...

Full Screen

Full Screen

006_plain_html.t.js

Source:006_plain_html.t.js Github

copy

Full Screen

...10 var actions = recorder.getRecordedActions();11 t.is(actions.length, 1);12 t.is(actions[0].action, 'click');13 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });14 recorder.stop();15 })16 t.it('right click', function (t) {17 recorder.clear();18 recorder.start();19 t.rightClick('#lab');20 var actions = recorder.getRecordedActions();21 t.is(actions.length, 1);22 t.is(actions[0].action, 'contextmenu');23 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });24 recorder.stop();25 });26 t.it('double click', function (t) {27 recorder.clear();28 recorder.start();29 t.doubleClick('#lab');30 var actions = recorder.getRecordedActions();31 t.is(actions.length, 1);32 t.is(actions[0].action, 'dblclick');33 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });34 recorder.stop();35 recorder.clear();36 })37 })38 t.describe('Should record text content of A tag', function (t) {39 var recorder = new Siesta.Recorder.Recorder({ ignoreSynthetic : false });40 recorder.attach(window);41 t.it('simple click', function (t) {42 document.body.innerHTML = '<a>BAR</a>'43 recorder.clear();44 recorder.start();45 t.click('a:contains(BAR)');46 var actions = recorder.getRecordedActions();47 t.is(actions.length, 1);48 t.is(actions[0].action, 'click');49 t.isDeeply(actions[0].getTarget(), { type : 'css', target : 'a:contains(BAR)', offset : t.any() });50 recorder.stop();51 })52 t.it('ignore if A tag contains markup', function (t) {53 document.body.innerHTML = '<a><span>BAR</span></a>'54 recorder.clear();55 recorder.start();56 t.click('a:contains(BAR)');57 var actions = recorder.getRecordedActions();58 t.is(actions.length, 1);59 t.is(actions[0].action, 'click');60 t.is(actions[0].getTarget().type, 'xy');61 recorder.stop();62 })63 })64 t.describe('Should support configuring which unique attribute to prioritize', function (t) {65 document.body.innerHTML = '<div id="foo"><span id="DONT_USE" other_id="USE_ME">Hello</span></div>'66 document.body.innerHTML += '<div other_id="someId"><span class="cls">Hello</span></div>'67 var recorder = new Siesta.Recorder.Recorder({68 extractorConfig : {69 uniqueDomNodeProperty : 'other_id'70 },71 ignoreSynthetic : false72 });73 recorder.attach(window);74 recorder.start();75 t.click('#DONT_USE');76 var actions = recorder.getRecordedActions();77 t.is(actions.length, 1);78 t.is(actions[0].action, 'click');79 t.isDeeply(actions[0].getTarget(), {80 type : 'css',81 target : '[other_id=\'USE_ME\']',82 offset : t.any()83 });84 recorder.stop();85 recorder.clear();86 recorder.start();87 t.click('.cls');88 var actions = recorder.getRecordedActions();89 t.is(actions.length, 1);90 t.is(actions[0].action, 'click');91 t.isDeeply(actions[0].getTarget(), {92 type : 'css',93 target : '[other_id=\'someId\'] .cls',94 offset : t.any()95 });96 recorder.stop();97 })...

Full Screen

Full Screen

Scheduler.js

Source:Scheduler.js Github

copy

Full Screen

1define(function() {2 var Recorder = require("app/Recorder");3 var t = 0,4 duration = 2,5 fps = 30,6 running = false,7 stopping = false,8 looping = false,9 listener = null,10 renderList = null11 function init(pListener) {12 listener = pListener;13 Recorder.init();14 }15 function render() {16 if(running && !stopping) {17 listener.onRender(t);18 advance();19 setTimeout(onTimeout, 1000 / fps);20 }21 else {22 running = false;23 looping = false;24 stopping = false;25 listener.onComplete();26 }27 }28 function onTimeout() {29 requestAnimationFrame(render);30 }31 function advance() {32 var numFrames = duration * fps,33 speed = 1 / numFrames; 34 t += speed;35 if(Math.round(t * 10000) / 10000 >= 1) {36 if(looping) {37 t -= 1;38 Recorder.stop();39 }40 else {41 t = 0;42 stop();43 Recorder.stop();44 Recorder.uploadCommit();45 }46 }47 }48 function loop() {49 if(!running) {50 listener.onStart();51 t = 0;52 stopping = false;53 looping = true;54 running = true;55 Recorder.stop();56 Recorder.start();57 render();58 }59 }60 function stop() {61 if(running) {62 stopping = true;63 t = 0;64 Recorder.stop();65 }66 }67 function playOnce() {68 if(!running) {69 listener.onStart();70 t = 0;71 looping = false;72 running = true;73 render();74 Recorder.stop();75 Recorder.start();76 }77 }78 function isRunning() {79 return running;80 }81 function setDuration(value) {82 duration = value;83 }84 function getDuration() {85 return duration;86 }87 function setFPS(value) {88 fps = value;89 }90 function getFPS() {91 return fps;92 }93 return {94 init: init,95 loop: loop,96 playOnce: playOnce,97 stop: stop,98 render: render,99 isRunning: isRunning,100 setDuration: setDuration,101 getDuration: getDuration,102 setFPS: setFPS,103 getFPS: getFPS104 };...

Full Screen

Full Screen

types.js

Source:types.js Github

copy

Full Screen

1/*2 * Copyright (C) 2015-2018 CloudBeat Limited3 *4 * This program is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * (at your option) any later version.8 */9export const RECORDER_START = 'RECORDER_START';10export const RECORDER_STOP = 'RECORDER_STOP';11export const RECORDER_ADD_STEP = 'RECORDER_ADD_STEP';12export const RECORDER_SET_ACTIVE_FILE = 'RECORDER_SET_ACTIVE_FILE';13export const RECORDER_START_WATCHER = 'RECORDER_START_WATCHER';14export const RECORDER_SET_TIMESTAMP = 'RECORDER_SET_TIMESTAMP';15export const RECORDER_CHANGE_CAN_RECORD = 'RECORDER_CHANGE_CAN_RECORD';16export const RECORDER_STOP_WAIT_CHROME_EXTENSION = 'RECORDER_STOP_WAIT_CHROME_EXTENSION';17export const RECORDER_REPLACE_FILE_CREDENTIALS = 'RECORDER_REPLACE_FILE_CREDENTIALS';...

Full Screen

Full Screen

recorder.js

Source:recorder.js Github

copy

Full Screen

1export const RECORDER_START = 'RECORDER_START';2export const RECORDER_STOP = 'RECORDER_STOP';3export const RECORDER_PAUSE = 'RECORDER_PAUSE';4export const RECORDER_RESUME = 'RECORDER_RESUME';5export function recorderStart(filePath: string) {6 return {7 type: RECORDER_START,8 payload: { filePath }9 };10}11export function recorderStop() {12 return { type: RECORDER_STOP };13}14export function recorderPause() {15 return { type: RECORDER_PAUSE };16}17export function recorderResume() {18 return { type: RECORDER_RESUME };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 until = webdriver.until;3var driver = new webdriver.Builder()4 .forBrowser('selenium')5 .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.executeScript('mobile: stopRecordingScreen');10driver.quit();11driver.executeScript('mobile: stopRecordingScreen', { 'videoType': 'mp4', 'videoQuality': 'medium', 'videoFps': 10, 'videoScale': 1.0, 'videoFilters': 'none', 'videoFilterOptions': {}, 'videoFile': '/Users/username/Desktop/test.mp4' });12driver.executeScript('mobile: stopRecordingScreen');13driver.executeScript('mobile: stopRecordingScreen');14driver.executeScript('mobile: stopRecordingScreen');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var fs = require('fs');4var path = require('path');5var test = require('selenium-webdriver/testing');6var chai = require('chai');7var chaiAsPromised = require('chai-as-promised');8chai.use(chaiAsPromised);9chai.should();10chaiAsPromised.transferPromiseness = wd.transferPromiseness;11var recorder = require('node-record-lpcm16');12var request = require('request');13var config = require('./config.js');14var process = require('process');15var exec = require('child_process').exec;16var spawn = require('child_process').spawn;17var username = config.username;18var accessKey = config.accessKey;19var serverConfig = {20};21var driver;22var allPassed = true;23test.describe('Sauce Labs iOS WebdriverIO Test', function() {24 this.timeout(300000);25 test.beforeEach(function() {26 driver = wd.promiseChainRemote(serverConfig);27 var desired = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exec } = require('child_process');2exec('xcrun simctl io booted recordVideo --type=mp4 --mask=black --codec=libx264 --force /Users/Shared/test.mp4', (err, stdout, stderr) => {3 if (err) {4 console.error(err)5 } else {6 console.log(`stdout: ${stdout}`);7 console.log(`stderr: ${stderr}`);8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exec } = require('child_process');2exec(cmd, (err, stdout, stderr) => {3 if (err) {4 console.error(err)5 } else {6 console.log(`stdout: ${stdout}`);7 console.log(`stderr: ${stderr}`);8 }9});10const { exec } = require('child_process');11exec(cmd, (err, stdout, stderr) => {12 if (err) {13 console.error(err)14 } else {15 console.log(`stdout: ${stdout}`);16 console.log(`stderr: ${stderr}`);17 }18});

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