Best JavaScript code snippet using root
2_home_page.js
Source:2_home_page.js
...6 await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();7 // è¾å
¥æ£ç¡®çææºå·å¯ç 8 await element(by.id('loginPhone_LoginMainScreen')).replaceText('13812345678');9 await element(by.id('password_LoginMainScreen')).replaceText('123456');10 // await waitFor(element(by.id('loginButton_LoginMainScreen'))).toBeVisible().withTimeout(3000);11 await element(by.id('loginButton_LoginMainScreen')).tap();12 await waitFor(element(by.id('GrowTargetSwitch_HomeScreen'))).toBeVisible().withTimeout(10000);13 await element(by.id('GrowTargetSwitch_HomeScreen')).tap();14 // æ¶é´éæ©å¨15 await waitFor(element(by.id('LightBoxScreen_ExpDetailScreen'))).toBeVisible().withTimeout(10000);16 await element(by.id('LightBoxScreen_ExpDetailScreen')).tap();17 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);18 await element(by.id('ç¡®å®')).tap();19 // await element(by.text('èéåæé¿è¶å¿')).scrollTo('bottom');20 // await waitFor(element(by.text('èéå'))).toBeVisible().withTimeout(10000);21 // await element(by.text('èéå')).tap();22 });23 it('ç®æ èä½', async () => {24 // await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();25 // // è¾å
¥æ£ç¡®çææºå·å¯ç 26 // await element(by.id('loginPhone_LoginMainScreen')).replaceText('13812345678');27 // await element(by.id('password_LoginMainScreen')).replaceText('123456');28 // // await waitFor(element(by.id('loginButton_LoginMainScreen'))).toBeVisible().withTimeout(3000);29 // await element(by.id('loginButton_LoginMainScreen')).tap();30 await waitFor(element(by.id('targetJob_TextTwoLink'))).toBeVisible().withTimeout(10000);31 await element(by.id('targetJob_TextTwoLink')).tap();32 // å¶å®æ°çç®æ 33 await waitFor(element(by.text('å¶å®æ°çç®æ '))).toBeVisible().withTimeout(10000);34 await element(by.text('å¶å®æ°çç®æ ')).tap();35 await waitFor(element(by.text('ä¸ä¸å¯¹å£'))).toBeVisible().withTimeout(10000);36 await element(by.text('ä¸ä¸å¯¹å£')).tap();37 await element(by.id('majorBack_GrowingFutureChoose')).tap();38 await waitFor(element(by.id('DRefreshFutureList_GrowingFutureChoose'))).toBeVisible().withTimeout(10000);39 await element(by.id('draftGoal_GrowingFuture')).tap();40 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);41 await element(by.text('IT')).tap();42 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);43 await element(by.text('ç¡®å®')).tap();44 await waitFor(element(by.text('ä¸ä¸æ¥'))).toBeVisible().withTimeout(10000);45 await element(by.text('ä¸ä¸æ¥')).tap();46 await waitFor(element(by.text('产åç»ç'))).toBeVisible().withTimeout(10000);47 await element(by.text('产åç»ç')).tap();48 await waitFor(element(by.text('å å
¥æçè§å'))).toBeVisible().withTimeout(10000);49 await element(by.text('å å
¥æçè§å')).tap();50 await expect(element(by.text('æçç®æ '))).toBeVisible();51 // åæ¢ç®æ 52 await waitFor(element(by.id('GrowTargetSwitch_HomeScreen'))).toBeVisible().withTimeout(10000);53 await element(by.id('GrowTargetSwitch_HomeScreen')).tap();54 await waitFor(element(by.id('homeScreen'))).toBeVisible().withTimeout(10000);55 await expect(element(by.id('homeScreen'))).toBeVisible();56 });57 it('å¼é¨æè·¯', async () => {58 await waitFor(element(by.id('article_HomeScreen'))).toBeVisible().withTimeout(10000);59 await element(by.id('article_HomeScreen')).tap();60 await waitFor(element(by.id('articleDetail_StudentShare'))).toBeVisible().withTimeout(10000);61 await element(by.id('articleDetail_StudentShare')).tap();62 await element(by.text('æç¨')).tap();63 await element(by.text('æ¶è')).tap();64 // ï¼éªè¯å³ä¸è§æåº65 });66 it('æçå±¥å', async () => {67 await waitFor(element(by.id('myResume_HomeScreen'))).toBeVisible().withTimeout(10000);68 await element(by.id('myResume_HomeScreen')).tap();69 // //ç¼è¾åºæ¬ä¿¡æ¯70 await waitFor(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible().withTimeout(10000);71 await element(by.id('nameInput_EditUserBaseInfoScreen')).replaceText(Math.random().toString().slice(-4));72 await element(by.text('ä¿å')).tap();73 await expect(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible();74 // //ç¼è¾æè²ç»å75 await waitFor(element(by.id('editEducationnfo_TrackRecordScreen'))).toBeVisible().withTimeout(10000);76 await element(by.id('editEducationnfo_TrackRecordScreen')).tap();77 // 认è¯78 await waitFor(element(by.text('认è¯'))).toBeVisible().withTimeout(10000);79 await element(by.text('认è¯')).tap();80 await expect(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible();81 await element(by.id('account_AddChisAccount')).replaceText('123');82 await element(by.id('password_AddChisAccount')).replaceText('123456');83 await element(by.text('ç»å®è´¦å·')).tap();84 await element(by.text('å®æ')).tap();85 // ç¼è¾86 await waitFor(element(by.text('ç¼è¾'))).toBeVisible().withTimeout(10000);87 await element(by.text('ç¼è¾')).tap();88 await waitFor(element(by.text('å é¤è¯¥æè²ç»å'))).toBeVisible().withTimeout(10000);89 await element(by.text('å é¤è¯¥æè²ç»å')).tap();90 await expect(element(by.text('该æè²ç»å已被设置为é»è®¤èº«ä»½ï¼ä¸å¯å é¤ï¼'))).toBeVisible();91 await element(by.text('ç¡®å®')).tap();92 await waitFor(element(by.text('ä¿å'))).toBeVisible().withTimeout(10000);93 await element(by.text('ä¿å')).tap();94 await element(by.traits(['button']).and(by.label('Back'))).tap();95 // æ·»å 96 // //æ·»å å¨æ ¡æ绩97 await waitFor(element(by.id('editLearnedCourse_TrackRecordScreen'))).toBeVisible().withTimeout(10000);98 await element(by.id('editLearnedCourse_TrackRecordScreen')).tap();99 await expect(element(by.text('æ£å¨éªè¯ä¸'))).toBeVisible();100 await element(by.traits(['button']).and(by.label('Back'))).tap();101 // //æ·»å å¨æ ¡èå¡102 await waitFor(element(by.id('inSchoolJobs_TrackRecordScreen'))).toBeVisible().withTimeout(10000);103 await element(by.id('inSchoolJobs_TrackRecordScreen')).tap();104 // èå¡105 await waitFor(element(by.id('jobInput_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);106 await element(by.id('jobInput_EditInSchoolJobsScreen')).replaceText('12345');107 // å¼å§æ¶é´108 await element(by.id('startInput_EditInSchoolJobsScreen')).tap();109 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);110 await element(by.text('ç¡®å®')).tap();111 // ç»ææ¶é´112 await waitFor(element(by.id('endInput_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);113 await element(by.id('endInput_EditInSchoolJobsScreen')).tap();114 await element(by.label('SelectorDate')).scroll(100, 'down');115 await element(by.text('ç¡®å®')).tap();116 // èå¡æè¿°117 await waitFor(element(by.id('inputDetail_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);118 await element(by.id('inputDetail_EditInSchoolJobsScreen')).replaceText('12345');119 await element(by.text('ä¿å')).tap();120 await expect(element(by.text('å¨æ ¡èä½'))).toBeVisible();121 // //æ·»å è·å¥ç»å æ æ³å®ä½ç¸åå¾çé®é¢122 // //æ·»å å®ä¹ ç»å123 await waitFor(element(by.id('addPractice_TrackRecordScreen'))).toBeVisible().withTimeout(10000);124 await element(by.id('addPractice_TrackRecordScreen')).tap();125 // å
¬å¸126 await waitFor(element(by.id('companyInput_AddPracticeScreen'))).toBeVisible().withTimeout(10000);127 await element(by.id('companyInput_AddPracticeScreen')).replaceText('12345');128 // èå¡129 await waitFor(element(by.id('jobInput_AddPracticeScreen'))).toBeVisible().withTimeout(10000);130 await element(by.id('jobInput_AddPracticeScreen')).replaceText('12345');131 // å¼å§æ¶é´132 await element(by.text('å¼å§æ¶é´')).tap();133 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);134 await element(by.text('ç¡®å®')).tap();135 // ç»ææ¶é´136 await waitFor(element(by.id('ç»ææ¶é´'))).toBeVisible().withTimeout(10000);137 await element(by.id('ç»ææ¶é´')).tap();138 await element(by.label('SelectorDate')).scroll(100, 'down');139 await element(by.text('ç¡®å®')).tap();140 // å·¥ä½å
容æè¿°141 await waitFor(element(by.id('workDetail_AddPracticeScreen'))).toBeVisible().withTimeout(10000);142 await element(by.id('workDetail_AddPracticeScreen')).replaceText('12345');143 await element(by.text('ä¿å')).tap();144 await expect(element(by.text('å®ä¹ ç»å'))).toBeVisible();145 // //æ·»å è¯ä¹¦ æ æ³å®ä½ç¸åå¾çé®é¢146 ////æ·»å èªæè¯ä»·147 await waitFor(element(by.id('remarkInput_SelfEvaluationScreen'))).toBeVisible().withTimeout(10000);148 await element(by.id('remarkInput_SelfEvaluationScreen')).replaceText('12345');149 await element(by.text('ä¿å')).tap();150 await expect(element(by.text('èªæè¯ä»·'))).toBeVisible();151 });152 it('æè¦æé¿', async () => {153 // æçç®æ 154 await waitFor(element(by.id('myGrow_HomeScreen'))).toBeVisible().withTimeout(10000);155 await element(by.id('myGrow_HomeScreen')).tap();156 await waitFor(element(by.id('targetJob_TextTwoLink'))).toBeVisible().withTimeout(10000);157 await element(by.id('targetJob_TextTwoLink')).tap();158 await expect(element(by.text('æçç®æ '))).toBeVisible();159 await element(by.text('æ¶è')).tap();160 await expect(element(by.text('å®ä¹ ç»å'))).toBeVisible();161 await element(by.traits(['button']).and(by.label('Back'))).tap();162 // å¼é¨æè·¯163 await waitFor(element(by.id('imageStudentShare_GrowScreen'))).toBeVisible().withTimeout(10000);164 await element(by.id('imageStudentShare_GrowScreen')).tap();165 await expect(element(by.text('è§å¾æç¨'))).toBeVisible();166 await element(by.traits(['button']).and(by.label('Back'))).tap();167 // èåºæè½168 await waitFor(element(by.id('jobSkill_GrowScreen'))).toBeVisible().withTimeout(10000);169 await element(by.id('jobSkill_GrowScreen')).tap();170 await waitFor(element(by.text('office-excel'))).toBeVisible().withTimeout(10000);171 await element(by.id('office-excel')).tap();172 await waitFor(element(by.text('å®æ'))).toBeVisible().withTimeout(10000);173 await element(by.id('å®æ')).tap();174 await waitFor(element(by.id('inputfeel_PunchSkill'))).toBeVisible().withTimeout(10000);175 await element(by.id('inputfeel_PunchSkill')).tap();176 await element(by.id('achiveCard_PunchSkill')).tap();177 // ï¼å
³éå¼¹åºçå®æä»»å¡æ示178 // è¯ä¹¦èåï¼å®ä½ç¸åå¾çé®é¢179 });180 it('æ¯æ¥æå¡', async () => {181 await waitFor(element(by.id('growCheckin_HomeScreen'))).toBeVisible().withTimeout(10000);182 await element(by.id('growCheckin_HomeScreen')).tap();183 await waitFor(element(by.text('ä»æ¥èåè¯äº')).and(by.text('æªæå¡'))).toBeVisible().withTimeout(10000);184 await element(by.text('ä»æ¥èåè¯äº')).and(by.text('æªæå¡')).tap();185 await element(by.id('æ¥çææ±æ»')).tap();186 await element(by.traits(['button']).and(by.label('Back'))).tap();187 // ï¼å
³éå¼¹åºçå®æä»»å¡æ示188 });189 //// ç®èªèµ190 it('ç®èªèµ', async () => {191 // å¼å§ç®èªèµ192 await waitFor(element(by.id('calSalary_HomeScreen'))).toBeVisible().withTimeout(10000);193 await element(by.id('calSalary_HomeScreen')).tap();194 await waitFor(element(by.text('å¼å§ç®èªèµ'))).toBeVisible().withTimeout(10000);195 await element(by.text('å¼å§ç®èªèµ')).tap();196 await waitFor(element(by.id('chengdu_Salary00'))).toBeVisible().withTimeout(10000);197 await element(by.id('chengdu_Salary00')).tap();198 await waitFor(element(by.id('gongChengShi_Salary01'))).toBeVisible().withTimeout(10000);199 await element(by.id('gongChengShi_Salary01')).tap();200 await waitFor(element(by.text('Android'))).toBeVisible().withTimeout(10000);201 await element(by.text('Android')).tap();202 await waitFor(element(by.id('benKe_Salary03'))).toBeVisible().withTimeout(10000);203 await element(by.id('benKe_Salary03')).tap();204 await waitFor(element(by.id('baiYang_Salary06'))).toBeVisible().withTimeout(10000);205 await element(by.id('baiYang_Salary06')).tap();206 await waitFor(element(by.id('nv_Salary07'))).toBeVisible().withTimeout(10000);207 await element(by.id('nv_Salary07')).tap();208 await waitFor(element(by.id('OT_Salary08'))).toBeVisible().withTimeout(10000);209 await element(by.id('OT_Salary08')).tap();210 await waitFor(element(by.id('praise_Salary09'))).toBeVisible().withTimeout(10000);211 await element(by.id('praise_Salary09')).tap();212 await waitFor(element(by.text('çææçèªèµ'))).toBeVisible().withTimeout(10000);213 await element(by.text('çææçèªèµ')).tap();214 // åç©ä¸æ¬¡215 await waitFor(element(by.text('åç©ä¸æ¬¡'))).toBeVisible().withTimeout(10000);216 await element(by.text('åç©ä¸æ¬¡')).tap();217 await waitFor(element(by.id('calSalary_HomeScreen'))).toBeVisible().withTimeout(10000);218 await element(by.id('calSalary_HomeScreen')).tap();219 await waitFor(element(by.text('å¼å§ç®èªèµ'))).toBeVisible().withTimeout(10000);220 await element(by.text('å¼å§ç®èªèµ')).tap();221 await waitFor(element(by.id('chengdu_Salary00'))).toBeVisible().withTimeout(10000);222 await element(by.id('chengdu_Salary00')).tap();223 await waitFor(element(by.id('gongChengShi_Salary01'))).toBeVisible().withTimeout(10000);224 await element(by.id('gongChengShi_Salary01')).tap();225 await waitFor(element(by.text('Android'))).toBeVisible().withTimeout(10000);226 await element(by.text('Android')).tap();227 await waitFor(element(by.id('benKe_Salary03'))).toBeVisible().withTimeout(10000);228 await element(by.id('benKe_Salary03')).tap();229 await waitFor(element(by.id('baiYang_Salary06'))).toBeVisible().withTimeout(10000);230 await element(by.id('baiYang_Salary06')).tap();231 await waitFor(element(by.id('nv_Salary07'))).toBeVisible().withTimeout(10000);232 await element(by.id('nv_Salary07')).tap();233 await waitFor(element(by.id('OT_Salary08'))).toBeVisible().withTimeout(10000);234 await element(by.id('OT_Salary08')).tap();235 await waitFor(element(by.id('praise_Salary09'))).toBeVisible().withTimeout(10000);236 await element(by.id('praise_Salary09')).tap();237 await waitFor(element(by.text('çææçèªèµ'))).toBeVisible().withTimeout(10000);238 await element(by.text('çææçèªèµ')).tap();239 // è¿åé¦é¡µ240 await waitFor(element(by.text('è¿åé¦é¡µ'))).toBeVisible().withTimeout(10000);241 await element(by.text('è¿åé¦é¡µ')).tap();242 await expect(element(by.id('calSalary_HomeScreen'))).toBeVisible();243 });244 // //èªèµå¢é¿è¶å¿245 it('èªèµå¢é¿è¶å¿', async () => {246 await waitFor(element(by.text('èªèµå¢é¿è¶å¿'))).toBeVisible().withTimeout(10000);247 await element(by.text('èªèµå¢é¿è¶å¿')).tap();248 await waitFor(element(by.text('æ¬æ ¡å°±ä¸æ
åµ'))).toBeVisible().withTimeout(10000);249 await element(by.text('æ¬æ ¡å°±ä¸æ
åµ')).tap();250 });251 // //èªèµå¢é¿è¶å¿252 it('å°±ä¸é¢ååå¸', async () => {253 await waitFor(element(by.text('å°±ä¸é¢ååå¸'))).toBeVisible().withTimeout(10000);254 await element(by.text('å°±ä¸é¢ååå¸')).tap();255 await waitFor(element(by.text('å°±ä¸è¡ä¸åå¸'))).toBeVisible().withTimeout(10000);256 await element(by.text('å°±ä¸è¡ä¸åå¸')).scrollTo('bottom');257 });258 // //å°±ä¸å
¬å¸åå¸259 it('å°±ä¸å
¬å¸åå¸', async () => {260 await waitFor(element(by.text('å°±ä¸é¢ååå¸'))).toBeVisible().withTimeout(10000);261 await element(by.text('å°±ä¸é¢ååå¸')).scrollTo('bottom');262 await waitFor(element(by.text('å°±ä¸å
¬å¸åå¸'))).toBeVisible().withTimeout(10000);263 await element(by.text('å°±ä¸å
¬å¸åå¸')).tap();264 });265 // //æ¥è¯¢æ´å¤266 it('æ¥è¯¢æ´å¤', async () => {267 await waitFor(element(by.text('å°±ä¸é¢ååå¸'))).toBeVisible().withTimeout(10000);268 await element(by.text('å°±ä¸é¢ååå¸')).scrollTo('bottom');269 await waitFor(element(by.text('æ¥è¯¢æ´å¤'))).toBeVisible().withTimeout(10000);270 await element(by.text('æ¥è¯¢æ´å¤')).tap();271 // å¦æ ¡272 await waitFor(element(by.text('æé½ç工大å¦'))).toBeVisible().withTimeout(10000);273 await element(by.text('æé½ç工大å¦')).scrollTo('bottom');274 await expect(element(by.text('åå·è´¢ç»èä¸å¦é¢'))).toBeVisible();275 // ä¸ä¸276 await waitFor(element(by.text('ä¸ä¸'))).toBeVisible().withTimeout(10000);277 await element(by.text('ä¸ä¸')).tap();278 await waitFor(element(by.text('æ¬ç§ä¸ä¸'))).toBeVisible().withTimeout(10000);279 await element(by.text('æ¬ç§ä¸ä¸')).tap();280 await waitFor(element(by.text('å²å¦'))).toBeVisible().withTimeout(10000);281 await element(by.text('å²å¦')).tap();282 await waitFor(element(by.text('å²å¦ç±»'))).toBeVisible().withTimeout(10000);283 await element(by.text('å²å¦ç±»')).tap();284 await waitFor(element(by.text('å²å¦'))).toBeVisible().withTimeout(10000);285 await element(by.text('å²å¦')).tap();286 await element(by.text('ä¸ä¸æ¦åµ')).scrollTo('bottom');287 // ï¼æ¶èæé®288 await element(by.traits(['button']).and(by.label('Back'))).tap();289 // å¦æ ¡290 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);291 await element(by.text('IT')).tap();292 await expect(element(by.text('æ°æ®è§£è¯»'))).toBeVisible();293 // èä½294 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);295 await element(by.text('IT')).tap();296 await waitFor(element(by.text('ææ¯-人工æºè½'))).toBeVisible().withTimeout(10000);297 await element(by.text('ææ¯-人工æºè½')).tap();298 await waitFor(element(by.text('æºå¨å¦ä¹ å·¥ç¨å¸'))).toBeVisible().withTimeout(10000);299 await element(by.text('æºå¨å¦ä¹ å·¥ç¨å¸')).tap();300 await waitFor(element(by.text('å å
¥æçè§å'))).toBeVisible().withTimeout(10000);301 await element(by.text('å å
¥æçè§å')).tap();302 await expect(element(by.text('æçç®æ '))).toBeVisible();303 });304 // //æ¥è¯¢æ´å¤-æç´¢305 it('æ¥è¯¢æ´å¤-æç´¢', async () => {306 /////307 });...
02-team.spec.js
Source:02-team.spec.js
...4} = require('../../helpers/app');5async function navigateToRoom(roomName) {6 await searchRoom(`${ roomName }`);7 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();8 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);9}10async function openActionSheet(username) {11 await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);12 await element(by.id(`room-members-view-item-${ username }`)).tap();13 await sleep(300);14 await expect(element(by.id('action-sheet'))).toExist();15 await expect(element(by.id('action-sheet-handle'))).toBeVisible();16}17async function navigateToRoomActions() {18 await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);19 await element(by.id('room-header')).tap();20 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);21}22async function backToActions() {23 await tapBack();24 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);25}26async function closeActionSheet() {27 await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);28}29async function waitForToast() {30 await sleep(1000);31}32describe('Team', () => {33 const team = data.teams.private.name;34 const user = data.users.alternate;35 const room = `private${ data.random }-channel-team`;36 const existingRoom = data.groups.alternate.name;37 before(async() => {38 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });39 await navigateToLogin();40 await login(data.users.regular.username, data.users.regular.password);41 await navigateToRoom(team);42 });43 describe('Team Room', () => {44 describe('Team Header', () => {45 it('should have actions button ', async() => {46 await expect(element(by.id('room-header'))).toExist();47 });48 it('should have team channels button ', async() => {49 await expect(element(by.id('room-view-header-team-channels'))).toExist();50 });51 it('should have threads button ', async() => {52 await expect(element(by.id('room-view-header-threads'))).toExist();53 });54 it('should have threads button ', async() => {55 await expect(element(by.id('room-view-search'))).toExist();56 });57 });58 describe('Team Header Usage', () => {59 it('should navigate to team channels view', async() => {60 await element(by.id('room-view-header-team-channels')).tap();61 await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000);62 });63 });64 describe('Team Channels Header', () => {65 it('should have actions button ', async() => {66 await expect(element(by.id('room-header'))).toExist();67 });68 it('should have team channels button ', async() => {69 await expect(element(by.id('team-channels-view-create'))).toExist();70 });71 it('should have threads button ', async() => {72 await expect(element(by.id('team-channels-view-search'))).toExist();73 });74 });75 describe('Team Channels Header Usage', () => {76 it('should navigate to add team channels view', async() => {77 await element(by.id('team-channels-view-create')).tap();78 await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);79 });80 it('should have create new button', async() => {81 await waitFor(element(by.id('add-channel-team-view-create-channel'))).toExist().withTimeout(5000);82 });83 it('should add existing button', async() => {84 await waitFor(element(by.id('add-channel-team-view-add-existing'))).toExist().withTimeout(5000);85 });86 });87 describe('Channels', () => {88 it('should create new channel for team', async() => {89 await element(by.id('add-channel-team-view-create-channel')).tap();90 await element(by.id('select-users-view-search')).replaceText('rocket.cat');91 await element(by.id('select-users-view-item-rocket.cat')).tap();92 await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);93 await element(by.id('selected-users-view-submit')).tap();94 await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);95 await element(by.id('create-channel-name')).replaceText('');96 await element(by.id('create-channel-name')).typeText(room);97 await element(by.id('create-channel-submit')).tap();98 await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);99 await expect(element(by.id('room-view'))).toExist();100 await expect(element(by.id('room-view-header-team-channels'))).toExist();101 await element(by.id('room-view-header-team-channels')).tap();102 await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000);103 await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(6000);104 await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist();105 await element(by.id(`rooms-list-view-item-${ room }`)).tap();106 await waitFor(element(by.id(`room-view-title-${ room }`))).toExist().withTimeout(60000);107 await expect(element(by.id(`room-view-title-${ room }`))).toExist();108 await expect(element(by.id('room-view-header-team-channels'))).toExist();109 await expect(element(by.id('room-view-header-threads'))).toExist();110 await expect(element(by.id('room-view-search'))).toExist();111 await tapBack();112 });113 it('should add existing channel to team', async() => {114 await element(by.id('team-channels-view-create')).tap();115 await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);116 await element(by.id('add-channel-team-view-add-existing')).tap();117 await waitFor(element(by.id('add-existing-channel-view'))).toExist().withTimeout(60000);118 await expect(element(by.id(`add-existing-channel-view-item-${ existingRoom }`))).toExist();119 await element(by.id(`add-existing-channel-view-item-${ existingRoom }`)).tap();120 await waitFor(element(by.id('add-existing-channel-view-submit'))).toExist().withTimeout(6000);121 await element(by.id('add-existing-channel-view-submit')).tap();122 await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);123 await expect(element(by.id('room-view'))).toExist();124 await expect(element(by.id('room-view-header-team-channels'))).toExist();125 await element(by.id('room-view-header-team-channels')).tap();126 await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(10000);127 });128 it('should activate/deactivate auto-join to channel', async() => {129 await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress();130 await waitFor(element(by.id('action-sheet-auto-join'))).toBeVisible().withTimeout(5000);131 await waitFor(element(by.id('auto-join-unchecked'))).toBeVisible().withTimeout(5000);132 await waitFor(element(by.id('action-sheet-remove-from-team'))).toBeVisible().withTimeout(5000);133 await waitFor(element(by.id('action-sheet-delete'))).toBeVisible().withTimeout(5000);134 await element(by.id('auto-join-unchecked')).tap();135 await waitFor(element(by.id('auto-join-tag'))).toBeVisible().withTimeout(5000);136 await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress();137 await waitFor(element(by.id('auto-join-checked'))).toBeVisible().withTimeout(5000);138 await element(by.id('auto-join-checked')).tap();139 await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000);140 await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000);141 });142 });143 describe('Team actions', () => {144 before(async() => {145 await tapBack();146 await navigateToRoomActions();147 });148 it('should add users to the team', async() => {149 await waitFor(element(by.id('room-actions-add-user'))).toExist().withTimeout(10000);150 await element(by.id('room-actions-add-user')).tap();151 const rocketCat = 'rocket.cat';152 await element(by.id('select-users-view-search')).replaceText('rocket.cat');153 await waitFor(element(by.id(`select-users-view-item-${ rocketCat }`))).toExist().withTimeout(10000);154 await element(by.id(`select-users-view-item-${ rocketCat }`)).tap();155 await waitFor(element(by.id(`selected-user-${ rocketCat }`))).toExist().withTimeout(5000);156 await waitFor(element(by.id('select-users-view-search'))).toExist().withTimeout(4000);157 await element(by.id('select-users-view-search')).tap();158 await element(by.id('select-users-view-search')).replaceText(user.username);159 await waitFor(element(by.id(`select-users-view-item-${ user.username }`))).toExist().withTimeout(10000);160 await element(by.id(`select-users-view-item-${ user.username }`)).tap();161 await waitFor(element(by.id(`selected-user-${ user.username }`))).toExist().withTimeout(5000);162 await element(by.id('selected-users-view-submit')).tap();163 await sleep(300);164 await waitFor(element(by.id('room-actions-members'))).toExist().withTimeout(10000);165 await element(by.id('room-actions-members')).tap();166 await element(by.id('room-members-view-toggle-status')).tap();167 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);168 await backToActions();169 });170 it('should try to leave to leave team and raise alert', async() => {171 await element(by.id('room-actions-scrollview')).scrollTo('bottom');172 await waitFor(element(by.id('room-actions-leave-channel'))).toExist().withTimeout(2000);173 await element(by.id('room-actions-leave-channel')).tap();174 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);175 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);176 await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);177 await element(by.id(`select-list-view-item-${ room }`)).tap();178 await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);179 await element(by.text('OK')).tap();180 await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);181 await element(by.id('select-list-view-submit')).tap();182 await waitFor(element(by.text('Last owner cannot be removed'))).toExist().withTimeout(8000);183 await element(by.text('OK')).tap();184 await tapBack();185 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);186 });187 describe('Room Members', () => {188 before(async() => {189 await element(by.id('room-actions-members')).tap();190 await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000);191 });192 it('should show all users', async() => {193 await element(by.id('room-members-view-toggle-status')).tap();194 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);195 });196 it('should filter user', async() => {197 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);198 await element(by.id('room-members-view-search')).replaceText('rocket');199 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toBeNotVisible().withTimeout(60000);200 await element(by.id('room-members-view-search')).tap();201 await element(by.id('room-members-view-search')).clearText('');202 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);203 });204 it('should remove member from team', async() => {205 await openActionSheet('rocket.cat');206 await element(by.id('action-sheet-remove-from-team')).tap();207 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(5000);208 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(5000);209 await element(by.id(`select-list-view-item-${ room }`)).tap();210 await waitFor(element(by.id(`${ room }-checked`))).toExist().withTimeout(5000);211 await element(by.id(`select-list-view-item-${ room }`)).tap();212 await waitFor(element(by.id(`${ room }-unchecked`))).toExist().withTimeout(5000);213 await element(by.id('select-list-view-submit')).tap();214 await waitFor(element(by.id('room-members-view-item-rocket.cat'))).toBeNotVisible().withTimeout(60000);215 });216 it('should set member as owner', async() => {217 await openActionSheet(user.username);218 await element(by.id('action-sheet-set-owner')).tap();219 await waitForToast();220 await openActionSheet(user.username);221 await waitFor(element(by.id('action-sheet-set-owner-checked'))).toBeVisible().withTimeout(6000);222 await closeActionSheet();223 });224 it('should leave team', async() => {225 await tapBack();226 await element(by.id('room-actions-scrollview')).scrollTo('bottom');227 await waitFor(element(by.id('room-actions-leave-channel'))).toExist().withTimeout(2000);228 await element(by.id('room-actions-leave-channel')).tap();229 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);230 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);231 await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);232 await element(by.id(`select-list-view-item-${ room }`)).tap();233 await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);234 await element(by.text('OK')).tap();235 await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);236 await element(by.id('select-list-view-submit')).tap();237 await waitFor(element(by.id(`rooms-list-view-item-${ team }`))).toBeNotVisible().withTimeout(60000);238 });239 });240 });241 });...
01-e2eencryption.spec.js
Source:01-e2eencryption.spec.js
...6const otheruser = data.users.alternate;7const checkServer = async(server) => {8 const label = `Connected to ${ server }`;9 await element(by.id('rooms-list-view-sidebar')).tap();10 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);11 await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000);12 await element(by.id('sidebar-close-drawer')).tap();13};14const checkBanner = async() => {15 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);16};17async function navigateToRoom(roomName) {18 await searchRoom(`${ roomName }`);19 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();20 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);21}22async function waitForToast() {23 await sleep(300);24}25async function navigateSecurityPrivacy() {26 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);27 await element(by.id('rooms-list-view-sidebar')).tap();28 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);29 await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);30 await element(by.id('sidebar-settings')).tap();31 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);32 await element(by.id('settings-view-security-privacy')).tap();33 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);34}35describe('E2E Encryption', () => {36 const room = `encrypted${ data.random }`;37 const newPassword = 'abc';38 before(async() => {39 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });40 await navigateToLogin();41 await login(testuser.username, testuser.password);42 });43 describe('Banner', () => {44 describe('Render', () => {45 it('should have encryption badge', async() => {46 await checkBanner();47 });48 });49 describe('Usage', () => {50 it('should tap encryption badge and open save password modal', async() => {51 await element(by.id('listheader-encryption')).tap();52 await waitFor(element(by.id('e2e-save-password-view'))).toBeVisible().withTimeout(2000);53 });54 it('should tap "How it works" and navigate', async() => {55 await element(by.id('e2e-save-password-view-how-it-works').and(by.label('How It Works'))).tap();56 await waitFor(element(by.id('e2e-how-it-works-view'))).toBeVisible().withTimeout(2000);57 await tapBack();58 });59 it('should tap "Save my password" and close modal', async() => {60 await element(by.id('e2e-save-password-view-saved-password').and(by.label('I Saved My E2E Password'))).tap();61 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);62 });63 it('should create encrypted room', async() => {64 await element(by.id('rooms-list-view-create-channel')).tap();65 await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);66 await element(by.id('new-message-view-create-channel')).tap();67 await waitFor(element(by.id('select-users-view'))).toBeVisible().withTimeout(2000);68 await element(by.id('select-users-view-search')).replaceText(otheruser.username);69 await waitFor(element(by.id(`select-users-view-item-${ otheruser.username }`))).toBeVisible().withTimeout(60000);70 await element(by.id(`select-users-view-item-${ otheruser.username }`)).tap();71 await waitFor(element(by.id(`selected-user-${ otheruser.username }`))).toBeVisible().withTimeout(5000);72 await element(by.id('selected-users-view-submit')).tap();73 await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);74 await element(by.id('create-channel-name')).replaceText(room);75 await element(by.id('create-channel-encrypted')).longPress();76 await element(by.id('create-channel-submit')).tap();77 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);78 await waitFor(element(by.id(`room-view-title-${ room }`))).toBeVisible().withTimeout(60000);79 });80 it('should send message and be able to read it', async() => {81 await mockMessage('message');82 await tapBack();83 });84 });85 });86 describe('Security and Privacy', () => {87 it('should navigate to security privacy', async() => {88 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);89 await element(by.id('rooms-list-view-sidebar')).tap();90 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);91 await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);92 await element(by.id('sidebar-settings')).tap();93 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);94 await element(by.id('settings-view-security-privacy')).tap();95 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);96 });97 it('render', async() => {98 await expect(element(by.id('security-privacy-view-e2e-encryption'))).toExist();99 await expect(element(by.id('security-privacy-view-screen-lock'))).toExist();100 await expect(element(by.id('security-privacy-view-analytics-events'))).toExist();101 await expect(element(by.id('security-privacy-view-crash-report'))).toExist();102 });103 });104 describe('E2E Encryption Security', () => {105 it('should navigate to e2e encryption security', async() => {106 await element(by.id('security-privacy-view-e2e-encryption')).tap();107 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);108 });109 describe('Render', () => {110 it('should have items', async() => {111 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);112 await expect(element(by.id('e2e-encryption-security-view-password'))).toExist();113 await expect(element(by.id('e2e-encryption-security-view-change-password').and(by.label('Save Changes')))).toExist();114 await expect(element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key')))).toExist();115 });116 });117 describe('Change password', () => {118 it('should change password', async() => {119 await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword);120 await element(by.id('e2e-encryption-security-view-change-password')).tap();121 await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);122 await expect(element(by.text('Make sure you\'ve saved it carefully somewhere else.'))).toExist();123 await element(by.label('Yes, change it').and(by.type('_UIAlertControllerActionView'))).tap();124 await waitForToast();125 });126 it('should navigate to the room and messages should remain decrypted', async() => {127 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);128 await tapBack();129 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);130 await tapBack();131 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);132 await element(by.id('settings-view-drawer')).tap();133 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);134 await element(by.id('sidebar-chats')).tap();135 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);136 await navigateToRoom(room);137 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).toExist().withTimeout(2000);138 });139 it('should logout, login and messages should be encrypted', async() => {140 await tapBack();141 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);142 await logout();143 await navigateToLogin();144 await login(testuser.username, testuser.password);145 await navigateToRoom(room);146 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).not.toExist().withTimeout(2000);147 await expect(element(by.label('Encrypted message')).atIndex(0)).toExist();148 });149 it('should enter new e2e password and messages should be decrypted', async() => {150 await tapBack();151 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);152 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Enter Your E2E Password')))).toBeVisible().withTimeout(2000);153 await element(by.id('listheader-encryption').withDescendant(by.label('Enter Your E2E Password'))).tap();154 await waitFor(element(by.id('e2e-enter-your-password-view'))).toBeVisible().withTimeout(2000);155 await element(by.id('e2e-enter-your-password-view-password')).typeText(newPassword);156 await element(by.id('e2e-enter-your-password-view-confirm')).tap();157 await waitFor(element(by.id('listheader-encryption'))).not.toExist().withTimeout(10000);158 await navigateToRoom(room);159 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).toExist().withTimeout(2000);160 });161 });162 describe('Reset E2E key', () => {163 it('should reset e2e key', async() => {164 await tapBack();165 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);166 await navigateSecurityPrivacy();167 await element(by.id('security-privacy-view-e2e-encryption')).tap();168 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);169 await element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key'))).tap();170 await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);171 await expect(element(by.text('You\'re going to be logged out.'))).toExist();172 await element(by.label('Yes, reset it').and(by.type('UILabel'))).tap();173 await sleep(2000);174 await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);175 await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(2000);176 await element(by.label('OK').and(by.type('_UIAlertControllerActionView'))).tap();177 await element(by.id('workspace-view-login')).tap();178 await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);179 await login(testuser.username, testuser.password);180 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(2000);181 });182 });183 });184 describe('Persist Banner', () => {185 it('check save banner', async() => {186 await checkServer(data.server);187 await checkBanner();188 });189 it('should add server and create new user', async() => {190 await sleep(5000);191 await element(by.id('rooms-list-header-server-dropdown-button')).tap();192 await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);193 await element(by.id('rooms-list-header-server-add')).tap();194 // TODO: refactor195 await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);196 await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);197 await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);198 await element(by.id('workspace-view-register')).tap();199 await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);200 // Register new user201 await element(by.id('register-view-name')).replaceText(data.registeringUser.username);202 await element(by.id('register-view-username')).replaceText(data.registeringUser.username);203 await element(by.id('register-view-email')).replaceText(data.registeringUser.email);204 await element(by.id('register-view-password')).typeText(data.registeringUser.password);205 await element(by.id('register-view-submit')).tap();206 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);207 await checkServer(data.alternateServer);208 });209 it('should change back', async() => {210 await element(by.id('rooms-list-header-server-dropdown-button')).tap();211 await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);212 await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();213 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);214 await checkServer(data.server);215 await checkBanner();216 });217 it('should reopen the app and have banner', async() => {218 await device.launchApp({219 permissions: { notifications: 'YES' },220 newInstance: true221 });222 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);223 await checkBanner();224 });225 });...
4_my.js
Source:4_my.js
...11}12describe('æç', () => {13 beforeEach(async () => {14 await device.reloadReactNative();15 await waitFor(element(by.id('myTab_PersonScreen'))).toBeVisible().withTimeout(10000);16 await element(by.id('myTab_PersonScreen')).tap();17 });18 it('æ¶æ¯éç¥', async () => {19 await waitFor(element(by.id('message_PageHeader'))).toBeVisible().withTimeout(10000);20 await element(by.id('message_PageHeader')).tap();21 await expect(element(by.id('messageDetail_MessageNotifyScreen'))).toBeVisible();22 // ï¼éªè¯é»è¾23 });24 it('设置', async () => {25 await waitFor(element(by.id('setting_PageHeader'))).toBeVisible().withTimeout(10000);26 await element(by.id('setting_PageHeader')).tap();27 await expect(element(by.text('ç¼è¾ä¸ªäººèµæ'))).toBeVisible();28 // //ç¼è¾ä¸ªäººèµæ29 await waitFor(element(by.text('ç¼è¾ä¸ªäººèµæ'))).toBeVisible().withTimeout(10000);30 await element(by.text('ç¼è¾ä¸ªäººèµæ')).tap();31 // ï¼æ´æ¢å¤´åï¼å®ä½ç¸åå
ç´ 32 await waitFor(element(by.id('changeImage_EditUserBaseInfoScreen'))).toBeVisible().withTimeout(10000);33 await element(by.id('changeImage_EditUserBaseInfoScreen')).tap();34 await waitFor(element(by.id('openImageSelection_EditUserbaseInfoScreen'))).toBeVisible().withTimeout(10000);35 await element(by.id('openImageSelection_EditUserbaseInfoScreen')).tap();36 // ç¼è¾èµæä¸çå
¶ä»itemå·²å¨æçå±¥åç¼è¾-åºæ¬ä¿¡æ¯å®ç°37 // ï¼ä¿åæé®å®ä½38 // //身份管ç39 await waitFor(element(by.text('身份管ç'))).toBeVisible().withTimeout(10000);40 await element(by.text('身份管ç')).tap();41 await expect(element(by.text('温馨æ示'))).toBeVisible();42 await element(by.id('selectNor_IdentifyManageList')).tap();43 // ï¼éªè¯é»è¾44 // è¿åæé®45 // //è´¦å·ä¸å®å
¨46 await waitFor(element(by.text('è´¦å·ä¸å®å
¨'))).toBeVisible().withTimeout(10000);47 await element(by.text('è´¦å·ä¸å®å
¨')).tap();48 // ææºå·ç 49 await waitFor(element(by.text('ææºå·ç '))).toBeVisible().withTimeout(10000);50 await element(by.text('ææºå·ç ')).tap();51 await waitFor(element(by.id('setPwd_PhoneManageScreen'))).toBeVisible().withTimeout(10000);52 await element(by.id('setPwd_PhoneManageScreen')).tap();53 await waitFor(element(by.id('inputCode_SetPasswordScreen'))).toBeVisible().withTimeout(10000);54 await element(by.id('inputCode_SetPasswordScreen')).replaceText(Math.random().toString().slice(-4));55 await element(by.id('inputPassword_SetPasswordScreen')).replaceText('123456');56 await element(by.id('confirm_SetPasswordScreen')).tap();57 // æ´æ¢ææºå·58 await waitFor(element(by.id('changePhone_PhoneManageScreen'))).toBeVisible().withTimeout(10000);59 await element(by.id('changePhone_PhoneManageScreen')).tap();60 await waitFor(element(by.id('inputNewPhone_ChangePhoneScreen'))).toBeVisible().withTimeout(10000);61 await element(by.id('inputNewPhone_ChangePhoneScreen')).replaceText('13812345678');62 await element(by.id('inputMsgCode_ChangePhoneScreen')).replaceText(Math.random().toString().slice(-4));63 await element(by.id('confirm_ChangePhoneScreen')).tap();64 // ï¼å¾®ä¿¡æµè¯65 // //éç§è®¾ç½®66 await element(by.traits(['button']).and(by.label('Back'))).tap();67 await element(by.traits(['button']).and(by.label('Back'))).tap();68 await waitFor(element(by.text('éç§è®¾ç½®'))).toBeVisible().withTimeout(10000);69 await element(by.text('éç§è®¾ç½®')).tap();70 // ï¼switchæé®å®ä½ï¼éªè¯é»è¾71 // //å
³äº72 await element(by.traits(['button']).and(by.label('Back'))).tap();73 await waitFor(element(by.text('å
³äº'))).toBeVisible().withTimeout(10000);74 await element(by.text('å
³äº')).tap();75 await waitFor(element(by.text('çæ¬è¯´æ'))).toBeVisible().withTimeout(10000);76 await element(by.text('çæ¬è¯´æ')).tap();77 await expect(element(by.text('updateText_AboutVersionScreen'))).toBeVisible();78 await element(by.traits(['button']).and(by.label('Back'))).tap();79 await waitFor(element(by.text('å»è¯å'))).toBeVisible().withTimeout(10000);80 await element(by.text('å»è¯å')).tap();81 await expect(Linking.openURL("http://shandudata.com/"));82 await waitFor(element(by.text('æå¡åè®®'))).toBeVisible().withTimeout(10000);83 await element(by.text('æå¡åè®®')).tap();84 await waitFor(element(by.id('service_TosScreen'))).toBeVisible().withTimeout(10000);85 await element(by.id('service_TosScreen')).scrollTo('bottom');86 await expect(element(by.text('解éæ¬æ¡æ¬¾'))).toBeVisible();87 await element(by.traits(['button']).and(by.label('Back'))).tap();88 await element(by.traits(['button']).and(by.label('Back'))).tap();89 // //éåºå½åè´¦å·90 await waitFor(element(by.id('exitAccount_UserSettingForm'))).toBeVisible().withTimeout(10000);91 await element(by.id('exitAccount_UserSettingForm')).tap();92 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);93 await element(by.text('ç¡®å®')).tap();94 await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();95 });96 it('æç主页', async () => {97 await waitFor(element(by.id('gotoMyPage_PersonMainTOp'))).toBeVisible().withTimeout(10000);98 await element(by.id('gotoMyPage_PersonMainTOp')).tap();99 // åå¸å¨æï¼ï¼å³ä¸è§åå¸æé®100 // 101 // 102 await waitFor(element(by.id('content_PostTrends'))).toBeVisible().withTimeout(10000);103 await element(by.id('content_PostTrends')).replaceText(Math.random().toString().slice(-6));104 await element(by.id('takePhoto_SDTakePhoto')).tap();105 // å®ä½ç¸åå
ç´ 106 // å
³æ³¨107 await waitFor(element(by.text('å
³æ³¨'))).toBeVisible().withTimeout(10000);108 await element(by.text('å
³æ³¨')).tap();109 await expect(element(by.text('æçå
³æ³¨'))).toBeVisible();110 await element(by.traits(['button']).and(by.label('Back'))).tap();111 // ç²ä¸112 await waitFor(element(by.text('ç²ä¸'))).toBeVisible().withTimeout(10000);113 await element(by.text('ç²ä¸')).tap();114 await expect(element(by.text('æçç²ä¸'))).toBeVisible();115 await element(by.traits(['button']).and(by.label('Back'))).tap();116 // å¨æ117 await waitFor(element(by.text('å¨æ'))).toBeVisible().withTimeout(10000);118 await element(by.text('å¨æ')).tap();119 await element(by.text('å®æ')).scrollTo('bottom');120 // æè·è¯ä¹¦121 });122 it('æçå
³æ³¨', async () => {123 await waitFor(element(by.id('myFallow_PersonMainTop'))).toBeVisible().withTimeout(10000);124 await element(by.id('myFallow_PersonMainTop')).tap();125 await expect(element(by.text('æçå
³æ³¨'))).toBeVisible();126 // ï¼å
³æ³¨ç¨æ·çå®ä½127 });128 it('æçç²ä¸', async () => {129 await waitFor(element(by.id('myFans_PersonMainTop'))).toBeVisible().withTimeout(10000);130 await element(by.id('myFans_PersonMainTop')).tap();131 await expect(element(by.text('æçç²ä¸'))).toBeVisible();132 // ï¼ç²ä¸ç¨æ·çå®ä½133 });134 it('æçå±¥å', async () => {135 await waitFor(element(by.id('myResume_MainPageButton'))).toBeVisible().withTimeout(10000);136 await element(by.id('myResume_MainPageButton')).tap();137 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();138 });139 it('æçæ¶è', async () => {140 await waitFor(element(by.id('myCollection_MainPageButton'))).toBeVisible().withTimeout(10000);141 await element(by.id('myCollection_MainPageButton')).tap();142 // ï¼å
容/æ°æ®æ¥å æ¶èæ°ééªè¯é»è¾143 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();144 await waitFor(element(by.text('管ç'))).toBeVisible().withTimeout(10000);145 await element(by.text('管ç')).tap();146 // ç¹éitem147 await element(by.text('å é¤')).tap();148 await waitFor(element(by.text('ç¡®å®'))).toBeVisible().withTimeout(10000);149 await element(by.text('ç¡®å®')).tap();150 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();151 });152 it('æçèéå', async () => {153 await waitFor(element(by.text('æçèéå'))).toBeVisible().withTimeout(10000);154 await element(by.text('æçèéå')).tap();155 await expect(element(by.text('èéåæé¿è¶å¿'))).toBeVisible();156 });157 it('帮å©ä¸å¿', async () => {158 await waitFor(element(by.text('帮å©ä¸å¿'))).toBeVisible().withTimeout(10000);159 await element(by.text('帮å©ä¸å¿')).tap();160 await waitFor(element(by.text('ä»ä¹æ¯èéå'))).toBeVisible().withTimeout(10000);161 await element(by.text('ä»ä¹æ¯èéå')).tap();162 await waitFor(element(by.text('å
³é'))).toBeVisible().withTimeout(10000);163 await element(by.text('å
³é')).tap();164 await expect(element(by.text('ä»ä¹æ¯èéå'))).toBeVisible();165 });166 it('å享ç»å¥½å', async () => {167 // 微信缺失168 });169 it('æè§åé¦', async () => {170 await waitFor(element(by.text('æè§åé¦'))).toBeVisible().withTimeout(10000);171 await element(by.text('æè§åé¦')).tap();172 await waitFor(element(by.id('suggestContent_FeedBackForm'))).toBeVisible().withTimeout(10000);173 await element(by.text('æ
éé误')).tap();174 await element(by.id('suggestContent_FeedBackForm')).replaceText(Math.random().toString().slice(-6));175 await element(by.id('contactInfo_FeedBackForm')).replaceText(getMobile());176 // éªè¯å¤å¶é»è¾177 await element(by.id('copyGroup_FeedBackScreen')).tap();178 await element(by.id('submit_FeedBackForm')).tap();179 await expect(element(by.text('æè§åé¦'))).toBeVisible();180 });...
09-jumptomessage.spec.js
Source:09-jumptomessage.spec.js
...4} = require('../../helpers/app');5async function navigateToRoom(roomName) {6 await searchRoom(`${ roomName }`);7 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();8 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);9}10async function clearCache() {11 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);12 await tapBack();13 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);14 await element(by.id('rooms-list-view-sidebar')).tap();15 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);16 await element(by.id('sidebar-settings')).tap();17 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);18 await element(by.id('settings-view-clear-cache')).tap();19 await waitFor(element(by.text('This will clear all your offline data.'))).toExist().withTimeout(2000);20 await element(by.label('Clear').and(by.type('_UIAlertControllerActionView'))).tap();21 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000);22 await waitFor(element(by.id('rooms-list-view-item-jumping'))).toExist().withTimeout(10000);23}24async function waitForLoading() {25 await waitFor(element(by.id('loading'))).toBeVisible().withTimeout(5000);26 await waitFor(element(by.id('loading'))).toBeNotVisible().withTimeout(10000);27}28describe('Room', () => {29 before(async() => {30 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });31 await navigateToLogin();32 await login(data.adminUser, data.adminPassword);33 });34 it('should jump to an old message and load its surroundings', async() => {35 await navigateToRoom('jumping');36 await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);37 await element(by.label('1')).atIndex(0).tap();38 await waitForLoading();39 await waitFor(element(by.label('1')).atIndex(0)).toExist().withTimeout(10000);40 await expect(element(by.label('2'))).toExist();41 });42 it('should tap FAB and scroll to bottom', async() => {43 await waitFor(element(by.id('nav-jump-to-bottom'))).toExist().withTimeout(5000);44 await element(by.id('nav-jump-to-bottom')).tap();45 await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);46 await clearCache();47 });48 it('should load messages on scroll', async() => {49 await navigateToRoom('jumping');50 await waitFor(element(by.id('room-view-messages'))).toExist().withTimeout(5000);51 await waitFor(element(by.label('300'))).toExist().withTimeout(5000);52 let found = false;53 while (!found) {54 await element(by.id('room-view-messages')).atIndex(0).scroll(500, 'up');55 try {56 await expect(element(by.label('249'))).toExist();57 found = true;58 } catch {59 //60 }61 }62 await clearCache();63 });64 it('should search for old message and load its surroundings', async() => {65 await navigateToRoom('jumping');66 await element(by.id('room-view-search')).tap();67 await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);68 await element(by.id('search-message-view-input')).typeText('30\n');69 await waitFor(element(by.label('30')).atIndex(0)).toExist().withTimeout(5000);70 await element(by.label('30')).atIndex(0).tap();71 await waitForLoading();72 await expect(element(by.label('30'))).toExist();73 await expect(element(by.label('31'))).toExist();74 await expect(element(by.label('32'))).toExist();75 });76 it('should load newer and older messages', async() => {77 await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8);78 await waitFor(element(by.label('5'))).toExist().withTimeout(10000);79 await waitFor(element(by.label('Load Older'))).toExist().withTimeout(5000);80 await element(by.label('Load Older')).atIndex(0).tap();81 await waitFor(element(by.label('4'))).toExist().withTimeout(5000);82 await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.5);83 await waitFor(element(by.label('1'))).toExist().withTimeout(5000);84 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);85 await waitFor(element(by.label('25'))).toExist().withTimeout(5000);86 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);87 await waitFor(element(by.label('50'))).toExist().withTimeout(5000);88 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'slow', 0.5);89 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);90 await element(by.label('Load Newer')).atIndex(0).tap();91 await waitFor(element(by.label('104'))).toExist().withTimeout(5000);92 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);93 await element(by.label('Load Newer')).atIndex(0).tap();94 await waitFor(element(by.label('154'))).toExist().withTimeout(5000);95 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);96 await element(by.label('Load Newer')).atIndex(0).tap();97 await waitFor(element(by.label('Load Newer'))).toNotExist().withTimeout(5000);98 await expect(element(by.label('Load More'))).toNotExist();99 await expect(element(by.label('201'))).toExist();100 await expect(element(by.label('202'))).toExist();101 await tapBack();102 });103});104const expectThreadMessages = async(message) => {105 await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);106 await expect(element(by.label(message))).toExist();107};108describe('Threads', () => {109 it('should navigate to a thread from another room', async() => {110 await navigateToRoom('jumping');111 await waitFor(element(by.label('Go to jumping-thread\'s thread')).atIndex(0)).toExist().withTimeout(5000);112 await element(by.label('Go to jumping-thread\'s thread')).atIndex(0).tap();113 await waitForLoading();114 await expectThreadMessages('Go to jumping-thread\'s thread');115 await tapBack();116 });117 it('should tap on thread message from main room', async() => {118 await waitFor(element(by.label('thread message sent to main room')).atIndex(0)).toExist().withTimeout(5000);119 await element(by.label('thread message sent to main room')).atIndex(0).tap();120 await expectThreadMessages('thread message sent to main room');121 await tapBack();122 });123 it('should tap on quote', async() => {124 await waitFor(element(by.label('quoted'))).toExist().withTimeout(5000);125 await element(by.label('quoted')).atIndex(0).tap();126 await expectThreadMessages('quoted');127 await tapBack();128 });129 it('should jump from search message', async() => {130 await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);131 await element(by.id('room-view-search')).atIndex(0).tap();132 await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);133 await element(by.id('search-message-view-input')).typeText('to be searched\n');134 await waitFor(element(by.label('to be searched'))).toExist().withTimeout(5000);135 await element(by.label('to be searched')).atIndex(1).tap();136 await expectThreadMessages('to be searched');137 });138 // TODO: Threads pagination...
3_rank.js
Source:3_rank.js
1describe('æå', () => {2 beforeEach(async () => {3 await device.reloadReactNative();4 await waitFor(element(by.id('rankTab_RankScreen'))).toBeVisible().withTimeout(10000);5 await element(by.id('rankTab_RankScreen')).tap();6 });7 //// å
³æ³¨æ¦8 it('ç»å³°æ¦âå
³æ³¨æ¦', async () => {9 // åæ¢åå¸10 await waitFor(element(by.id('getCity_RankTabOne'))).toBeVisible().withTimeout(10000);11 await element(by.id('getCity_RankTabOne')).tap();12 await waitFor(element(by.text('å京å¸'))).toBeVisible().withTimeout(10000);13 await element(by.text('å京å¸')).tap();14 await expect(element(by.id('content_ScoreText'))).toHaveText('å京');15 // åç±»é¢æ ¡æå16 await waitFor(element(by.text('å
³æ³¨æ¦'))).toBeVisible().withTimeout(10000);17 await element(by.text('å
³æ³¨æ¦')).tap();18 await waitFor(element(by.text('åç±»é¢æ ¡æå'))).toBeVisible().withTimeout(10000);19 await element(by.text('åç±»é¢æ ¡æå')).tap();20 await expect(element(by.id('content_ScoreText'))).toHaveText('211');21 // æ¬æ ¡æå22 await waitFor(element(by.text('åç±»é¢æ ¡æå'))).toBeVisible().withTimeout(10000);23 await element(by.text('åç±»é¢æ ¡æå')).tap();24 await waitFor(element(by.text('æ¬æ ¡æå'))).toBeVisible().withTimeout(10000);25 await element(by.text('æ¬æ ¡æå')).tap();26 await expect(element(by.id('content_ScoreText'))).toHaveText('å京èªç©º');27 // åç±»ä¸ä¸æå28 await waitFor(element(by.text('æ¬æ ¡æå'))).toBeVisible().withTimeout(10000);29 await element(by.text('æ¬æ ¡æå')).tap();30 await waitFor(element(by.text('åç±»ä¸ä¸æå'))).toBeVisible().withTimeout(10000);31 await element(by.text('åç±»ä¸ä¸æå')).tap();32 await expect(element(by.id('content_ScoreText'))).toHaveText('计ç®æºç±»');33 // æ¬ä¸ä¸æå34 await waitFor(element(by.text('åç±»ä¸ä¸æå'))).toBeVisible().withTimeout(10000);35 await element(by.text('åç±»ä¸ä¸æå')).tap();36 await waitFor(element(by.text('æ¬ä¸ä¸æå'))).toBeVisible().withTimeout(10000);37 await element(by.text('æ¬ä¸ä¸æå')).tap();38 await expect(element(by.id('content_ScoreText'))).toHaveText('计ç®æºç§å¦');39 });40 it('ç»å³°æ¦âTOPæ¦', async () => {41 await waitFor(element(by.text('å
³æ³¨æ¦'))).toBeVisible().withTimeout(10000);42 await element(by.text('å
³æ³¨æ¦')).scrollTo('bottom');43 await waitFor(element(by.text('åªå'))).toBeVisible().withTimeout(10000);44 await element(by.text('åªå')).scrollTo('bottom');45 // ï¼ ä¸ªäººä¸»é¡µ46 // ï¼userlistItemå®ä½47 });48 it('ç»å³°æ¦âæçä½æ¬¡', async () => {49 await waitFor(element(by.text('å
³æ³¨æ¦'))).toBeVisible().withTimeout(10000);50 await element(by.text('å
³æ³¨æ¦')).scrollTo('bottom');51 await waitFor(element(by.text('ç»é¡¶'))).toBeVisible().withTimeout(10000);52 await element(by.text('ç»é¡¶')).scrollTo('bottom');53 // ï¼ ä¸ªäººä¸»é¡µ54 // ï¼userlistItemå®ä½55 });56 it('å
³æ³¨æ¦âåç°å¨æ', async () => {57 await waitFor(element(by.text('å
³æ³¨æ¦'))).toBeVisible().withTimeout(10000);58 await element(by.text('å
³æ³¨æ¦')).tap();59 await waitFor(element(by.id('findEvent_RankTabTwo'))).toBeVisible().withTimeout(10000);60 await element(by.id('findEvent_RankTabTwo')).tap();61 await expect(element(by.text('å
³æ³¨å¨æ'))).toBeVisible();62 });63 it('å
³æ³¨æ¦âæå', async () => {64 await waitFor(element(by.text('å
³æ³¨æ¦'))).toBeVisible().withTimeout(10000);65 await element(by.text('å
³æ³¨æ¦')).tap();66 await waitFor(element(by.id('findEvent_RankTabTwo'))).toBeVisible().withTimeout(10000);67 await element(by.id('findEvent_RankTabTwo')).scrollTo('bottom');68 // ?æå·²é¢å
69 });70 it('è¿æ¥æ¦âæå', async () => {71 await waitFor(element(by.text('è¿æ¥æ¦'))).toBeVisible().withTimeout(10000);72 await element(by.text('è¿æ¥æ¦')).tap();73 await waitFor(element(by.text('æ'))).toBeVisible().withTimeout(10000);74 await element(by.text('æ')).scrollTo('bottom');75 // ï¼éªè¯é»è¾76 });...
Using AI Code Generation
1const { By, until } = require('selenium-webdriver');2(async function example() {3 let driver = await new Builder().forBrowser('firefox').build();4 await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);5 await driver.wait(until.titleIs('webdriver - Google Search'), 1000);6 await driver.quit();7})();8const { By, until } = require('selenium-webdriver');9(async function example() {10 let driver = await new Builder().forBrowser('firefox').build();11 await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);12 await driver.wait(until.elementLocated(By.id('resultStats')), 1000);13 await driver.quit();14})();15const { By, until } = require('selenium-webdriver');16(async function example() {17 let driver = await new Builder().forBrowser('firefox').build();18 await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);19 await driver.wait(until.elementLocated(By.id('resultStats')), 1000);20 await driver.quit();21})();22const { By, until } = require('selenium-webdriver');23(async function example() {24 let driver = await new Builder().forBrowser('firefox').build();25 await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);26 await driver.wait(until.elementLocated(By.id('resultStats')), 1000);27 await driver.quit();28})();29const { By, until } = require('selenium-webdriver');30(async function example() {31 let driver = await new Builder().forBrowser('firefox').build();32 await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);33 await driver.wait(until.elementLocated(By.id('resultStats')), 1000);34 await driver.quit();35})();36const {
Using AI Code Generation
1import React from 'react';2import { withTimeout } from 'react-with-timeout';3class Test extends React.Component {4 constructor(props) {5 super(props);6 this.state = {7 };8 }9 componentDidMount() {10 this.props.setTimeout(() => {11 this.setState({ test: 'test2' });12 }, 5000);13 }14 render() {15 return <div>{this.state.test}</div>;16 }17}18export default withTimeout(Test);19import React from 'react';20import { withTimeout } from 'react-with-timeout';21class Test2 extends React.Component {22 constructor(props) {23 super(props);24 this.state = {25 };26 }27 componentDidMount() {28 this.props.setTimeout(() => {29 this.setState({ test: 'test2' });30 }, 5000);31 }32 render() {33 return <div>{this.state.test}</div>;34 }35}36export default withTimeout(Test2);
Using AI Code Generation
1var rootElement = element(by.css('body'));2browser.driver.wait(protractor.until.elementLocated(by.css('body')), 5000);3browser.driver.wait(protractor.until.elementIsVisible(rootElement), 5000);4rootElement.withTimeout(5000).findElement(by.css('div')).click();5var elementFinder = element(by.css('div'));6browser.driver.wait(protractor.until.elementLocated(by.css('div')), 5000);7browser.driver.wait(protractor.until.elementIsVisible(elementFinder), 5000);8elementFinder.withTimeout(5000).click();9var elementArrayFinder = element.all(by.css('div'));10browser.driver.wait(protractor.until.elementLocated(by.css('div')), 5000);11browser.driver.wait(protractor.until.elementIsVisible(elementArrayFinder.first()), 5000);12elementArrayFinder.withTimeout(5000).get(0).click();13var locator = by.css('div');14browser.driver.wait(protractor.until.elementLocated(locator), 5000);15browser.driver.wait(protractor.until.elementIsVisible(element(locator)), 5000);16element(locator).withTimeout(5000).click();17var expectedCondition = protractor.ExpectedConditions;18browser.driver.wait(expectedCondition.presenceOf(element(by.css('div'))), 5000);19browser.driver.wait(expectedCondition.visibilityOf(element(by.css('div'))), 5000);20element(by.css('div')).withTimeout(5000).click();21var protractorExpectedCondition = protractor.ExpectedConditions;22browser.driver.wait(protractorExpectedCondition.presenceOf(element(by.css('div'))), 5000);23browser.driver.wait(protractorExpectedCondition.visibilityOf(element(by.css('div'))), 5000);24element(by.css('div')).withTimeout(5000).click();25var protractorExpectedCondition = protractor.ExpectedConditions;26browser.driver.wait(protractorExpectedCondition.presenceOf(element(by.css('div'))), 5000);27browser.driver.wait(protractorExpectedCondition.visibilityOf(element(by.css('div'))), 5000);28element(by.css('div')).withTimeout(5000).click();
Using AI Code Generation
1const { By, until } = require('selenium-webdriver');2const { driver } = require('./driver');3async function test() {4 await driver.wait(5 until.elementLocated(By.name('q')),6 );7 await driver.findElement(By.name('q')).sendKeys('Selenium');8 await driver.findElement(By.name('btnK')).click();9 await driver.wait(until.titleIs('Selenium - Google Search'), 1000);10 await driver.quit();11}12test();
Using AI Code Generation
1const { withTimeout } = require('root-require')('index.js');2const slowFunction = async () => {3 await new Promise((resolve) => {4 setTimeout(() => {5 resolve();6 }, 1000);7 });8};9const test = async () => {10 try {11 await withTimeout(slowFunction, 500);12 } catch (err) {13 console.log('err', err);14 }15};16test();17MIT © [Nikhil Sharma](
Using AI Code Generation
1const { withTimeout } = require('with-timeout');2const { setTimeout } = require('timers/promises');3const longRunningTask = async () => {4 await setTimeout(5000);5 return 'Task done';6};7const task = async () => {8 const result = await withTimeout(longRunningTask(), 2000);9 console.log(result);10};11task().catch(console.error);12const { withTimeout } = require('with-timeout');13const { setTimeout } = require('timers/promises');14const longRunningTask = async () => {15 await setTimeout(5000);16 return 'Task done';17};18const task = async () => {19 try {20 const result = await withTimeout.reject(longRunningTask(), 2000);21 console.log(result);22 } catch (error) {23 console.log(error.message);24 }25};26task().catch(console.error);27const { withTimeout } = require('with-timeout');28const { setTimeout } = require('timers/promises');29const longRunningTask = async () => {30 await setTimeout(5000);31 return 'Task done';32};33const task = async () => {34 const result = await withTimeout.resolve(longRunningTask(), 2000);35 console.log(result);36};37task().catch(console.error);38const { withTimeout } = require('with-timeout');39const { setTimeout } = require('timers/promises');40const longRunningTask = async () => {41 await setTimeout(5000);42 return 'Task done';43};44const task = async () => {45 try {46 const result = await withTimeout.resolveOrReject(longRunningTask(), 2000);47 console.log(result);48 } catch
Using AI Code Generation
1var root = require('root');2var timeout = root.withTimeout(1000);3timeout(function() {4 console.log('timeout');5});6var timeout = require('root').withTimeout(1000);7timeout(function() {8 console.log('timeout');9});10var root = require('root');11var timeout = root.withTimeout(1000);12timeout(function() {13 console.log('timeout');14});15var timeout = require('root').withTimeout(1000);16timeout(function() {17 console.log('timeout');18});19var root = require('root');20var timeout = root.withTimeout(1000);21timeout(function() {22 console.log('timeout');23});24var timeout = require('root').withTimeout(1000);25timeout(function() {26 console.log('timeout');27});28var root = require('root');29var timeout = root.withTimeout(1000);30timeout(function() {31 console.log('timeout');32});33var timeout = require('root').withTimeout(1000);34timeout(function() {35 console.log('timeout');36});37var root = require('root');38var timeout = root.withTimeout(1000);39timeout(function() {40 console.log('timeout');41});42var timeout = require('root').withTimeout(1000);43timeout(function() {44 console.log('timeout');45});46var root = require('root');47var timeout = root.withTimeout(1000);48timeout(function() {49 console.log('timeout');50});51var timeout = require('root').withTimeout(1000);52timeout(function() {53 console.log('timeout');54});55var root = require('root');56var timeout = root.withTimeout(1000);57timeout(function() {58 console.log('timeout');59});60var timeout = require('root').withTimeout(1000);61timeout(function() {62 console.log('timeout');63});
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!!