Best Python code snippet using fMBT_python
tickets.py
Source:tickets.py
...87 88def pressUp():89 pressButton(JSEvent(buttonUp = True))90 91def pressBack():92 pressButton(JSEvent(buttonO = True)) 93def pressSelect():94 pressButton(JSEvent(buttonSelect = True)) 95def pressStart():96 pressButton(JSEvent(buttonStart = True)) 97def pressGuide():98 pressButton(JSEvent(buttonGuide = True)) 99amount = 0100def getimage():101 fsocket.send_string('0')102 msg = fsocket.recv()103 if len(msg) != 0:104 height = int.from_bytes(msg[0:2], byteorder='little')105 width = int.from_bytes(msg[2:4], byteorder='little')106 channel = int.from_bytes(msg[4:6], byteorder='little')107 img = numpy.frombuffer(msg, numpy.uint8, -1, 6)108 img.shape = (height, width, channel)109 img = img[:, :, ::-1].copy() 110 return img111 else:112 print("error!")113def pressXrepeatedly(duration):114 start = time()115 while (time() < start+duration):116 pressX()117 i = getimage()118 i = i[20:80, 80:140]119 s = diffimg(i)120 if s >= 0.8:121 return True122 return False123def maintoextra():124 global tickets125 tickets += 1126 print("start: %d tickets" % tickets)127 sleep(1)128 pressLeft()129 pressX()130 print("cafe")131 sleep(4)132 pressLeft()133 pressX()134 print("my collections")135 pressDown()136 pressRight()137 pressX()138 print("extra menus")139def menutoclaim():140 sleep(1)141 pressX()142 sleep(3)143 pressBack()144 pressBack()145 pressBack()146 sleep(5)147 print("back to main")148 pressRight()149 pressX()150 sleep(6)151 print("garage")152 pressRight()153 pressRight()154 pressRight()155 pressX()156 print("gift")157 pressX()158 print("selected ticket")159 pressX()160 print("yes")161 pressX()162 print("repeating X")163 success = pressXrepeatedly(60)164 print("exiting")165 sleep(1)166 pressBack()167 pressBack()168 print("back to main")169 sleep(3)170 return success171def runloop1():172 print(datetime.datetime.now().strftime("%d/%m/%y %H:%M:%S"))173 maintoextra()174 pressUp()175 pressX()176 print("Toyota 86")177 return menutoclaim()178def runloop3():179 print(datetime.datetime.now().strftime("%d/%m/%y %H:%M:%S"))180 maintoextra()181 pressUp()182 pressRight()183 pressRight()184 pressX()185 print("Rotary")186 return menutoclaim()187def pressBackRepeatedly(duration):188 start = time()189 while (time() < start+duration):190 pressBack()191def restartGame():192 print("*** Restarting Game***")193 pressGuide()194 sleep(2)195 pressDown()196 pressX()197 sleep(2)198 print("opening options")199 pressStart()200 sleep(2)201 pressX()202 print("closed game")203 sleep(7)204 pressX()...
TroubleMaker.py
Source:TroubleMaker.py
...122 #rotate twice to get back to original screen orientation123 self.device.sleep(2000)124 self.screenAgent.changeOrientation()125 elif name == 'pressBack':126 self.keypressAgent.pressBack()127 elif name == 'pressHome':...
Hillfair_culebra_test.py
Source:Hillfair_culebra_test.py
...49 self.vc.click(x=303, y=1288)50 self.vc.sleep(_s)51 self.vc.click(x=807, y=440)52 self.vc.sleep(_s)53 self.vc.uiAutomatorHelper.pressBack()54 self.vc.sleep(_s)55 self.vc.click(x=728, y=1353)56 self.vc.sleep(_s)57 self.vc.uiAutomatorHelper.pressBack()58 self.vc.sleep(_s)59 self.vc.uiAutomatorHelper.findObject(bySelector='desc@Navigate up,clazz@android.widget.ImageButton,text@$,package@appteam.nith.hillffair').clickAndWait(eventCondition='until:newWindow', timeout=_s*1000)60 self.vc.click(x=944, y=1141)61 self.vc.sleep(_s)62 self.vc.uiAutomatorHelper.findObject(bySelector='res@appteam.nith.hillffair:id/leaderboard_link,clazz@android.widget.Button,text@LEADERBOARD,package@appteam.nith.hillffair').clickAndWait(eventCondition='until:newWindow', timeout=_s*1000)63 self.vc.uiAutomatorHelper.findObject(bySelector='desc@Navigate up,clazz@android.widget.ImageButton,text@$,package@appteam.nith.hillffair').clickAndWait(eventCondition='until:newWindow', timeout=_s*1000)64 self.vc.uiAutomatorHelper.pressBack()65 self.vc.sleep(_s)66 self.vc.click(x=459, y=2296)67 self.vc.sleep(_s)68 self.vc.uiAutomatorHelper.pressBack()69 self.vc.sleep(_s)70 self.vc.click(x=1061, y=2259)71 self.vc.sleep(_s)72 self.vc.click(x=387, y=701)73 self.vc.sleep(_s)74 self.vc.uiAutomatorHelper.pressBack()75 self.vc.sleep(_s)76 self.vc.click(x=424, y=1300)77 self.vc.sleep(_s)78 self.vc.uiAutomatorHelper.pressBack()79 self.vc.sleep(_s)80 self.vc.click(x=1053, y=1997)81 self.vc.sleep(_s)82 self.vc.uiAutomatorHelper.pressBack()83 self.vc.sleep(_s)84 self.vc.uiAutomatorHelper.pressBack()85 self.vc.sleep(_s)86 self.vc.swipe(start=(587, 2281), end=(580, 864), steps=25)87 self.vc.sleep(_s)88 self.vc.click(x=925, y=2190)89 self.vc.sleep(_s)90 self.vc.uiAutomatorHelper.pressBack()91 self.vc.sleep(_s)92 self.vc.click(x=341, y=1599)93 self.vc.sleep(_s)94 self.vc.uiAutomatorHelper.pressBack()95 self.vc.sleep(_s)96 self.vc.click(x=387, y=909)97 self.vc.sleep(_s)98 self.vc.uiAutomatorHelper.pressBack()99 self.vc.sleep(_s)100 self.vc.click(x=1061, y=1573)101 self.vc.sleep(_s)102 self.vc.click(x=1091, y=2243)103 self.vc.sleep(_s)104if __name__ == '__main__':...
basicTests.e2e.js
Source:basicTests.e2e.js
...10 });11 it('should login successfully', async () => {12 await element(by.id('inputUsername')).typeText('ios@test.fr');13 await element(by.id('inputPassword')).typeText('1234');14 await device.pressBack();15 await element(by.text('Login')).tap();16 await expect(element(by.id('welcomeTitle'))).toBeVisible();17 });18 it('should edit my informations', async () => {19 await element(by.id('ProfilePage')).tap();20 await element(by.id('inputEmail')).clearText();21 await element(by.id('inputEmail')).typeText('ios2@test.fr');22 await element(by.id('inputPassword')).clearText();23 await element(by.id('inputPassword')).typeText('12345');24 await element(by.id('inputConfirmPassword')).clearText();25 await element(by.id('inputConfirmPassword')).typeText('12345');26 await device.pressBack();27 await element(by.id('buttonSubmit')).tap();28 await element(by.id('HomePage')).tap();29 await element(by.id('buttonLogout')).tap();30 await expect(element(by.id('title'))).toBeVisible();31 await element(by.id('inputUsername')).typeText('ios2@test.fr');32 await element(by.id('inputPassword')).typeText('12345');33 await device.pressBack();34 await element(by.text('Login')).tap();35 await expect(element(by.id('welcomeTitle'))).toBeVisible();36 });37 it('should reverse my previous edit of my informations', async () => {38 await element(by.id('ProfilePage')).tap();39 await element(by.id('inputEmail')).clearText();40 await element(by.id('inputEmail')).typeText('ios@test.fr');41 await element(by.id('inputPassword')).clearText();42 await element(by.id('inputPassword')).typeText('1234');43 await element(by.id('inputConfirmPassword')).clearText();44 await element(by.id('inputConfirmPassword')).typeText('1234');45 await device.pressBack();46 await element(by.id('buttonSubmit')).tap();47 await element(by.id('HomePage')).tap();48 await element(by.id('buttonLogout')).tap();49 await expect(element(by.id('title'))).toBeVisible();50 await element(by.id('inputUsername')).typeText('ios@test.fr');51 await element(by.id('inputPassword')).typeText('1234');52 await device.pressBack();53 await element(by.text('Login')).tap();54 await expect(element(by.id('welcomeTitle'))).toBeVisible();55 });56 it('should logout succesfully', async () => {57 await element(by.id('HomePage')).tap();58 await element(by.id('buttonLogout')).tap();59 await expect(element(by.id('title'))).toBeVisible();60 });61 it('should register succesfully and delete the account', async () => {62 await element(by.id('buttonRegister')).tap();63 await element(by.id('inputUsername')).clearText();64 await element(by.id('inputUsername')).typeText('barbie');65 await element(by.id('inputEmail')).clearText();66 await element(by.id('inputEmail')).typeText('barbie@ken.fr');67 await element(by.id('inputPassword')).clearText();68 await element(by.id('inputPassword')).typeText('1234');69 await device.pressBack();70 await element(by.id('inputConfirmPassword')).clearText();71 await element(by.id('inputConfirmPassword')).typeText('1234');72 await device.pressBack();73 await element(by.id('buttonRegister')).tap();74 await expect(element(by.id('welcomeTitle'))).toBeVisible();75 await element(by.id('ProfilePage')).tap();76 await element(by.id('buttonDeleteAccount')).tap();77 await expect(element(by.id('title'))).toBeVisible();78 await element(by.id('inputUsername')).typeText('barbie@ken.fr');79 await element(by.id('inputPassword')).typeText('1234');80 await device.pressBack();81 await element(by.text('Login')).tap();82 await expect(element(by.id('title'))).toBeVisible();83 })84});85// import React from 'react';86// import {fireEvent, render} from '@testing-library/react-native';87// import App from '../';88// test('render login container properly', () => {89// const {debug, getByTestId, getByText} = render(<App />);90// // const input = getByTestId('inputUsername');91// // const title = getByTestId('title')92// // fireEvent.changeText(input, 'testsafelymobile@gmail.com');93// // expect(title).toBeVisible();94// });
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!