How to use waitForCondition method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

list_test.js

Source:list_test.js Github

copy

Full Screen

...76};77var test_list_store = function () {78 var done;79 var result;80 waitForCondition(81 // Condition82 function () {83 return done;84 },85 // Continuation86 function () {87 assertEquals('length', objs.length, result.length);88 assertArrayEquals(objs, result);89 reachedFinalContinuation = true;90 },91 100, // interval92 1000); // maxTimeout93 var q = new ydn.db.Iterator(store_name);94 load_default(function (db) {95 db.values(q).addBoth(function (value) {96 //console.log(db + ' fetch value: ' + JSON.stringify(value));97 result = value;98 done = true;99 ydn.db.deleteDatabase(db.getName(), db.getType());100 db.close();101 });102 });103};104var test_getByIterator = function () {105 var db = load_default();106 var done;107 var result;108 waitForCondition(109 // Condition110 function () {111 return done;112 },113 // Continuation114 function () {115 assertObjectEquals(objs[1], result);116 reachedFinalContinuation = true;117 ydn.db.deleteDatabase(db.getName(), db.getType());118 db.close();119 },120 100, // interval121 1000); // maxTimeout122 var range = new ydn.db.KeyRange.only('a2');123 var q = new ydn.db.IndexValueIterator(store_name, 'value', range);124 db.get(q).addBoth(function (value) {125 //console.log(db + ' fetch value: ' + JSON.stringify(value));126 result = value;127 done = true;128 });129};130var test_listByIterator = function () {131 var db = load_default();132 var done;133 var result;134 waitForCondition(135 // Condition136 function () {137 return done;138 },139 // Continuation140 function () {141 assertObjectEquals('result', objs, result);142 ydn.db.deleteDatabase(db.getName(), db.getType());143 db.close();144 reachedFinalContinuation = true;145 },146 100, // interval147 1000); // maxTimeout148 var q = new ydn.db.ValueIterator(store_name);149 db.values(q).addBoth(function (value) {150 //console.log(db + ' fetch value: ' + JSON.stringify(value));151 result = value;152 done = true;153 });154};155var test_listByIterator_key_range = function () {156 var db = load_default();157 var done;158 var result;159 waitForCondition(160 // Condition161 function () {162 return done;163 },164 // Continuation165 function () {166 assertObjectEquals('result', objs.slice(2, 5), result);167 ydn.db.deleteDatabase(db.getName(), db.getType());168 db.close();169 reachedFinalContinuation = true;170 },171 100, // interval172 1000); // maxTimeout173 var kr = ydn.db.KeyRange.bound(1, 10);174 var q = new ydn.db.ValueIterator(store_name, kr);175 db.values(q).addBoth(function (value) {176 //console.log(db + ' fetch value: ' + JSON.stringify(value));177 result = value;178 done = true;179 });180};181var test_listByIterator_resume = function () {182 var db = load_default();183 var done;184 var result;185 waitForCondition(186 // Condition187 function () {188 return done;189 },190 // Continuation191 function () {192 assertObjectEquals('first result', objs.slice(0, 3), result);193 done = false;194 waitForCondition(195 // Condition196 function () {197 return done;198 },199 // Continuation200 function () {201 assertObjectEquals('second result', objs.slice(3, 6), result);202 reachedFinalContinuation = true;203 ydn.db.deleteDatabase(db.getName(), db.getType());204 db.close();205 },206 100, // interval207 1000); // maxTimeout208 db.values(q, 3).addBoth(function (value) {209 //console.log(db + ' fetch value: ' + JSON.stringify(value));210 result = value;211 done = true;212 });213 },214 100, // interval215 1000); // maxTimeout216 var q = new ydn.db.ValueIterator(store_name);217 db.values(q, 3).addBoth(function (value) {218 //console.log(db + ' fetch value: ' + JSON.stringify(value));219 result = value;220 done = true;221 });222};223var test_listBy_index_ValueIterator = function () {224 var db = load_default();225 var done;226 var result;227 var exp_result = objs.sort(function(a, b) {228 return a.value > b.value ? 1 : -1;229 });230 waitForCondition(231 // Condition232 function () {233 return done;234 },235 // Continuation236 function () {237 console.log(result);238 assertObjectEquals('result', exp_result, result);239 ydn.db.deleteDatabase(db.getName(), db.getType());240 db.close();241 reachedFinalContinuation = true;242 },243 100, // interval244 1000); // maxTimeout245 var q = new ydn.db.IndexValueIterator(store_name, 'value');246 db.values(q).addBoth(function (value) {247 //console.log(db + ' fetch value: ' + JSON.stringify(value));248 result = value;249 done = true;250 });251};252var test_listBy_index_ValueIterator_resume = function () {253 var db = load_default();254 var done;255 var result, result2;256 var exp_result = objs.sort(function(a, b) {257 return a.value > b.value ? 1 : -1;258 });259 waitForCondition(260 // Condition261 function () {262 return done;263 },264 // Continuation265 function () {266 // console.log(result)267 assertObjectEquals('first result', exp_result.slice(0, 3), result);268 done = false;269 waitForCondition(270 // Condition271 function () {272 return done;273 },274 // Continuation275 function () {276 // console.log(result2)277 assertObjectEquals('second result', exp_result.slice(3, 6), result2);278 reachedFinalContinuation = true;279 ydn.db.deleteDatabase(db.getName(), db.getType());280 db.close();281 },282 100, // interval283 1000); // maxTimeout284 db.values(q, 3).addBoth(function (value) {285 //console.log(db + ' fetch value: ' + JSON.stringify(value));286 result2 = value;287 done = true;288 });289 },290 100, // interval291 1000); // maxTimeout292 var q = new ydn.db.IndexValueIterator(store_name, 'value');293 db.values(q, 3).addBoth(function (value) {294 //console.log(db + ' fetch value: ' + JSON.stringify(value));295 result = value;296 done = true;297 });298};299var test_listByKeyIterator = function () {300 var db = load_default();301 var done;302 var result;303 var keys = objs.map(function(x) {304 return x.id;305 });306 // keys.sort();307 waitForCondition(308 // Condition309 function () {310 return done;311 },312 // Continuation313 function () {314 assertArrayEquals('result', keys, result);315 ydn.db.deleteDatabase(db.getName(), db.getType());316 db.close();317 reachedFinalContinuation = true;318 },319 100, // interval320 1000); // maxTimeout321 var q = new ydn.db.KeyIterator(store_name);322 db.values(q).addBoth(function (value) {323 //console.log(db + ' fetch value: ' + JSON.stringify(value));324 result = value;325 done = true;326 });327};328var test_listByKeyIterator_resume = function () {329 var db = load_default();330 var done;331 var result;332 var keys = objs.map(function(x) {333 return x.id;334 });335 // keys.sort();336 waitForCondition(337 // Condition338 function () {339 return done;340 },341 // Continuation342 function () {343 assertObjectEquals('first result', keys.slice(0, 3), result);344 done = false;345 waitForCondition(346 // Condition347 function () {348 return done;349 },350 // Continuation351 function () {352 assertObjectEquals('second result', keys.slice(3, 6), result);353 reachedFinalContinuation = true;354 ydn.db.deleteDatabase(db.getName(), db.getType());355 db.close();356 },357 100, // interval358 1000); // maxTimeout359 db.values(q, 3).addBoth(function (value) {360 //console.log(db + ' fetch value: ' + JSON.stringify(value));361 result = value;362 done = true;363 });364 },365 100, // interval366 1000); // maxTimeout367 var q = new ydn.db.KeyIterator(store_name);368 db.values(q, 3).addBoth(function (value) {369 //console.log(db + ' fetch value: ' + JSON.stringify(value));370 result = value;371 done = true;372 });373};374var test_listByIterator_limit = function () {375 var db = load_default();376 var done;377 var result;378 waitForCondition(379 // Condition380 function () {381 return done;382 },383 // Continuation384 function () {385 assertObjectEquals('result', objs.slice(0, 3), result);386 ydn.db.deleteDatabase(db.getName(), db.getType());387 db.close();388 reachedFinalContinuation = true;389 },390 100, // interval391 1000); // maxTimeout392 var q = new ydn.db.ValueIterator(store_name);393 db.values(q, 3).addBoth(function (value) {394 //console.log(db + ' fetch value: ' + JSON.stringify(value));395 result = value;396 done = true;397 });398};399var test_keysBy_ValueIterator = function () {400 var db = load_default();401 var done;402 var result;403 var keys = objs.map(function(x) {404 return x.id;405 });406 waitForCondition(407 // Condition408 function () {409 return done;410 },411 // Continuation412 function () {413 assertObjectEquals('result', keys, result);414 ydn.db.deleteDatabase(db.getName(), db.getType());415 db.close();416 reachedFinalContinuation = true;417 },418 100, // interval419 1000); // maxTimeout420 var q = new ydn.db.ValueIterator(store_name);421 db.keys(q).addBoth(function (value) {422 //console.log(db + ' fetch value: ' + JSON.stringify(value));423 result = value;424 done = true;425 });426};427var test_keysBy_ValueIterator_resume = function () {428 var db = load_default();429 var done;430 var result;431 var keys = objs.map(function(x) {432 return x.id;433 });434 waitForCondition(435 // Condition436 function () {437 return done;438 },439 // Continuation440 function () {441 assertObjectEquals('first result', keys.slice(0, 3), result);442 done = false;443 waitForCondition(444 // Condition445 function () {446 return done;447 },448 // Continuation449 function () {450 assertObjectEquals('second result', keys.slice(3, 6), result);451 reachedFinalContinuation = true;452 ydn.db.deleteDatabase(db.getName(), db.getType());453 db.close();454 },455 100, // interval456 1000); // maxTimeout457 db.keys(q, 3).addBoth(function (value) {458 // console.log(value);459 result = value;460 done = true;461 });462 },463 100, // interval464 1000); // maxTimeout465 var q = new ydn.db.ValueIterator(store_name);466 // db.keys(q).addBoth(function (value) {console.log(value);});467 db.keys(q, 3).addBoth(function (value) {468 // console.log(value);469 result = value;470 done = true;471 });472};473var test_keysBy_index_ValueIterator = function() {474 var db = load_default();475 var done;476 var result;477 var keys = objs.map(function(x) {478 return x.value;479 });480 keys.sort();481 waitForCondition(482 // Condition483 function() {484 return done;485 },486 // Continuation487 function() {488 assertObjectEquals('result', keys, result);489 ydn.db.deleteDatabase(db.getName(), db.getType());490 db.close();491 reachedFinalContinuation = true;492 },493 100, // interval494 1000); // maxTimeout495 var q = new ydn.db.IndexValueIterator(store_name, 'value');496 db.keys(q).addBoth(function(value) {497 //console.log(db + ' fetch value: ' + JSON.stringify(value));498 result = value;499 done = true;500 });501};502var test_keys_by_ValueIndexIterator = function () {503 var db = load_default();504 var done;505 var result;506 var keys = objs.map(function(x) {507 return x.type;508 });509 waitForCondition(510 // Condition511 function () {512 return done;513 },514 // Continuation515 function () {516 assertObjectEquals('result', keys, result);517 ydn.db.deleteDatabase(db.getName(), db.getType());518 db.close();519 reachedFinalContinuation = true;520 },521 100, // interval522 1000); // maxTimeout523 var q = new ydn.db.IndexValueIterator(store_name, 'type');524 db.keys(q).addBoth(function (value) {525 //console.log(db + ' fetch value: ' + JSON.stringify(value));526 result = value;527 done = true;528 });529};530var test_keys_by_KeyIndexIterator = function () {531 var db = load_default();532 var done;533 var result;534 var keys = objs.map(function(x) {535 return x.type;536 });537 waitForCondition(538 // Condition539 function () {540 return done;541 },542 // Continuation543 function () {544 assertObjectEquals('result', keys, result);545 ydn.db.deleteDatabase(db.getName(), db.getType());546 db.close();547 reachedFinalContinuation = true;548 },549 100, // interval550 1000); // maxTimeout551 var q = new ydn.db.IndexIterator(store_name, 'type');552 db.keys(q).addBoth(function (value) {553 //console.log(db + ' fetch value: ' + JSON.stringify(value));554 result = value;555 done = true;556 });557};558var test_keys_by_KeyIndexIterator_unqiue = function () {559 var db = load_default();560 var done;561 var result;562 var keys = [];563 for (var i = 0; i < objs.length; i++) {564 var value = objs[i].value;565 if (keys.indexOf(value) == -1) {566 keys.push(value);567 }568 }569 keys.sort();570 waitForCondition(571 // Condition572 function () {573 return done;574 },575 // Continuation576 function () {577 assertObjectEquals('result', keys, result);578 ydn.db.deleteDatabase(db.getName(), db.getType());579 db.close();580 reachedFinalContinuation = true;581 },582 100, // interval583 1000); // maxTimeout584 var q = new ydn.db.IndexIterator(store_name, 'value', null, false, true);...

Full Screen

Full Screen

sql_test.js

Source:sql_test.js Github

copy

Full Screen

...33};34var test_select_all = function() {35 var hasEventFired = false;36 var result;37 waitForCondition(38 // Condition39 function() { return hasEventFired; },40 // Continuation41 function() {42 assertArrayEquals('all records', objs, result);43 reachedFinalContinuation = true;44 },45 100, // interval46 1000); // maxTimeout47 db.executeSql('SELECT * FROM "st"').addCallback(function (q_result) {48 //console.log(db.explain(q));49 //console.log('receiving query ' + JSON.stringify(q_result));50 result = q_result;51 hasEventFired = true;52 })53};54var test_select_field = function() {55 var hasEventFired = false;56 var result;57 var actual_result = objs.map(function(x) {return x.value});58 actual_result.sort();59 waitForCondition(60 // Condition61 function() { return hasEventFired; },62 // Continuation63 function() {64 result.sort();65 assertArrayEquals('all records', actual_result, result);66 reachedFinalContinuation = true;67 },68 100, // interval69 2000); // maxTimeout70 db.executeSql('SELECT value FROM "st"').addCallback(function (q_result) {71 //console.log(db.explain(q));72 //console.log('receiving query ' + JSON.stringify(q_result));73 result = q_result;74 hasEventFired = true;75 })76};77var test_select_primary_field = function() {78 var hasEventFired = false;79 var result;80 var actual_result = objs.map(function(x) {return x.id});81 waitForCondition(82 // Condition83 function() { return hasEventFired; },84 // Continuation85 function() {86 result.sort();87 assertArrayEquals('all records', actual_result, result);88 reachedFinalContinuation = true;89 },90 100, // interval91 2000); // maxTimeout92 db.executeSql('SELECT "id" FROM "st"').addCallback(function (q_result) {93 //console.log(db.explain(q));94 //console.log('receiving query ' + JSON.stringify(q_result));95 result = q_result;96 hasEventFired = true;97 })98};99var test_select_fields = function() {100 var hasEventFired = false;101 var result;102 var actual_result = objs.map(function(x) {103 return {id: x.id, value: x.value};104 });105 waitForCondition(106 // Condition107 function() { return hasEventFired; },108 // Continuation109 function() {110 result.sort();111 assertArrayEquals('all records', actual_result, result);112 reachedFinalContinuation = true;113 },114 100, // interval115 2000); // maxTimeout116 db.executeSql('SELECT id, "value" FROM "st"').addCallback(function (q_result) {117 //console.log(db.explain(q));118 //console.log('receiving query ' + JSON.stringify(q_result));119 result = q_result;120 hasEventFired = true;121 })122};123var test_select_field_ordered = function() {124 var hasEventFired = false;125 var result;126 var actual_result = objs.map(function(x) {return x.value});127 actual_result.sort();128 waitForCondition(129 // Condition130 function() { return hasEventFired; },131 // Continuation132 function() {133 assertArrayEquals('all records', actual_result, result);134 reachedFinalContinuation = true;135 },136 100, // interval137 2000); // maxTimeout138 db.executeSql('SELECT value FROM "st" ORDER BY value').addCallback(function (q_result) {139 //console.log(db.explain(q));140 //console.log('receiving query ' + JSON.stringify(q_result));141 result = q_result;142 hasEventFired = true;143 })144};145var test_order_by = function() {146 var hasEventFired = false;147 var result;148 var actual_result = objs;149 actual_result.sort(function(a, b) {150 return a.value > b.value ? 1 : -1;151 });152 waitForCondition(153 // Condition154 function() { return hasEventFired; },155 // Continuation156 function() {157 assertArrayEquals('all records', actual_result, result);158 reachedFinalContinuation = true;159 },160 100, // interval161 1000); // maxTimeout162 db.executeSql('SELECT * FROM "st" ORDER BY value').addCallback(function (q_result) {163 //console.log(db.explain(q));164 //console.log('receiving query ' + JSON.stringify(q_result));165 result = q_result;166 hasEventFired = true;167 })168};169var test_select_field_order_by_other = function() {170 var hasEventFired = false;171 var result;172 var actual_result = objs.map(function(x) {return x.value});173 actual_result.sort(function(a, b) {174 return a.x > b.x ? 1 : -1;175 });176 waitForCondition(177 // Condition178 function() { return hasEventFired; },179 // Continuation180 function() {181 assertArrayEquals('all records', actual_result, result);182 reachedFinalContinuation = true;183 },184 100, // interval185 2000); // maxTimeout186 db.executeSql('SELECT value FROM "st" ORDER BY x').addCallback(function (q_result) {187 //console.log(db.explain(q));188 //console.log('receiving query ' + JSON.stringify(q_result));189 result = q_result;190 hasEventFired = true;191 })192};193var test_limit = function() {194 var hasEventFired = false;195 var result;196 var actual_result = objs.slice(0, 2);197 waitForCondition(198 // Condition199 function() { return hasEventFired; },200 // Continuation201 function() {202 assertArrayEquals('all records', actual_result, result);203 reachedFinalContinuation = true;204 },205 100, // interval206 2000); // maxTimeout207 db.executeSql('SELECT * FROM "st" LIMIT 2').addCallback(function (q_result) {208 //console.log(db.explain(q));209 //console.log('receiving query ' + JSON.stringify(q_result));210 result = q_result;211 hasEventFired = true;212 })213};214var test_limit_offset = function() {215 var hasEventFired = false;216 var result;217 var actual_result = objs.slice(1, 3);218 waitForCondition(219 // Condition220 function() { return hasEventFired; },221 // Continuation222 function() {223 assertArrayEquals('all records', actual_result, result);224 reachedFinalContinuation = true;225 },226 100, // interval227 2000); // maxTimeout228 db.executeSql('SELECT * FROM "st" ORDER BY id LIMIT 2 OFFSET 1').addCallback(function (q_result) {229 //console.log(db.explain(q));230 //console.log('receiving query ' + JSON.stringify(q_result));231 result = q_result;232 hasEventFired = true;233 })234};235var test_where = function() {236 var hasEventFired = false;237 var result;238 var exp_result = objs.slice(1, 3);239 waitForCondition(240 // Condition241 function() { return hasEventFired; },242 // Continuation243 function() {244 console.log([exp_result, result]);245 assertArrayEquals('all records', exp_result, result);246 reachedFinalContinuation = true;247 },248 100, // interval249 2000); // maxTimeout250 db.executeSql('SELECT * FROM "st" WHERE x >= 0 AND x < 3').addCallback(function (q_result) {251 //console.log(db.explain(q));252 //console.log('receiving query ' + JSON.stringify(q_result));253 result = q_result;254 hasEventFired = true;255 })256};257var test_count = function() {258 var hasEventFired = false;259 var result;260 waitForCondition(261 // Condition262 function() { return hasEventFired; },263 // Continuation264 function() {265 assertEquals('all records', 4, result);266 reachedFinalContinuation = true;267 },268 100, // interval269 1000); // maxTimeout270 db.executeSql('SELECT COUNT(*) FROM "st"').addCallback(function (q_result) {271 //console.log(db.explain(q));272 //console.log('receiving query ' + JSON.stringify(q_result));273 result = q_result;274 hasEventFired = true;275 })276};277var test_count_where = function() {278 var hasEventFired = false;279 var result;280 waitForCondition(281 // Condition282 function() { return hasEventFired; },283 // Continuation284 function() {285 assertEquals('all records', 2, result);286 reachedFinalContinuation = true;287 },288 100, // interval289 1000); // maxTimeout290 db.executeSql('SELECT COUNT(*) FROM "st" where x > 0 AND x <= 3').addCallback(function (q_result) {291 //console.log(db.explain(q));292 //console.log('receiving query ' + JSON.stringify(q_result));293 result = q_result;294 hasEventFired = true;295 })296};297var test_sum = function() {298 var hasEventFired = false;299 var result;300 waitForCondition(301 // Condition302 function() { return hasEventFired; },303 // Continuation304 function() {305 assertEquals('sum', 6, result);306 reachedFinalContinuation = true;307 },308 100, // interval309 1000); // maxTimeout310 db.executeSql('SELECT SUM(id) FROM "st"').addCallback(function (q_result) {311 //console.log(db.explain(q));312 //console.log('receiving query ' + JSON.stringify(q_result));313 result = q_result;314 hasEventFired = true;315 })316};317var test_sum_where = function() {318 var hasEventFired = false;319 var result;320 waitForCondition(321 // Condition322 function() { return hasEventFired; },323 // Continuation324 function() {325 assertEquals('sum', 5, result);326 reachedFinalContinuation = true;327 },328 100, // interval329 1000); // maxTimeout330 db.executeSql('SELECT SUM(x) FROM "st" where x > 0 AND x <= 3').addCallback(function (q_result) {331 //console.log(db.explain(q));332 //console.log('receiving query ' + JSON.stringify(q_result));333 result = q_result;334 hasEventFired = true;335 });336};337var test_max = function() {338 var hasEventFired = false;339 var result;340 waitForCondition(341 // Condition342 function() { return hasEventFired; },343 // Continuation344 function() {345 assertEquals('sum', 3, result);346 reachedFinalContinuation = true;347 },348 100, // interval349 1000); // maxTimeout350 db.executeSql('SELECT MAX(x) FROM "st"').addCallback(function (q_result) {351 //console.log(db.explain(q));352 //console.log('receiving query ' + JSON.stringify(q_result));353 result = q_result;354 hasEventFired = true;355 })356};357var test_min = function() {358 var hasEventFired = false;359 var result;360 waitForCondition(361 // Condition362 function() { return hasEventFired; },363 // Continuation364 function() {365 assertEquals('sum', -1, result);366 reachedFinalContinuation = true;367 },368 100, // interval369 1000); // maxTimeout370 db.executeSql('SELECT MIN(x) FROM "st"').addCallback(function (q_result) {371 //console.log(db.explain(q));372 //console.log('receiving query ' + JSON.stringify(q_result));373 result = q_result;374 hasEventFired = true;375 })376};377var test_avg = function() {378 var hasEventFired = false;379 var result;380 waitForCondition(381 // Condition382 function() { return hasEventFired; },383 // Continuation384 function() {385 assertEquals('avg', 1, result);386 reachedFinalContinuation = true;387 },388 100, // interval389 1000); // maxTimeout390 db.executeSql('SELECT AVG(x) FROM "st"').addCallback(function (q_result) {391 //console.log(db.explain(q));392 //console.log('receiving query ' + JSON.stringify(q_result));393 result = q_result;394 hasEventFired = true;...

Full Screen

Full Screen

emoji_picker_test.js

Source:emoji_picker_test.js Github

copy

Full Screen

...68 'emoji-group-button[data-group="history"]', 'cr-icon-button');69 const thirdButton = findInEmojiPicker(70 'emoji-group-button[data-group="1"]', 'cr-icon-button');71 // wait so emoji-groups render and we have something to scroll to.72 await waitForCondition(73 () => findInEmojiPicker(74 '[data-group="5"] > emoji-group', 'emoji-button', 'button'));75 thirdButton.click();76 // wait while waiting for scroll to happen and update buttons.77 await waitForCondition(78 () => isGroupButtonActive(thirdButton) &&79 !isGroupButtonActive(firstButton));80 const newScroll = emojiGroups.scrollTop;81 assertGT(newScroll, initialScroll);82 // check the highlight bar also moved83 const bar = findInEmojiPicker('#bar');84 assertGT(parseInt(bar.style.left, 10), 0);85 });86 test('recently used should be hidden when empty', () => {87 const recentlyUsed =88 findInEmojiPicker('[data-group=history] > emoji-group');89 assert(!recentlyUsed);90 });91 test(92 'recently used should be populated after emoji is clicked normally',93 async () => {94 EmojiPickerApiProxyImpl.getInstance().isIncognitoTextField = () =>95 new Promise((resolve) => resolve({incognito: false}));96 // yield to allow emoji-group and emoji buttons to render.97 const emojiButton = await waitForCondition(98 () => findInEmojiPicker(99 '[data-group="0"] > emoji-group', 'emoji-button', 'button'));100 emojiButton.click();101 // wait until emoji exists in recently used section.102 const recentlyUsed = await waitForCondition(103 () => findInEmojiPicker(104 '[data-group=history] > emoji-group', 'emoji-button',105 'button'));106 // check text is correct.107 const recentText = recentlyUsed.innerText;108 assertTrue(recentText.includes(String.fromCodePoint(128512)));109 });110 test(111 'recently used should be empty after emoji is clicked in incognito mode',112 async () => {113 EmojiPickerApiProxyImpl.getInstance().isIncognitoTextField = () =>114 new Promise((resolve) => resolve({incognito: true}));115 // yield to allow emoji-group and emoji buttons to render.116 const emojiButton = await waitForCondition(117 () => findInEmojiPicker(118 '[data-group="0"] > emoji-group', 'emoji-button', 'button'));119 emojiButton.click();120 // Wait to ensure recents has a chance to render if we have a bug.121 await timeout(1000);122 const recentlyUsed =123 findInEmojiPicker('[data-group=history] > emoji-group');124 assert(!recentlyUsed);125 });126 suite('<emoji-variants>', () => {127 /** @type {!EmojiButton} */128 let firstEmojiButton;129 /** @type {function(!EmojiButton): ?EmojiVariants} */130 const findEmojiVariants = el => {131 const variants =132 /** @type {?EmojiVariants} */ (el.querySelector('emoji-variants'));133 return variants && variants.style.display !== 'none' ? variants : null;134 };135 setup(async () => {136 firstEmojiButton = (await waitForCondition(137 () => findInEmojiPicker(138 '[data-group="0"] > emoji-group',139 'emoji-button:nth-child(2)')))140 .shadowRoot;141 // right click and wait for variants to appear.142 const variantsPromise = waitForEvent(emojiPicker, EMOJI_VARIANTS_SHOWN);143 dispatchMouseEvent(firstEmojiButton.querySelector('button'), 2);144 await waitWithTimeout(145 variantsPromise, 1000, 'did not receive emoji variants event.');146 await waitForCondition(147 () => findEmojiVariants(firstEmojiButton),148 'emoji-variants failed to appear.', 5000);149 });150 test('right clicking emoji again should close popup', async () => {151 // right click again and variants should disappear.152 dispatchMouseEvent(firstEmojiButton.querySelector('button'), 2);153 await waitForCondition(154 () => !findEmojiVariants(firstEmojiButton),155 'emoji-variants failed to disappear.');156 });157 test('clicking elsewhere should close popup', async () => {158 // click in some empty space of main emoji picker.159 emojiPicker.click();160 await waitForCondition(161 () => !findEmojiVariants(firstEmojiButton),162 'emoji-variants failed to disappear.');163 });164 test('opening different variants should close first variants', async () => {165 const emojiButton2 = await waitForCondition(166 () =>167 findInEmojiPicker(168 '[data-group="0"] > emoji-group', 'emoji-button:nth-child(3)')169 .shadowRoot);170 // right click on second emoji button171 dispatchMouseEvent(emojiButton2.querySelector('button'), 2);172 // ensure first popup disappears and second popup appears.173 await waitForCondition(174 () => !findEmojiVariants(firstEmojiButton),175 'first emoji-variants failed to disappear.');176 await waitForCondition(177 () => findEmojiVariants(emojiButton2),178 'second emoji-variants failed to appear.');179 });180 test('opening variants on the left side should not overflow', async () => {181 const groupsRect = emojiPicker.getBoundingClientRect();182 const variants = findEmojiVariants(firstEmojiButton);183 const variantsRect = variants.getBoundingClientRect();184 assertLT(groupsRect.left, variantsRect.left);185 assertLT(variantsRect.right, groupsRect.right);186 });187 test('opening large variants (twice) should not overflow', async () => {188 const coupleEmojiButton = await waitForCondition(189 () =>190 findInEmojiPicker(191 '[data-group="0"] > emoji-group', 'emoji-button:nth-child(5)')192 .shadowRoot);193 // listen for emoji variants event.194 const variantsPromise = waitForEvent(emojiPicker, EMOJI_VARIANTS_SHOWN);195 // right click on couple emoji to show 5x5 grid with skin tone.196 dispatchMouseEvent(coupleEmojiButton.querySelector('button'), 2);197 const variants =198 await waitForCondition(() => findEmojiVariants(coupleEmojiButton));199 // ensure variants are positioned before we get bounding rectangle.200 await waitWithTimeout(201 variantsPromise, 1000, 'did not receive emoji variants event.');202 const variantsRect = variants.getBoundingClientRect();203 const pickerRect = emojiPicker.getBoundingClientRect();204 assertLT(pickerRect.left, variantsRect.left);205 assertLT(variantsRect.right, pickerRect.right);206 // Now close the variants and reopen, should still be positioned properly.207 emojiPicker.click();208 await waitForCondition(209 () => !findEmojiVariants(firstEmojiButton),210 'emoji-variants failed to disappear.');211 const variantsPromise2 = waitForEvent(emojiPicker, EMOJI_VARIANTS_SHOWN);212 // reshow213 dispatchMouseEvent(coupleEmojiButton.querySelector('button'), 2);214 const variants2 =215 await waitForCondition(() => findEmojiVariants(coupleEmojiButton));216 // ensure variants are positioned before we get bounding rectangle.217 await waitWithTimeout(218 variantsPromise2, 1000,219 'did not receive second emoji variants event.');220 const variantsRect2 = variants2.getBoundingClientRect();221 assertLT(pickerRect.left, variantsRect2.left);222 assertLT(variantsRect2.right, pickerRect.right);223 });224 });...

Full Screen

Full Screen

browser_selection_basic.js

Source:browser_selection_basic.js Github

copy

Full Screen

...16 if (gWindow)17 clearSelection(gWindow);18 if (gFrame)19 clearSelection(gFrame);20 yield waitForCondition(function () {21 return !SelectionHelperUI.isSelectionUIVisible;22 }, kCommonWaitMs, kCommonPollMs);23}24gTests.push({25 desc: "normalize browser",26 setUp: setUpAndTearDown,27 tearDown: setUpAndTearDown,28 run: function test() {29 info(chromeRoot + "browser_selection_basic.html");30 yield addTab(chromeRoot + "browser_selection_basic.html");31 yield waitForCondition(function () {32 return !StartUI.isStartPageVisible;33 }, 10000, 100);34 yield hideContextUI();35 gWindow = Browser.selectedTab.browser.contentWindow;36 InputSourceHelper.isPrecise = false;37 },38});39gTests.push({40 desc: "tap-hold to select",41 setUp: setUpAndTearDown,42 tearDown: setUpAndTearDown,43 run: function test() {44 sendContextMenuClick(30, 20);45 yield waitForCondition(function () {46 return SelectionHelperUI.isSelectionUIVisible;47 }, kCommonWaitMs, kCommonPollMs);48 is(getTrimmedSelection(gWindow).toString(), "There", "selection test");49 },50});51gTests.push({52 desc: "double-tap to select",53 setUp: setUpAndTearDown,54 tearDown: setUpAndTearDown,55 run: function test() {56 sendDoubleTap(gWindow, 30, 20);57 yield waitForCondition(function () {58 return SelectionHelperUI.isSelectionUIVisible;59 }, kCommonWaitMs, kCommonPollMs);60 is(getTrimmedSelection(gWindow).toString(), "There", "selection test");61 },62});63gTests.push({64 desc: "appbar interactions",65 setUp: setUpAndTearDown,66 tearDown: setUpAndTearDown,67 run: function test() {68 sendContextMenuClick(100, 20);69 yield waitForCondition(function () {70 return SelectionHelperUI.isSelectionUIVisible;71 }, kCommonWaitMs, kCommonPollMs);72 is(SelectionHelperUI.isActive, true, "selection active");73 is(getTrimmedSelection(gWindow).toString(), "nothing", "selection test");74 yield fireAppBarDisplayEvent();75 ok(ContextUI.isVisible, true, "appbar visible");76 yield hideContextUI();77 ok(!ContextUI.isVisible, true, "appbar hidden");78 },79});80gTests.push({81 desc: "simple drag selection",82 setUp: setUpAndTearDown,83 tearDown: setUpAndTearDown,84 run: function test() {85 yield waitForMs(100);86 sendContextMenuClick(100, 20);87 yield waitForCondition(function () {88 return SelectionHelperUI.isSelectionUIVisible;89 }, kCommonWaitMs, kCommonPollMs);90 is(SelectionHelperUI.isActive, true, "selection active");91 is(getTrimmedSelection(gWindow).toString(), "nothing", "selection test");92 let ypos = SelectionHelperUI.endMark.yPos + kMarkerOffsetY;93 let touchdrag = new TouchDragAndHold();94 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 190, ypos);95 touchdrag.end();96 yield waitForCondition(function () {97 return !SelectionHelperUI.hasActiveDrag;98 }, kCommonWaitMs, kCommonPollMs);99 yield SelectionHelperUI.pingSelectionHandler();100 is(SelectionHelperUI.isActive, true, "selection active");101 is(getTrimmedSelection(gWindow).toString(), "nothing so VERY", "selection test");102 },103});104gTests.push({105 desc: "expand / collapse selection",106 setUp: setUpAndTearDown,107 tearDown: setUpAndTearDown,108 run: function test() {109 sendContextMenuClick(30, 20);110 yield waitForCondition(function () {111 return SelectionHelperUI.isSelectionUIVisible;112 }, kCommonWaitMs, kCommonPollMs);113 is(SelectionHelperUI.isActive, true, "initial active");114 is(getTrimmedSelection(gWindow).toString(), "There", "initial selection test");115 for (let count = 0; count < 5; count++) {116 let ypos = SelectionHelperUI.endMark.yPos + kMarkerOffsetY;117 let touchdrag = new TouchDragAndHold();118 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 550, ypos);119 touchdrag.end();120 yield waitForCondition(function () {121 return !SelectionHelperUI.hasActiveDrag;122 }, kCommonWaitMs, kCommonPollMs);123 yield SelectionHelperUI.pingSelectionHandler();124 is(getTrimmedSelection(gWindow).toString(),125 "There was nothing so VERY remarkable in that; nor did Alice think it so",126 "long selection test");127 is(SelectionHelperUI.isActive, true, "selection active");128 touchdrag = new TouchDragAndHold();129 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 40, ypos);130 touchdrag.end();131 yield waitForCondition(function () {132 return !SelectionHelperUI.hasActiveDrag;133 }, kCommonWaitMs, kCommonPollMs);134 yield SelectionHelperUI.pingSelectionHandler();135 is(SelectionHelperUI.isActive, true, "selection active");136 is(getTrimmedSelection(gWindow).toString(), "There was", "short selection test");137 }138 },139});140gTests.push({141 desc: "expand / collapse selection scolled content",142 setUp: setUpAndTearDown,143 run: function test() {144 let scrollPromise = waitForEvent(gWindow, "scroll");145 gWindow.scrollBy(0, 200);146 yield scrollPromise;147 ok(scrollPromise && !(scrollPromise instanceof Error), "scrollPromise error");148 sendContextMenuClick(106, 20);149 yield waitForCondition(function () {150 return SelectionHelperUI.isSelectionUIVisible;151 }, kCommonWaitMs, kCommonPollMs);152 is(SelectionHelperUI.isActive, true, "selection active");153 is(getTrimmedSelection(gWindow).toString(), "moment", "selection test");154 let ypos = SelectionHelperUI.endMark.yPos + kMarkerOffsetY;155 let touchdrag = new TouchDragAndHold();156 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 550, ypos);157 touchdrag.end();158 yield waitForCondition(function () {159 return !SelectionHelperUI.hasActiveDrag;160 }, kCommonWaitMs, kCommonPollMs);161 yield SelectionHelperUI.pingSelectionHandler();162 is(getTrimmedSelection(gWindow).toString(),163 "moment down went Alice after it, never once considering how in",164 "selection test");165 is(SelectionHelperUI.isActive, true, "selection active");166 touchdrag = new TouchDragAndHold();167 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 150, ypos);168 touchdrag.end();169 170 yield waitForCondition(function () {171 return !SelectionHelperUI.hasActiveDrag;172 }, kCommonWaitMs, kCommonPollMs);173 yield SelectionHelperUI.pingSelectionHandler();174 is(getTrimmedSelection(gWindow).toString(), "moment down went", "selection test");175 touchdrag = new TouchDragAndHold();176 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 550, ypos);177 touchdrag.end();178 yield waitForCondition(function () {179 return !SelectionHelperUI.hasActiveDrag;180 }, kCommonWaitMs, kCommonPollMs);181 yield SelectionHelperUI.pingSelectionHandler();182 is(getTrimmedSelection(gWindow).toString(),183 "moment down went Alice after it, never once considering how in",184 "selection test");185 touchdrag = new TouchDragAndHold();186 yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 160, ypos);187 touchdrag.end();188 189 yield waitForCondition(function () {190 return !SelectionHelperUI.hasActiveDrag;191 }, kCommonWaitMs, kCommonPollMs);192 yield SelectionHelperUI.pingSelectionHandler();193 is(getTrimmedSelection(gWindow).toString(),194 "moment down went",195 "selection test");196 },197 tearDown: function tearDown() {198 let scrollPromise = waitForEvent(gWindow, "scroll");199 gWindow.scrollBy(0, -200);200 yield scrollPromise;201 emptyClipboard();202 if (gWindow)203 clearSelection(gWindow);204 if (gFrame)205 clearSelection(gFrame);206 yield waitForCondition(function () {207 return !SelectionHelperUI.isSelectionUIVisible;208 }, kCommonWaitMs, kCommonPollMs);209 yield hideContextUI();210 },211});212gTests.push({213 desc: "scroll disables",214 setUp: setUpAndTearDown,215 run: function test() {216 sendContextMenuClick(100, 20);217 yield waitForCondition(function () {218 return SelectionHelperUI.isSelectionUIVisible;219 }, kCommonWaitMs, kCommonPollMs);220 is(SelectionHelperUI.isActive, true, "selection active");221 // scroll page222 sendTouchDrag(gWindow,223 400,224 400,225 400,226 200);227 yield waitForCondition(function () {228 return !SelectionHelperUI.isSelectionUIVisible;229 }, kCommonWaitMs, kCommonPollMs);230 // active state - should be disabled after a page scroll231 is(SelectionHelperUI.isActive, false, "selection inactive");232 },233 tearDown: function tearDown() {234 EventUtils.synthesizeKey("VK_HOME", {}, gWindow);235 emptyClipboard();236 if (gWindow)237 clearSelection(gWindow);238 if (gFrame)239 clearSelection(gFrame);240 yield waitForCondition(function () {241 return !SelectionHelperUI.isSelectionUIVisible;242 }, kCommonWaitMs, kCommonPollMs);243 yield hideContextUI();244 },245});246gTests.push({247 desc: "tap on selection clears selection in content",248 setUp: setUpAndTearDown,249 run: function test() {250 sendContextMenuClick(30, 20);251 yield waitForCondition(function () {252 return SelectionHelperUI.isSelectionUIVisible;253 }, kCommonWaitMs, kCommonPollMs);254 sendTap(gWindow, 30, 20);255 yield waitForCondition(function () {256 return !SelectionHelperUI.isSelectionUIVisible;257 }, kCommonWaitMs, kCommonPollMs);258 },259 tearDown: setUpAndTearDown,260});261gTests.push({262 desc: "tap off selection clears selection in content",263 setUp: setUpAndTearDown,264 run: function test() {265 sendContextMenuClick(30, 20);266 yield waitForCondition(function () {267 return SelectionHelperUI.isSelectionUIVisible;268 }, kCommonWaitMs, kCommonPollMs);269 sendTap(gWindow, 30, 100);270 yield waitForCondition(function () {271 return !SelectionHelperUI.isSelectionUIVisible;272 }, kCommonWaitMs, kCommonPollMs);273 },274 tearDown: setUpAndTearDown,275});276function test() {277 if (!isLandscapeMode()) {278 todo(false, "browser_selection_tests need landscape mode to run.");279 return;280 }281 requestLongerTimeout(3);282 runTests();...

Full Screen

Full Screen

lib.js

Source:lib.js Github

copy

Full Screen

...24 * @param {Element} container The container in which the node should be found.25 * @return {Promise}26 */27MM.clickOn = function (text, container) {28 waitForCondition();29 var locator = by.xpath('(//a | //button | //*[contains(concat(" ",normalize-space(@class)," ")," item ")])[contains(.,"' + text + '") or contains(@aria-label,"' + text + '")]');30 if (container) {31 waitForCondition();32 browser.wait(EC.presenceOf(container), 5000);33 node = container.element(locator);34 } else {35 node = element(locator);36 }37 waitForCondition();38 return MM.clickOnElement(node);39};40/**41 * Click on a element.42 *43 * This will scroll the view if required.44 *45 * @param {Element} el46 * @return {Promise}47 */48MM.clickOnElement = function (el) {49 waitForCondition();50 browser.sleep(2000);51 browser.wait(EC.presenceOf(el), 50000);52 browser.executeScript('arguments[0].scrollIntoView(true)', el.getWebElement());53 browser.wait(EC.elementToBeClickable(el), 13000);54 return el.click();55};56/**57 * Go to bottom of page and Click on a element.58 *59 * This will scroll the view if required.60 *61 * @param {Element} text62 * @return {Promise}63 */64MM.goToBottomAndClick = function (text) {65 waitForCondition();66 browser.sleep(2000); // This is must, due to slow page rendering issues.67 var locator = by.xpath('(//a | //button | //*[contains(concat(" ",normalize-space(@class)," ")," item ")])[contains(.,"' + text + '") or contains(@aria-label,"' + text + '")]');68 browser.wait(EC.presenceOf(element(locator)), 5000);69 node = element(locator);70 waitForCondition();71 browser.sleep(2000);72 browser.executeScript('arguments[0].scrollIntoView(false)', node.getWebElement());73 browser.wait(EC.elementToBeClickable(node), 15000);74 return node.click();75}76/**77 * Click on a link in the side menu.78 *79 * @param {String} text The link name80 * @return {Promise}81 */82MM.clickOnInSideMenu = function (text) {83 return MM.openSideMenu().then(function () {84 waitForCondition();85 var menu = $('ion-side-menu[side="left"]');86 browser.wait(EC.visibilityOf(menu), 7000);87 browser.wait(EC.elementToBeClickable(menu), 5000);88 return MM.clickOn(text, menu);89 });90};91/**92 * Return the active header bar.93 *94 * @return {Element}95 */96MM.getNavBar = function () {97 waitForCondition();98 browser.wait(EC.visibilityOf($(currentNavBar)), 10000);99 browser.sleep(7000); // Wait for contents to render.100 return $(currentNavBar);101};102/**103 * Return the active view.104 *105 * @return {Element}106 */107MM.getView = function () {108 waitForCondition();109 browser.wait(EC.visibilityOf($(currentView)), 50000);110 browser.sleep(7000); // Wait for contents to render.111 return $(currentView);112};113/**114 * Navigate back.115 *116 * @return {Promise}117 */118MM.goBack = function () {119 var backBtn = $(currentNavBar + ' .back-button');120 waitForCondition();121 browser.wait(EC.visibilityOf(backBtn), 15000);122 return backBtn.isPresent().then(function (present) {123 if (present) {124 return backBtn.isDisplayed().then(function (displayed) {125 if (displayed) {126 return backBtn.click();127 }128 throw new Error('Could not find back button.');129 });130 }131 throw new Error('Could not find the back button.');132 });133};134/**135 * Login as a user.136 *137 * @param {String} username The login138 * @param {String} password The password139 * @return {Promise}140 */141MM.loginAs = function (username, password) {142 browser.ignoreSynchronization = true;143 browser.waitForAngular();144 browser.wait(EC.visibilityOf(element(by.model('loginData.siteurl'))), 15000);145 element(by.model('loginData.siteurl'))146 .sendKeys(SITEURL);147 browser.wait(EC.elementToBeClickable($('[ng-click="connect(loginData.siteurl)"]')), 15000);148 return $('[ng-click="connect(loginData.siteurl)"]').click()149 .then(function () {150 waitForCondition();151 browser.wait(EC.visibilityOf($('[ng-click="login()"]')), 15000);152 element(by.model('credentials.username'))153 .sendKeys(username);154 element(by.model('credentials.password'))155 .sendKeys(password);156 browser.wait(EC.elementToBeClickable($('[ng-click="login()"]')), 15000);157 return $('[ng-click="login()"]').click();158 });159};160/**161 * Login as admin.162 *163 * @return {Promise}164 */165MM.loginAsAdmin = function () {166 return MM.loginAs(USERS.ADMIN.LOGIN, USERS.ADMIN.PASSWORD);167};168/**169 * Login as student.170 *171 * @return {Promise}172 */173MM.loginAsStudent = function () {174 return MM.loginAs(USERS.STUDENT.LOGIN, USERS.STUDENT.PASSWORD);175};176/**177 * Login as teacher.178 *179 * @return {Promise}180 */181MM.loginAsTeacher = function () {182 return MM.loginAs(USERS.TEACHER.LOGIN, USERS.TEACHER.PASSWORD);183};184/**185 * Logout (change site).186 *187 * @return {Promise}188 */189MM.logout = function () {190 return MM.clickOnInSideMenu('Change site');191};192/**193 * Open the side menu from anywhere.194 *195 * @return {Promise}196 */197MM.openSideMenu = function () {198 var menuBtn = $(currentNavBar + ' [menu-toggle="left"]:not(.hide)');199 waitForCondition();200 browser.wait(EC.visibilityOf(menuBtn), 10000);201 browser.wait(EC.elementToBeClickable(menuBtn), 50000);202 function navigateBack() {203 return MM.goBack().then(function () {204 return openMenu();205 });206 }207 function openMenu() {208 return menuBtn.isPresent().then(function (present) {209 if (present) {210 return menuBtn.isDisplayed().then(function (displayed) {211 if (displayed) {212 return menuBtn.click();213 }...

Full Screen

Full Screen

selenium-executionloop.js

Source:selenium-executionloop.js Github

copy

Full Screen

...119 }120 },121 continueTestWhenConditionIsTrue: function () {122 /**123 * Busy wait for waitForCondition() to become true, and then carry124 * on with test. Fail the current test if there's a timeout or an125 * exception.126 */127 //LOG.debug("currentTest.continueTestWhenConditionIsTrue()");128 selenium.browserbot.runScheduledPollers();129 try {130 if (this.waitForCondition == null) {131 LOG.debug("null condition; let's continueTest()");132 LOG.debug("Command complete");133 this.commandComplete(this.result);134 this.continueTest();135 } else if (this.waitForCondition()) {136 LOG.debug("condition satisfied; let's continueTest()");137 this.waitForCondition = null;138 LOG.debug("Command complete");139 this.commandComplete(this.result);140 this.continueTest();141 } else {142 //LOG.debug("waitForCondition was false; keep waiting!");143 window.setTimeout(fnBind(this.continueTestWhenConditionIsTrue, this), 10);144 }145 } catch (e) {146 this.result = {};147 this.result.failed = true;148 this.result.failureMessage = extractExceptionMessage(e);149 this.commandComplete(this.result);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.wait(function () {7 return driver.executeScript('return document.readyState').then(function (readyState) {8 return readyState === 'complete';9 });10}, 10000);11driver.quit();12Error: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Timeout waiting for fulfillment of promise" UserInfo={NSLocalizedDescription=Timeout waiting for fulfillment of promise}13var webdriver = require('selenium-webdriver');14var driver = new webdriver.Builder()15 .withCapabilities({16 })17 .build();18driver.wait(function () {19 return driver.executeScript('return document.readyState').then(function (readyState) {20 return readyState === 'complete';21 });22}, 10000);23driver.quit();24Error: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Timeout waiting for fulfillment of promise" UserInfo={NSLocalizedDescription=Timeout waiting for fulfillment of promise}

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6const assert = chai.assert;7const desiredCaps = {8 deviceName: 'iPhone 11',const wd = require('wd');9};10driver.init(hesiredCaps)11 a.then(() i> {12 = turn driver.waitForCondition('name == "button"');13 })14 .then(() => {15 return driver.waitForCondition('name == "button"', 5000);16 })17 .then(() => {18 return driver.waitForCondition('name == "button"', 5000, 500);19 })20 .then(() => {21 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string');22 })23 .then(() => {24 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message');25 })26 .then(() => {27 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1);28 })29 .then(() => {30 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context');31 })32 .then(() => {33 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value');34 })35 .then(() => {36 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value', 'my name');37 })38 .then(() => {39 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value', 'my name', 'my element');40 })41 .then(() => {42 return driver.waitForCondition('name == "button"',

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = rerequire('chai');2const chaiAsPromised = require('chai-as-promised');3chai.use(chaiAsPromised);4const expect = chai.expect;5const assert = chai.assert;6const desiredCaps = {7};8driver.init(desiredCaps)9 .then(() => {10 return driver.waitForCondition('name == "button"');11 })12 .then(() => {13 return driver.waitForCondition('name == "button"', 5000);14 })15 .then(() => {16 return driver.waitForCondition('name == "button"', 5000, 500);17 })18 .then(() => {19 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string');20 })21 .then(() => {22 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message');23 })24 .then(() => {25 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1);26 })27 .then(() => {28 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context');29 })30 .then(() => {31 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value');32 })33 .then(() => {34 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value', 'my name');35 })36 .then(() => {37 return driver.waitForCondition('name == "button"', 5000, 500, 'predicate string', 'error message', 1, 'my context', 'my value', 'my name', 'my element');38 })39 .then(() => {40 return driver.waitForCondition('name == "button"',

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const config = {4};5const driver = wd.promiseChainRemote('localhost', 4723);6driver.init(config).then(() => {7 driver.waitForCondition("name == 'myButton'", 10000);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6 .wait(function() {7 return driver.executeAsyncScript(function() {8 var callback = arguments[arguments.length - 1];9 callback(true);10 });11 }, 10000)12 .then(function() {13 }, function(err) {14 });15driver.quit();16callback(true);17callback(document.querySelector('XCUIElementTypeButton') != null);18callback(document.querySelector('XCUIElementTypeButton').displayed);19callback(document.querySelector('XCUIElementTypeButton').text == 'Hello');

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6 .wait(function() {7 return driver.executeAsyncScript(function() {8 var callback = arguments[arguments.length - 1];9 callback(true);10 });11 }, 10000)12 .then(function() {13 }, function(err) {

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 const button = await client.$("~Buttons, Various uses of UIButton");9 await button.click();10 const backButton = await client.$("~Back");11 await backButton.waitForExist({ timeout: 3000 });12 await backButton.click();13 await client.deleteSession();14}15main();16const wdio = require("webdriverio");17const opts = {18 capabilities: {19 }20};21async function main() {22 const client = await wdio.remote(opts);23 const button = await client.$("~Buttons, Various uses of UIButton");24 await button.click();25 const backButton = await client.$("~Back");26 await backButton.waitForExist({ timeout: 3000 });27 await backButton.click();28 await client.deleteSession();29}30 });31driver.quit();32callback(true);33callback(document.querySelector('XCUIElementTypeButton') != null);34callback(document.querySelector('XCUIElementTypeButton').displayed);35callback(document.querySelector('XCUIElementTypeButton').text == 'Hello');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6const username = process.env.SAUCE_USERNAME;7const accessKey = process.env.SAUCE_ACCESS_KEY;8describe('Appium XCUITest Driver - waitForCondition', function () {9 this.timeout(300000);10 let driver;11 before(async () => {12 driver = await wd.promiseChainRemote('ondemand.us-west-1.saucelabs.com', 443, username, accessKey);13 await driver.init({14 });15 });16 after(async () => {17 await driver.quit();18 });19 it('should check if element is displayed', async () => {20 await driver.waitForCondition('au.getElementByAccessibilityId("TestApp").displayed()', 10000);21 const text = await driver.elementByAccessibilityId('TestApp').text();22 expect(text).to.equal('TestApp');23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6const PORT = 4723;

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful