How to use driver.back method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

apply.js

Source:apply.js Github

copy

Full Screen

1// pages/apply/apply.js2var util = require('../../utils/util.js')3var app = getApp()4Page({5 data: {6 driver_front: '../../images/one.jpg',7 driver_back: '../../images/two.jpg',8 driving_front: '../../images/three.jpg',9 driving_back: '../../images/four.jpg',10 studentcard: '../../images/five.jpg',11 car_front: '../../images/audi.png',12 imgadd_driver_front: [],13 imgadd_driver_back: [],14 imgadd_driving_front: [],15 imgadd_driving_back: [],16 imgadd_studentcard:[],17 imgadd_car_front:[],18 is_1_ok: 0,19 is_2_ok: 0,20 is_3_ok: 0,21 is_4_ok: 0,22 is_5_ok: 0,23 is_6_ok: 0,24 obct:'请上传照片',25 studentid:0,26 apply_id:[]27 },28 /**29 * 生命周期函数--监听页面加载30 */31 onLoad: function () {32 var that = this;33 wx.getStorage({34 key: 'obj',35 success: function (res) {36 console.log(res.data.openId)37 that.setData({38 nickName:res.data.nickName,39 openId: res.data.openId40 })41 }42 }),43 wx.getStorage({44 key: 'studentid',45 success: function (res) {46 console.log(res.data)47 that.setData({48 studentid: res.data49 })50 }51 });52 },53 /**54 * 生命周期函数--监听页面初次渲染完成55 */56 onReady: function () {57 58 },59 /**60 * 生命周期函数--监听页面显示61 */62 onShow: function () {63 64 },65 /**66 * 生命周期函数--监听页面隐藏67 */68 onHide: function () {69 70 },71 /**72 * 生命周期函数--监听页面卸载73 */74 onUnload: function () {75 76 },77 /**78 * 页面相关事件处理函数--监听用户下拉动作79 */80 onPullDownRefresh: function () {81 82 },83 /**84 * 页面上拉触底事件的处理函数85 */86 onReachBottom: function () {87 88 },89 /**90 * 用户点击右上角分享91 */92 onShareAppMessage: function () {93 94 },95 up_driver_front: function () {96 var that = this97 wx.chooseImage({98 count: 1,99 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图100 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有101 success: function (res) {102 var driver_front = res.tempFilePaths103 that.setData({104 driver_front: res.tempFilePaths[0]105 })106 console.log(driver_front)107 wx.setStorage({ key: "img_driver_front", data: driver_front })108// 存入私有文件夹109 wx.uploadFile({110 url: "https://sscar.ptczn.cn/index.php/index/index/upload",111 filePath: driver_front[0],112 name: 'add_image', //文件对应的参数名字(key) 113 formData: {114 'openId': that.data.openId,115 'studentid': that.data.studentid,116 'which_one':1117 }, //其它的表单信息 118 success: function (res) {119 console.log(res); 120 that.setData({121 imgadd_driver_front: res.data,122 is_1_ok: 3,123 }) 124 } 125 }) 126//公开识别127 wx.uploadFile({128 url: "https://sscar.ptczn.cn/index.php/index/index/recog_driv_front",129 filePath: driver_front[0],130 name: 'add_image', //文件对应的参数名字(key) 131 formData: {132 'openId': that.data.openId,133 'studentid': that.data.studentid,134 'type':1135 }, //其它的表单信息 136 success: function (res) {137 console.log(res);138 var driver_front_data_tmp = JSON.parse(res.data);139 var driver_front_data = JSON.parse(driver_front_data_tmp);140 if (driver_front_data.code == 0){141 console.log(driver_front_data)142 that.setData({143 obct: '识别成功',144 is_1_ok: 1,145 })146 console.log(driver_front_data.data)147 wx.setStorage({ key: "driver_front_data", data: driver_front_data.data.items })148 }else{149 that.setData({150 obct: '未识别到驾驶证',151 is_1_ok: 2,152 })153 }154 console.log(driver_front_data.data.items)155 } 156 })157 }158 })159 },160 up_driving_front: function () {161 var that = this162 wx.chooseImage({163 count: 1,164 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图165 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有166 success: function (res) {167 var driving_front = res.tempFilePaths168 that.setData({169 driving_front: res.tempFilePaths[0]170 })171 console.log(driving_front)172 wx.setStorage({ key: "img_driving_front", data:driving_front })173 // 存入私有文件夹174 wx.uploadFile({175 url: "https://sscar.ptczn.cn/index.php/index/index/upload",176 filePath: driving_front[0],177 name: 'add_image', //文件对应的参数名字(key) 178 formData: {179 'openId': that.data.openId,180 'studentid': that.data.studentid,181 'which_one': 3182 }, //其它的表单信息 183 success: function (res) {184 console.log(res);185 that.setData({186 imgadd_driving_front: res.data,187 is_3_ok: 3,188 })189 }190 })191 //公开识别192 wx.uploadFile({193 url: "https://sscar.ptczn.cn/index.php/index/index/recog_driv_front",194 filePath: driving_front[0],195 name: 'add_image', //文件对应的参数名字(key) 196 formData: {197 'openId': that.data.openId,198 'type': 0199 }, //其它的表单信息 200 success: function (res) {201 console.log(res);202 var driving_front_data_tmp = JSON.parse(res.data);203 var driving_front_data = JSON.parse(driving_front_data_tmp);204 if (driving_front_data.code == 0) {205 that.setData({206 obct: '识别成功',207 is_3_ok: 1,208 })209 wx.setStorage({ key: "driving_front_data", data: driving_front_data.data.items })210 } else {211 that.setData({212 obct: '未识别到行驶证',213 is_3_ok: 2,214 })215 }216 console.log(driving_front_data.data.items)217 }218 })219 }220 })221 },222 up_driver_back: function () {223 var that = this224 wx.chooseImage({225 count: 1,226 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图227 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有228 success: function (res) {229 var driver_back = res.tempFilePaths230 that.setData({231 driver_back: res.tempFilePaths[0]232 })233 console.log(driver_back)234 // 存入私有文件夹235 wx.uploadFile({236 url: "https://sscar.ptczn.cn/index.php/index/index/upload",237 filePath: driver_back[0],238 name: 'add_image', //文件对应的参数名字(key) 239 formData: {240 'openId': that.data.openId,241 'studentid': that.data.studentid,242 'which_one': 2243 }, //其它的表单信息 244 success: function (res) {245 console.log(res);246 that.setData({247 imgadd_driver_back: res.data,248 is_2_ok: 1,249 })250 }251 })252 253 }254 })255 },256 up_driving_back: function () {257 var that = this258 wx.chooseImage({259 count: 1,260 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图261 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有262 success: function (res) {263 var driving_back = res.tempFilePaths264 that.setData({265 driving_back: res.tempFilePaths[0]266 })267 console.log(driving_back)268 // 存入私有文件夹269 wx.uploadFile({270 url: "https://sscar.ptczn.cn/index.php/index/index/upload",271 filePath: driving_back[0],272 name: 'add_image', //文件对应的参数名字(key) 273 formData: {274 'openId': that.data.openId,275 'studentid': that.data.studentid,276 'which_one': 4277 }, //其它的表单信息 278 success: function (res) {279 console.log(res);280 that.setData({281 imgadd_driving_back: res.data,282 is_4_ok: 1,283 })284 }285 })286 }287 })288 },289 up_studentcard: function () {290 var that = this291 wx.chooseImage({292 count: 1,293 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图294 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有295 success: function (res) {296 var studentcard = res.tempFilePaths297 that.setData({298 studentcard: res.tempFilePaths[0]299 })300 console.log(studentcard)301 wx.setStorage({ key: "img_studentcard", data: studentcard })302 // 存入私有文件夹303 wx.uploadFile({304 url: "https://sscar.ptczn.cn/index.php/index/index/upload",305 filePath: studentcard[0],306 name: 'add_image', //文件对应的参数名字(key) 307 formData: {308 'openId': that.data.openId,309 'studentid': that.data.studentid,310 'which_one': 5311 }, //其它的表单信息 312 success: function (res) {313 console.log(res)314 that.setData({315 imgadd_studentcard: res.data,316 is_5_ok: 1,317 })318 }319 })320 }321 })322 },323 up_car_front: function () {324 var that = this325 wx.chooseImage({326 count: 1,327 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图328 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有329 success: function (res) {330 var car_front = res.tempFilePaths331 that.setData({332 car_front: res.tempFilePaths[0]333 })334 console.log(car_front)335 // 存入私有文件夹336 wx.uploadFile({337 url: "https://sscar.ptczn.cn/index.php/index/index/recog_car_front",338 filePath: car_front[0],339 name: 'add_image', //文件对应的参数名字(key) 340 formData: {341 'openId': that.data.openId,342 'studentid': that.data.studentid,343 'which_one': 6344 }, //其它的表单信息 345 success: function (res) {346 console.log(res);347 var car_front_data_tmp = JSON.parse(res.data);348 that.setData({349 imgadd_car_front: car_front_data_tmp.imgadd,350 })351 console.log(car_front_data_tmp.imgadd)352 var car_front_data = JSON.parse(car_front_data_tmp.res);353 if (car_front_data.code == 0) {354 that.setData({355 obct: '识别成功',356 is_6_ok: 1,357 })358 wx.setStorage({ key: "car_front_data", data: car_front_data.data.items })359 } else {360 that.setData({361 obct: '未识别到车牌号'362 })363 }364 console.log(car_front_data.data.items)365 }366 }) 367 }368 })369 },370 totxt: function () {371 var that = this;372 wx.request({373 url: 'https://sscar.ptczn.cn/index.php/index/index/sql_photo',374 data: {375 // code: "oneyuan",376 'driver_front': that.data.imgadd_driver_front,377 'driver_back': that.data.imgadd_driver_back,378 'driving_front': that.data.imgadd_driving_front,379 'driving_back': that.data.imgadd_driving_back,380 'studentcard': that.data.imgadd_studentcard,381 'car_front': that.data.imgadd_car_front,382 'openId': that.data.openId,383 'studentid': that.data.studentid384 },385 method: "POST",386 header: {387 "Content-Type": "application/x-www-form-urlencoded" //post388 },389 success: function (res) {390 console.log(res.data.apply_id)391 var apply_id = res.data.apply_id;392 that.setData({393 apply_id: res.data.apply_id394 })395 wx.setStorageSync('apply_id', res.data.apply_id)396 }397 })398 if (this.data.is_1_ok == 1 && this.data.is_2_ok == 1 && this.data.is_3_ok == 1 && this.data.is_4_ok == 1 && this.data.is_5_ok == 1 && this.data.is_6_ok==1){399 wx.navigateTo({400 url: "/pages/txt/txt?apply_id=" + that.data.apply_id401 })402 }else{403 wx.showModal({404 title: '出错啦',405 content: '上传的照片可能未识别成功,请返回尝试。若多次尝试仍出现此提示,可点击坚持提交后手动修改',406 confirmText:'返回尝试',407 cancelText:'坚持提交',408 success: function (res) {409 if (res.confirm) {410 console.log('用户点击返回尝试')411 } else if (res.cancel) {412 console.log('用户点击坚持提交')413 414 console.log(that.data.apply_id)415 wx.navigateTo({416 url: "/pages/txt/txt?apply_id=" + that.data.apply_id417 })418 }419 }420 })421 }422 }...

Full Screen

Full Screen

travel-manager.factory.test.js

Source:travel-manager.factory.test.js Github

copy

Full Screen

1'use strict';2describe('Given a TravelManager instance', function() {3 var mockDialog = {};4 beforeEach(module("TravelServices", function ($provide) {5 $provide.value("$mdDialog", mockDialog);6 }));7 beforeEach(module('TestUtils'));8 var $httpBackend,9 $rootScope,10 TravelManager,11 TestUtils;12 beforeEach(function() {13 angular.mock.inject(function ($injector) {14 $httpBackend = $injector.get('$httpBackend');15 $rootScope = $injector.get('$rootScope');16 TravelManager = $injector.get('TravelManager');17 TestUtils = $injector.get('TestUtils');18 });19 });20 it('on passenger add the new passenger will be emitted on the rootscope',21 function() {22 spyOn($rootScope, "$emit")23 TestUtils.addPassengerThere('1');24 expect($rootScope.$emit).toHaveBeenCalledWith("PASSENGER_ADDED", TestUtils.createPassengerThere('1'));25 }26 );27 it('a passenger there can be added and only TravelManager.there will be set',28 function() {29 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));30 expect(TravelManager.getPassengerThere().model.pk).toBe('1');31 expect(TravelManager.getDriverThere().model).toBe(null);32 expect(TravelManager.getPassengerBack().model).toBe(null);33 expect(TravelManager.getDriverBack().model).toBe(null);34 }35 );36 it('a driver there can be added and only TravelManager.there will be set',37 function() {38 TravelManager.addDriver(TestUtils.createRideThere('1'));39 expect(TravelManager.getDriverThere().model.pk).toBe('1');40 expect(TravelManager.getPassengerThere().model).toBe(null);41 expect(TravelManager.getPassengerBack().model).toBe(null);42 expect(TravelManager.getDriverBack().model).toBe(null);43 }44 );45 it('a passenger there and back can be added',46 function() {47 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));48 TravelManager.addPassenger(TestUtils.createPassengerBack('2'));49 expect(TravelManager.getPassengerThere().model.pk).toBe('1');50 expect(TravelManager.getDriverThere().model).toBe(null);51 expect(TravelManager.getPassengerBack().model.pk).toBe('2');52 expect(TravelManager.getDriverBack().model).toBe(null);53 }54 );55 it('a driver there and back can be added',56 function() {57 TravelManager.addDriver(TestUtils.createRideThere('1'));58 TravelManager.addDriver(TestUtils.createRideBack('2'));59 expect(TravelManager.getDriverThere().model.pk).toBe('1');60 expect(TravelManager.getPassengerThere().model).toBe(null);61 expect(TravelManager.getPassengerBack().model).toBe(null);62 expect(TravelManager.getDriverBack().model.pk).toBe('2');63 }64 );65 it('a driver there and a passenger back can be added',66 function() {67 TravelManager.addDriver(TestUtils.createRideThere('1'));68 TravelManager.addPassenger(TestUtils.createPassengerBack('2'));69 expect(TravelManager.getDriverThere().model.pk).toBe('1');70 expect(TravelManager.getPassengerThere().model).toBe(null);71 expect(TravelManager.getPassengerBack().model.pk).toBe('2');72 expect(TravelManager.getDriverBack().model).toBe(null);73 }74 );75 it('DRIVER_UPDATED event will be fired when the driver is updated',76 inject(function($rootScope) {77 var driver = TestUtils.createRideThere('1');78 driver.num_of_seats = 1;79 var emittedDriver = angular.copy(driver);80 emittedDriver.num_of_seats = 2;81 TravelManager.addDriver(driver);82 spyOn($rootScope, "$emit");83 TravelManager.getDriverThere().model.num_of_seats = 2;84 $httpBackend.expectPUT('/rest/1/rides/1/').respond(emittedDriver);85 TravelManager.getDriverThere().modify();86 $httpBackend.flush();87 expect($rootScope.$emit).toHaveBeenCalledWith("DRIVER_UPDATED", emittedDriver);88 })89 );90 it('when a passenger is deleted it will be emit on the rootscope and the model will be set to null',91 inject(function($rootScope) {92 var passenger = TestUtils.createPassengerThere('1');93 var emittedPassenger = TestUtils.createPassengerThere('1');94 TravelManager.addPassenger(passenger);95 spyOn($rootScope, "$emit")96 TestUtils.removePassengerThere();97 expect($rootScope.$emit).toHaveBeenCalledWith("PASSENGER_DELETED", emittedPassenger);98 expect(TravelManager.getPassengerThere().model).toBe(null);99 })100 );101 it('when a driver is deleted it will be emit on the rootscope and the model will be set to null',102 inject(function($rootScope) {103 var driver = TestUtils.createRideThere('1');104 var emittedDriver = TestUtils.createRideThere('1');105 TravelManager.addDriver(driver);106 spyOn($rootScope, "$emit")107 $httpBackend.expectDELETE('/rest/1/rides/1/').respond({});108 TravelManager.getDriverThere().remove()109 $httpBackend.flush();110 expect($rootScope.$emit).toHaveBeenCalledWith("DRIVER_DELETED", emittedDriver);111 expect(TravelManager.getDriverThere().model).toBe(null);112 })113 );114 it('a passenger can be deleted and then added',115 function() {116 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));117 TravelManager.getPassengerThere().remove();118 TravelManager.addPassenger(TestUtils.createPassengerThere('2'));119 expect(TravelManager.getPassengerThere().model.pk).toBe('2');120 expect(TravelManager.getDriverThere().model).toBe(null);121 expect(TravelManager.getPassengerBack().model).toBe(null);122 expect(TravelManager.getDriverBack().model).toBe(null);123 }124 );125 it('a driver can be deleted and then added',126 function() {127 TravelManager.addDriver(TestUtils.createRideThere('1'));128 $httpBackend.expectDELETE('/rest/1/rides/1/').respond({});129 TravelManager.getDriverThere().remove();130 $httpBackend.flush();131 TravelManager.addDriver(TestUtils.createRideThere('2'));132 expect(TravelManager.getDriverThere().model.pk).toBe('2');133 expect(TravelManager.getPassengerThere().model).toBe(null);134 expect(TravelManager.getPassengerBack().model).toBe(null);135 expect(TravelManager.getDriverBack().model).toBe(null);136 }137 );138 it('a isDriving returns false for passenger',139 function() {140 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));141 expect(TravelManager.getTravelThere().isDriving()).toBe(false);142 }143 );144 it('a isDriving returns true for driver',145 function() {146 TravelManager.addDriver(TestUtils.createRideThere('1'));147 expect(TravelManager.getTravelThere().isDriving()).toBe(true);148 }149 );150 it('a isEmpty returns true when neither a driver nor a passenger exist in that direction',151 function() {152 expect(TravelManager.getTravelThere().isEmpty()).toBe(true);153 }154 );155 it('a isEmpty returns false when a driver exist in that direction',156 function() {157 TravelManager.addDriver(TestUtils.createRideThere('1'));158 expect(TravelManager.getTravelThere().isEmpty()).toBe(false);159 }160 );161 it('a isEmpty returns false when a passenger exist in that direction',162 function() {163 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));164 expect(TravelManager.getTravelThere().isEmpty()).toBe(false);165 }166 );167 it('a isEmpty returns true when a passenger exist in the other direction',168 function() {169 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));170 expect(TravelManager.getTravelBack().isEmpty()).toBe(true);171 }172 );173 it('getModelThere returns null if there is no passenger neither driver there',174 function() {175 expect(TravelManager.getModelThere()).toBe(null);176 }177 );178 it('getModelThere returns passenger model if there is a passenger there',179 function() {180 TravelManager.addPassenger(TestUtils.createPassengerThere('1'));181 expect(TravelManager.getModelThere().pk).toBe('1');182 }183 );184 it('getModelThere returns driver model if there is a driver there',185 function() {186 TravelManager.addDriver(TestUtils.createRideThere('1'));187 expect(TravelManager.getModelThere().pk).toBe('1');188 }189 );190 it('getModelThere returns null if there is a passenger back',191 function() {192 TravelManager.addPassenger(TestUtils.createPassengerBack('1'));193 expect(TravelManager.getModelThere()).toBe(null);194 }195 );196 it('getModelThere returns null if there is a driver back',197 function() {198 TravelManager.addDriver(TestUtils.createRideBack('1'));199 expect(TravelManager.getModelThere()).toBe(null);200 }201 );202 it('getModelThere returns passenger if there is a driver back',203 function() {204 TravelManager.addDriver(TestUtils.createRideBack('1'));205 TravelManager.addPassenger(TestUtils.createPassengerThere('2'));206 expect(TravelManager.getModelThere().pk).toBe('2');207 }208 );209 it('getModelThere returns passenger if there is a passenger back',210 function() {211 TravelManager.addPassenger(TestUtils.createPassengerBack('1'));212 TravelManager.addPassenger(TestUtils.createPassengerThere('2'));213 expect(TravelManager.getModelThere().pk).toBe('2');214 }215 );...

Full Screen

Full Screen

DriverBackPhoto.js

Source:DriverBackPhoto.js Github

copy

Full Screen

1/* eslint-disable prettier/prettier */2import React, {useState, useEffect} from 'react';3import {4 SafeAreaView,5 StyleSheet,6 Text,7 View,8 TouchableOpacity,9 ScrollView,10 Image,11} from 'react-native';12import IconFeather from 'react-native-vector-icons/Feather';13import { COLORS } from '../../constants';14import {useDispatch, useSelector} from 'react-redux';15import {uploadDriveBack, resetPhotos} from '../../redux/User/user.actions';16import { RNCamera } from 'react-native-camera';17const PendingView = () => (18 <View19 style={{20 flex: 1,21 backgroundColor: 'lightgreen',22 justifyContent: 'center',23 alignItems: 'center',24 }}>25 <Text>Waiting</Text>26 </View>27);28const mapState = ({user}) => ({29 uploadDriverBackSuccess: user.uploadDriverBackSuccess,30 errors: user.errors,31});32const DriverBackPhoto = ({navigation}) => {33 const { uploadDriverBackSuccess, errors} = useSelector(mapState);34 const dispatch = useDispatch();35 console.log('uploadDriverBackSuccess =>', uploadDriverBackSuccess);36 console.log('errors =>', errors);37 const [imageSource, setImageSource] = useState(null)38 39 const takePicture = async function(camera) {40 const options = { quality: 0.8, base64: true };41 const data = await camera.takePictureAsync(options);42 setImageSource(data.uri)43 dispatch(uploadDriveBack(imageSource))44 // navigation.navigate('DriverIdentification')45 };46 const NextPage = () => {47 navigation.navigate('DriverIdentification')48 }49 // const uploadImage = () => {50 // if(imageSource){51 // dispatch(uploadDriveBack(imageSource))52 // }53 // }54 useEffect(() => {55 if(uploadDriverBackSuccess){56 setImageSource(null)57 dispatch(resetPhotos())58 navigation.navigate('DriverIdentification')59 }60 }, [uploadDriverBackSuccess])61 return (62 <ScrollView>63 <SafeAreaView style={styles.container}>64 <View 65 style={styles.scrollHeight}66 >67 <ScrollView 68 horizontal 69 showsHorizontalScrollIndicator={false}70 style={styles.scrollView} >71 <View72 style={styles.header}73 >74 <IconFeather75 name="arrow-left"76 size={25}77 color={COLORS.main}78 style={styles.icon_style}79 onPress={() => navigation.goBack()}80 />81 <View82 style={styles.center_header}83 >84 <View 85 style={styles.cardContainer}86 >87 <Text style={styles.text_above} >88 Driver's License89 </Text>90 <View91 style={styles.card}92 >93 {94 imageSource 95 ? <Image96 style={styles.currentImage}97 source={{98 uri: imageSource,99 }}100 />101 : null 102 }103 </View>104 <Text style={styles.text_under}>105 Take a photo of back side106 </Text>107 {imageSource ? (108 <TouchableOpacity 109 style={styles.nextBtn}110 onPress={NextPage()}111 >112 <Text style={styles.nextText}>Next</Text>113 </TouchableOpacity>114 ) : null}115 <View116 style={styles.leftEdge}117 >118 </View>119 <View120 style={styles.rightEdge}121 >122 </View>123 </View>124 </View>125 <TouchableOpacity126 style={styles.getPhoto}127 // onPress={uploadImage()}128 >129 </TouchableOpacity>130 </View>131 </ScrollView>132 </View>133 134 </SafeAreaView>135 <RNCamera136 style={styles.preview}137 type={RNCamera.Constants.Type.back}138 flashMode={RNCamera.Constants.FlashMode.off}139 androidCameraPermissionOptions={{140 title: 'Permission to use camera',141 message: 'We need your permission to use your camera',142 buttonPositive: 'Ok',143 buttonNegative: 'Cancel',144 }}145 captureAudio={false}146 >147 {({ camera, status }) => {148 if (status !== 'READY') return <PendingView />;149 return (150 <View style={{ flex: 0, flexDirection: 'row', justifyContent: 'center' }}>151 <TouchableOpacity onPress={() => takePicture(camera)} style={styles.capture}>152 <Text style={{ fontSize: 14 }}>153 <IconFeather154 style={styles.cameraIcon}155 name="camera"156 /> 157 </Text>158 </TouchableOpacity>159 </View>160 );161 }}162 </RNCamera>163 </ScrollView>164 );165};166export default DriverBackPhoto;167const styles = StyleSheet.create({168 nextBtn: {169 borderWidth: 1,170 borderColor: 'grey',171 fontSize: 16,172 position: 'absolute',173 bottom: -50,174 left: 110,175 width: 100,176 paddingVertical: 3,177 borderRadius: 4,178 },179 nextText: {180 textAlign: 'center',181 }, 182 currentImage: {183 height: 162,184 resizeMode:'contain',185 marginTop: 0,186 transform: [{rotate: '-90deg'}],187 },188 // 189 preview: {190 // flex: 1,191 // justifyContent: 'flex-end',192 // alignItems: 'center',193 position: 'absolute',194 height: 80,195 width: '100%',196 bottom: 0,197 left: 0,198 },199 capture: {200 flex: 0,201 backgroundColor: 'white',202 borderRadius: 5,203 padding: 5,204 paddingHorizontal: 10,205 alignSelf: 'center',206 margin: 20,207 transform: [{scale: 1.5}]208 },209 // 210 scrollHeight: {211 height: 660,212 }, 213 scrollView: {214 flex: 1,215 height: 50,216 backgroundColor: 'white',217 },218 container: {219 flex: 1,220 color: COLORS.main,221 backgroundColor: 'black',222 },223 header: {224 display: 'flex',225 flexDirection: 'row',226 borderBottomWidth: 0.5,227 borderBottomColor: COLORS.main,228 paddingVertical: 5,229 },230 center_header: {231 marginHorizontal: 100,232 marginVertical: 20,233 },234 text_above: {235 textAlign: 'center',236 fontSize: 13,237 backgroundColor: 'white',238 position: 'absolute',239 top: -20 ,240 left: 40,241 height: 60,242 width: 270,243 },244 text_under: {245 textAlign: 'center',246 fontSize: 16,247 backgroundColor: 'white',248 position: 'absolute',249 bottom: -15,250 left: 35,251 width: 270,252 },253 cardContainer: {254 marginTop: 40,255 position: 'relative',256 width: 340,257 height: 220,258 borderWidth: 1,259 borderColor: 'grey',260 },261 card: {262 marginTop: 25,263 marginLeft: 25,264 width: 285,265 height: 160,266 borderWidth: 1,267 borderColor: 'grey',268 },269 icon_style: {270 flex: 0.45,271 padding: 10,272 },273 getPhoto: {274 width: 60,275 height: 60,276 borderRadius: 45,277 backgroundColor: 'grey',278 display: 'flex',279 flexDirection: 'column',280 justifyContent: 'space-around',281 alignItems: 'center',282 marginTop: 140,283 marginHorizontal: 40,284 marginLeft: 0,285 },286 leftEdge: {287 position: 'absolute',288 backgroundColor: 'white',289 top: 35,290 left: -10,291 width: 20,292 height: 140,293 },294 rightEdge: {295 position: 'absolute',296 backgroundColor: 'white',297 top: 35,298 right: -10,299 width: 20,300 height: 140,301 },...

Full Screen

Full Screen

find-e2e-specs.js

Source:find-e2e-specs.js Github

copy

Full Screen

...18 it(`should find an element by it's xpath`, async function () {19 let el = await driver.elementByXPath("//*[@text='Animation']");20 el.should.exist;21 await el.click();22 await driver.back();23 });24 it('should find multiple elements that match one xpath', async function () {25 let els = await driver.elementsByXPath('//android.widget.TextView');26 els.length.should.be.above(1);27 await els[0].click();28 await driver.back();29 });30 it('should get the first element of an xpath that matches more than one element', async function () {31 let el = await driver.elementByXPath('//android.widget.TextView');32 el.should.exist;33 await el.click();34 await driver.back();35 });36 it('should throw a stale element exception if clicking on element that does not exist', async function () {37 let el = await driver.elementByXPath("//*[@content-desc='Animation']");38 await el.click();39 await retryInterval(5, 1000, async () => await el.click().should.eventually.be.rejectedWith(/no longer exists /));40 await driver.back();41 });42 it('should get the isDisplayed attribute on the same element twice', async function () {43 let el = await driver.elementByXPath("//*[@content-desc='Animation']");44 await el.isDisplayed().should.eventually.be.true;45 await el.isDisplayed().should.eventually.be.true;46 await el.click();47 await driver.back();48 });49 it('should match an element if the element is off-screen but has an accessibility id', async function () {50 let el = await driver.elementByAccessibilityId('Views');51 await el.click();52 // Click on an element that is at the bottom of the list53 let moveToEl = await driver.elementByAccessibilityId('WebView');54 await moveToEl.click();55 await driver.back();56 await driver.back();57 });58 it('should test element equality', async function () {59 let el = await driver.elementByAccessibilityId('Views');60 let elAgain = await driver.elementByXPath("//*[@content-desc='Views']");61 let elNonMatch = await driver.elementByAccessibilityId('Preference');62 await el.equals(elAgain).should.eventually.be.true;63 await el.equals(elNonMatch).should.eventually.be.false;64 });65 // TODO: This test is very flakey. Need to inspect this.66 it.skip('should scroll element back into view if was scrolled out of view (regression test for https://github.com/appium/appium-espresso-driver/issues/276)', async function () {67 // If we find an element by 'contentDescription', scroll out of view of that element, we should be able to scroll it back into view, as long68 // as that element has a content description associated with an adapter item69 let el = await driver.elementByAccessibilityId('Views');70 await el.click();71 el = await driver.elementByAccessibilityId('Custom');72 await el.text().should.eventually.equal('Custom');73 let {value: element} = await driver.elementById('android:id/list');74 await driver.execute('mobile: swipe', {direction: 'up', element});75 await el.text().should.eventually.equal('Custom');76 await driver.back();77 });78 });79 describe('by data matcher', function () {80 it('should find an element using a data matcher', async function () {81 let el = await driver.element('-android datamatcher', JSON.stringify({82 name: 'hasEntry', args: ['title', 'Animation']83 }));84 await el.click();85 await driver.elementByAccessibilityId('Bouncing Balls').should.eventually.exist;86 await driver.back();87 });88 it('should find an offscreen element using a data matcher', async function () {89 let viewsEl = await driver.elementByAccessibilityId('Views');90 await viewsEl.click();91 let el = await driver.element('-android datamatcher', JSON.stringify({92 name: 'hasEntry', args: ['title', 'WebView3']93 }));94 await el.click();95 await driver.back();96 await driver.elementByAccessibilityId('Controls').should.eventually.exist;97 await driver.back();98 });99 it('should fail to find elements with helpful error messages', async function () {100 await driver.element('-android datamatcher', JSON.stringify({101 name: 'hasEntry', args: ['title', 'A Fake Item']102 })).should.eventually.be.rejectedWith(/NoSuchElement/);103 });104 it('should fail with invalid selector with helpful error messages', async function () {105 await driver.element('-android datamatcher', JSON.stringify({106 name: 'notARealHamcrestMatcherStrategy', args: ['title', 'A Fake Item']107 })).should.eventually.be.rejectedWith(/InvalidSelector/);108 });109 it('should allow "class" property with fully qualified className', async function () {110 await driver.element('-android datamatcher', JSON.stringify({111 name: 'notARealHamcrestMatcherStrategy', args: ['title', 'A Fake Item'], class: 'org.hamcrest.Matchers',...

Full Screen

Full Screen

ViewRidesScreen.js

Source:ViewRidesScreen.js Github

copy

Full Screen

1import React, { useEffect, useState } from "react";2import { Text, View, TouchableOpacity } from "react-native";3import { useNavigation, useRoute } from "@react-navigation/native";4import { auth, db } from "../../../firebaseConfig/firebaseConfig";5import ViewRideRow from "../../components/ViewRIdeRow/ViewRideRow";6import styles from "./styles";7import { SafeAreaView, ScrollView } from "react-native";8import LoadingSpinner from "../../components/LoadingSpinner";9const ViewRidesScreen = () => {10 const navigation = useNavigation();11 const route = useRoute();12 const [rides, setRides] = useState(null);13 const [passengerTextColor, setPassengerTextColor] = useState("white");14 const [passengerBackGroundColor, setPassengerBackGroundColor] = useState(15 "#ad462f"16 );17 const [driverTextColor, setDriverTextColor] = useState("black");18 const [driverBackGroundColor, setDriverBackGroundColor] = useState("white");19 const [loading, setLoading] = useState(true);20 const [userType, setUserType] = useState("Passenger");21 const [passengerButton, setPassengerButton] = useState(true);22 const [DriverButton, setDriverButton] = useState(false);23 useEffect(() => {24 const unsubscribe = db25 .collection("rides")26 .where("userType", "==", `${userType}`)27 .onSnapshot((snapshot) => {28 setRides(29 snapshot.docs.map((doc) => ({30 id: doc.id,31 data: doc.data(),32 }))33 );34 setLoading(false);35 });36 return unsubscribe;37 }, [userType]);38 const changePassengerColor = () => {39 setPassengerTextColor("white");40 setPassengerBackGroundColor("#ad462f");41 setDriverTextColor("black");42 setDriverBackGroundColor("white");43 setDriverButton(false);44 setPassengerButton(true);45 setLoading(true);46 };47 const changeDriverColor = () => {48 setDriverTextColor("white");49 setDriverBackGroundColor("#ad462f");50 setPassengerTextColor("black");51 setPassengerBackGroundColor("white");52 setPassengerButton(false);53 setDriverButton(true);54 setLoading(true);55 };56 const onPassengerButton = () => {57 changePassengerColor();58 setUserType("Passenger");59 };60 const onDriverButton = () => {61 changeDriverColor();62 setUserType("Driver");63 };64 return (65 <SafeAreaView style={styles.container}>66 <View style={styles.TypeContainer}>67 <TouchableOpacity68 disabled={passengerButton}69 style={[70 styles.buttonContainer,71 { backgroundColor: passengerBackGroundColor },72 ]}73 onPress={onPassengerButton}74 >75 <Text style={[styles.buttonText, { color: passengerTextColor }]}>76 PASSENGER77 </Text>78 </TouchableOpacity>79 <TouchableOpacity80 disabled={DriverButton}81 style={[82 styles.buttonContainer,83 { backgroundColor: driverBackGroundColor },84 ]}85 onPress={onDriverButton}86 >87 <Text style={[styles.buttonText, { color: driverTextColor }]}>88 DRIVER89 </Text>90 </TouchableOpacity>91 </View>92 {loading ? (93 <LoadingSpinner color="white" />94 ) : (95 <ScrollView>96 <View style={styles.row}>97 {rides.map((data) => (98 <ViewRideRow data={data.data} key={data.id} id={data.id} />99 ))}100 </View>101 </ScrollView>102 )}103 </SafeAreaView>104 );105};...

Full Screen

Full Screen

travel-manager.factory.js

Source:travel-manager.factory.js Github

copy

Full Screen

1(function () {2 'use strict';3 angular.module('TravelServices').factory('TravelManager', TravelManager);4 TravelManager.$inject = ['Travel'];5 function TravelManager(Travel) {6 var there = angular.copy(Travel.travel);7 var back = angular.copy(Travel.travel);8 return {9 getPassengerThere: getPassengerThere,10 getPassengerBack: getPassengerBack,11 getDriverThere: getDriverThere,12 getDriverBack: getDriverBack,13 getTravelThere: getTravelThere,14 getTravelBack: getTravelBack,15 getModelThere: getModelThere,16 getModelBack: getModelBack,17 addPassenger: addPassenger,18 addDriver: addDriver,19 showManagePassengerDialog: showManagePassengerDialog,20 };21 function showManagePassengerDialog(event, ride)22 {23 if (ride.is_return)24 {25 back.passenger.showAdd(event, ride);26 }27 else28 {29 there.passenger.showAdd(event, ride);30 }31 }32 function addPassenger(passenger) {33 if (passenger.ride.is_return)34 {35 back.passenger.model = passenger;36 back.driver.model = null;37 }38 else39 {40 there.passenger.model = passenger;41 there.driver.model = null;42 }43 }44 function addDriver(ride) {45 if (ride.is_return)46 {47 back.driver.model = ride;48 back.passenger.model = null;49 }50 else51 {52 there.driver.model = ride;53 there.passenger.model = null;54 }55 }56 function getTravelThere() {57 return there;58 }59 function getTravelBack() {60 return back;61 }62 function getModel(travel) {63 var object = travel.getObject();64 if (object === null)65 {66 return null;67 }68 return object.model;69 }70 function getModelThere() {71 return getModel(there);72 }73 function getModelBack() {74 return getModel(back);75 }76 function getDriverThere() {77 return there.driver;78 }79 function getDriverBack() {80 return back.driver;81 }82 function getPassengerThere() {83 return there.passenger;84 }85 function getPassengerBack() {86 return back.passenger;87 }88 }...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...26 .then((target) => target.click())27 await driver28 .elementByAndroidUIAutomator('new UiSelector().resourceId("android:id/text1").text("Action Bar")')29 .then((target) => target.click())30 await driver.back()31 await driver.back()32 await driver33 .elementByAndroidUIAutomator('new UiSelector().resourceId("android:id/text1").text("Content")')34 .then((target) => target.click())35 await driver36 .elementByAndroidUIAutomator('new UiSelector().resourceId("android:id/text1").text("Assets")')37 .then((target) => target.click())38 await driver.back()39 await driver.back()40 await driver41 .elementByAndroidUIAutomator('new UiSelector().resourceId("android:id/text1").text("Views")')42 .then((target) => target.click())43 await driver44 .elementByAndroidUIAutomator('new UiSelector().resourceId("android:id/text1").text("Buttons")')45 .then((target) => target.click())46 await driver.back()47 await driver.back()48 })...

Full Screen

Full Screen

CasperAction.js

Source:CasperAction.js Github

copy

Full Screen

1/**2 * Created by sunny.yu2 on 9/16/2015.3 */4var wait = require('../CommonUtility/Wait');5var casperInit=require('./CasperInit');6var casperDriver=casperInit.getCasperDriver();7exports.Open=function Open(url,callback){8 casperDriver.start(url,callback);9}10exports.Back=function Back(){11 casperDriver.back();12}13exports.Clear=function Clear(){14 casperDriver.clear();15}16exports.SendKeys=function SendKeys(css,key){17 wait.waitByCssWithMethod(css,casperDriver.sendKeys(css,key));18}19exports.Click=function Click(css){20 wait.waitByCssWithMethod(css,casperDriver.click(css))21}22exports.back=function Back(){23 casperDriver.back();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.back()2driver.back()3driver.back()4driver.back()5driver.back()6driver.back()7driver.back()

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desiredCaps = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6driver.init(desiredCaps)7 .then(function () {8 return driver.elementByAccessibilityId('Views').click();9 })10 .then(function () {11 return driver.elementByAccessibilityId('WebView').click();12 })13 .then(function () {14 return driver.elementByAccessibilityId('Make a page disappear!').click();15 })16 .then(function () {17 return driver.back();18 })19 .then(function () {20 return driver.quit();21 })22 .done();23driver.back() Method in Appium Java Driver24package appium;25import org.openqa.selenium.remote.DesiredCapabilities;26import java.net.URL;27import io.appium.java_client.android.AndroidDriver;28import io.appium.java_client.remote.MobileCapabilityType;29public class BackMethod {30 public static void main(String[] args) throws Exception {31 DesiredCapabilities capabilities = new DesiredCapabilities();32 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");33 capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.0.1");34 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");35 capabilities.setCapability(MobileCapabilityType.APP, "C:\\Users\\user\\Desktop\\appium\\ApiDemos-debug.apk");36 capabilities.setCapability("appPackage", "io.appium.android.apis");37 capabilities.setCapability("appActivity", ".view.WebView1");

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 },5};6var client = webdriverio.remote(options);7 .init()8 .click('android=new UiSelector().text("xxxxx")')9 .pause(1000)10 .back()11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 },16};17var client = webdriverio.remote(options);18 .init()19 .pause(1000)20 .back()21 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.back();2driver.forward();3driver.refresh();4driver.execute("mobile: shell", {5});6driver.executeAsync("mobile: shell", {7});8driver.getOrientation();9driver.setOrientation("LANDSCAPE");10driver.getGeoLocation();11driver.setGeoLocation({12});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6async function main() {7 const client = await wdio.remote(opts);8 await client.pause(5000);9 await client.back();10 await client.pause(5000);11 await client.deleteSession();12}13main();

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 Android Driver automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful