Best JavaScript code snippet using taiko
test_spec.js
Source:test_spec.js
...51 // TODO(charlie): Add tests for Keys.FRAC_EXCLUSIVE (the mixed-number52 // fraction key).53 describe('Fraction Bar', () => {54 it('should work with no content', () => {55 mathField.pressKey(Keys.FRAC_INCLUSIVE);56 assert.equal(mathField.getContent(), '\\frac{ }{ }');57 });58 it('should work after an expression', () => {59 mathField.setContent('35x^2');60 mathField.pressKey(Keys.FRAC_INCLUSIVE);61 assert.equal(mathField.getContent(), '\\frac{35x^2}{ }');62 });63 it('should work before an expression', () => {64 mathField.setContent('35x^2');65 mathField.moveToStart();66 mathField.pressKey(Keys.FRAC_INCLUSIVE);67 assert.equal(mathField.getContent(), '\\frac{ }{ }35x^2');68 });69 it('should work with a selected expression', () => {70 mathField.setContent('35x^2');71 mathField.selectAll();72 mathField.pressKey(Keys.FRAC_INCLUSIVE);73 assert.equal(mathField.getContent(), '\\frac{35x^2}{ }');74 });75 });76 describe('Parentheses', () => {77 it('should work with no content', () => {78 mathField.setContent('');79 mathField.pressKey(Keys.LEFT_PAREN);80 assert.equal(mathField.getContent(), '\\left(\\right)');81 });82 it('should work after an expression', () => {83 mathField.setContent('35x^2');84 mathField.pressKey(Keys.RIGHT_PAREN);85 assert.equal(mathField.getContent(), '\\left(35x^2\\right)');86 });87 it('should work before an expression', () => {88 mathField.setContent('35x^2');89 mathField.moveToStart();90 mathField.pressKey(Keys.LEFT_PAREN);91 assert.equal(mathField.getContent(), '\\left(35x^2\\right)');92 });93 it.skip('should work on a selected expression', () => {94 mathField.setContent('35x + 5');95 mathField.selectAll();96 mathField.pressKey(Keys.LEFT_PAREN);97 assert.equal(mathField.getContent(), '\\left(35x^2\\right)');98 });99 });100 describe('Squared', () => {101 it('should prefix with empty parens after no content', () => {102 mathField.pressKey(Keys.EXP_2);103 assert.equal(mathField.getContent(), '\\left(\\right)^2');104 // Verify that the cursor is in parens.105 assert(isInsideEmptyParens(mathField.getCursor()));106 });107 it('should prefix with empty parens after an operator', () => {108 mathField.pressKey(Keys.DIVIDE);109 mathField.pressKey(Keys.EXP_2);110 assert.equal(mathField.getContent(), '\\div\\left(\\right)^2');111 });112 it('should work after an expression', () => {113 mathField.setContent('35x');114 mathField.pressKey(Keys.EXP_2);115 assert.equal(mathField.getContent(), '35x^2');116 });117 it.skip('should work on a selected expression', () => {118 mathField.setContent('35x+5');119 mathField.selectAll();120 mathField.pressKey(Keys.EXP_2);121 assert.equal(mathField.getContent(), '\\left(35x+5\\right)^2');122 });123 });124 describe('Cubed', () => {125 it('should prefix with empty parens after no content', () => {126 mathField.pressKey(Keys.EXP_3);127 assert.equal(mathField.getContent(), '\\left(\\right)^3');128 // Verify that the cursor is in parens.129 assert(isInsideEmptyParens(mathField.getCursor()));130 });131 it('should prefix with empty parens after an operator', () => {132 mathField.pressKey(Keys.EQUAL);133 mathField.pressKey(Keys.EXP_3);134 assert.equal(mathField.getContent(), '=\\left(\\right)^3');135 });136 it('should work after an expression', () => {137 mathField.setContent('35x');138 mathField.pressKey(Keys.EXP_3);139 assert.equal(mathField.getContent(), '35x^3');140 });141 it.skip('should work on a selected expression', () => {142 mathField.setContent('35x+5');143 mathField.selectAll();144 mathField.pressKey(Keys.EXP_3);145 assert.equal(mathField.getContent(), '\\left(35x+5\\right)^3');146 });147 });148 describe('Exponent', () => {149 it('should prefix with empty parens after no content', () => {150 mathField.pressKey(Keys.EXP);151 assert.equal(mathField.getContent(), '\\left(\\right)^{ }');152 // Verify that the cursor is in the exponent, not within the parens,153 // writing a unique character to verify cursor position.154 assert(!isInsideEmptyParens(mathField.getCursor()));155 mathField.pressKey(Keys.PLUS);156 assert.equal(mathField.getContent(), '\\left(\\right)^+');157 });158 it('should prefix with empty parens after an operator', () => {159 mathField.pressKey(Keys.PLUS);160 mathField.pressKey(Keys.EXP);161 assert.equal(mathField.getContent(), '+\\left(\\right)^{ }');162 });163 it('should work after an expression', () => {164 mathField.setContent('35x');165 mathField.pressKey(Keys.EXP);166 assert.equal(mathField.getContent(), '35x^{ }');167 });168 // TODO(kevinb): makes the expression an exponent when it shouldn't169 it.skip('should work on a selected expression', () => {170 mathField.setContent('35x+5');171 mathField.selectAll();172 mathField.pressKey(Keys.EXP);173 assert.equal(mathField.getContent(), '\\left(35x+5\\right)^{ }');174 });175 });176 describe('Square Root', () => {177 it('should work with no content', () => {178 mathField.pressKey(Keys.SQRT);179 assert.equal(mathField.getContent(), '\\sqrt{ }');180 });181 it('should work after an expression', () => {182 mathField.setContent('35x^2');183 mathField.pressKey(Keys.SQRT);184 assert.equal(mathField.getContent(), '35x^2\\sqrt{ }');185 });186 it('should work on a selected expression', () => {187 mathField.setContent('35x+5');188 mathField.selectAll();189 mathField.pressKey(Keys.SQRT);190 assert.equal(mathField.getContent(), '\\sqrt{35x+5}');191 });192 });193 describe('Radical', () => {194 it('should work with no content', () => {195 mathField.pressKey(Keys.RADICAL);196 assert.equal(mathField.getContent(), '\\sqrt[]{}');197 });198 it('should work after an expression', () => {199 mathField.setContent('35x^2');200 mathField.pressKey(Keys.RADICAL);201 assert.equal(mathField.getContent(), '35x^2\\sqrt[]{}');202 });203 it.skip('should work on a selected expression', () => {204 mathField.setContent('35x+5');205 mathField.selectAll();206 mathField.pressKey(Keys.RADICAL);207 // TODO(kevinb): check cursor location208 assert.equal(mathField.getContent(), '\\sqrt[ ]{35x+5}');209 });210 });211 describe('Log', () => {212 it('should work with no content', () => {213 mathField.pressKey(Keys.LOG);214 assert.equal(mathField.getContent(), '\\log\\left(\\right)');215 });216 it('should work after an expression', () => {217 mathField.setContent('35x^2');218 mathField.pressKey(Keys.LOG);219 assert.equal(mathField.getContent(), '35x^2\\log\\left(\\right)');220 });221 it.skip('should work on a selected expression', () => {222 mathField.setContent('35x+5');223 mathField.selectAll();224 mathField.pressKey(Keys.LOG);225 assert.equal(mathField.getContent(), '\\log\\left(35x+5\\right)');226 });227 });228 describe('Log w/ base n', () => {229 it('should work with no content', () => {230 mathField.pressKey(Keys.LOG_N);231 assert.equal(mathField.getContent(), '\\log_{ }\\left(\\right)');232 });233 it('should work after an expression', () => {234 mathField.setContent('35x^2');235 mathField.pressKey(Keys.LOG_N);236 assert.equal(237 mathField.getContent(), '35x^2\\log_{ }\\left(\\right)');238 });239 it.skip('should work on a selected expression', () => {240 mathField.setContent('35x+5');241 mathField.selectAll();242 mathField.pressKey(Keys.LOG_N);243 assert.equal(244 mathField.getContent(), '\\log_{ }\\left(35x+5\\right)');245 });246 });247 describe('Backspace', () => {248 it('should delete an empty fraction from the numerator', () => {249 mathField.setContent('\\frac{ }{ }');250 mathField.moveToStart();251 mathField.pressKey(Keys.RIGHT);252 mathField.pressKey(Keys.BACKSPACE);253 assert.equal(mathField.getContent(), '');254 });255 it('should convert a fraction when deleting the denominator', () => {256 mathField.setContent('\\frac{35x^2}{ }');257 mathField.pressKey(Keys.LEFT);258 mathField.pressKey(Keys.BACKSPACE);259 assert.equal(mathField.getContent(), '35x^2');260 });261 // TODO(kevinb) math isn't selected262 it('should select a fraction when deleting from outside of it', () => {263 const expr = '\\frac{35x+5}{x^2}';264 mathField.setContent(expr);265 mathField.pressKey(Keys.BACKSPACE);266 assert(mathField.isSelected());267 assert.equal(mathField.getContent(), expr);268 });269 it('should delete parens when inside empty parens', () => {270 mathField.setContent('\\left(\\right)');271 mathField.pressKey(Keys.LEFT);272 mathField.pressKey(Keys.BACKSPACE);273 assert.equal(mathField.getContent(), '');274 });275 it('deletes only the first parens when inside empty parens', () => {276 mathField.setContent('\\left(\\right)\\left(\\right)');277 mathField.pressKey(Keys.LEFT);278 mathField.pressKey(Keys.BACKSPACE);279 assert.equal(mathField.getContent(), '\\left(\\right)');280 });281 it('should select an expression when deleting from outside (1)', () => {282 const expr = '\\left(35x+5\\right)';283 mathField.setContent(expr);284 mathField.pressKey(Keys.BACKSPACE);285 assert(mathField.isSelected());286 assert.equal(mathField.getContent(), expr);287 });288 it('should select an expression when deleting from outside (2)', () => {289 const expr = '1+\\left(35x+5\\right)';290 mathField.setContent(expr);291 mathField.pressKey(Keys.BACKSPACE);292 const selection = mathField.getSelection();293 const left = selection.ends[MQ.L][MQ.L];294 const right = selection.ends[MQ.R][MQ.R];295 assert.equal(left.ctrlSeq, '+');296 assert.equal(right, END_OF_EXPR);297 assert.equal(mathField.getContent(), expr);298 });299 it('should select an expression when deleting from outside (3)', () => {300 const expr = '1+\\left(35x+5\\right)-1';301 mathField.setContent(expr);302 mathField.pressKey(Keys.LEFT);303 mathField.pressKey(Keys.LEFT);304 mathField.pressKey(Keys.BACKSPACE);305 const selection = mathField.getSelection();306 const left = selection.ends[MQ.L][MQ.L];307 const right = selection.ends[MQ.R][MQ.R];308 assert.equal(left.ctrlSeq, '+');309 assert.equal(right.ctrlSeq, '-');310 assert.equal(mathField.getContent(), expr);311 });312 it('should select an expression when deleting from outside (4)', () => {313 const expr = '\\left(35x+5\\right)-1';314 mathField.setContent(expr);315 mathField.pressKey(Keys.LEFT);316 mathField.pressKey(Keys.LEFT);317 mathField.pressKey(Keys.BACKSPACE);318 const selection = mathField.getSelection();319 const left = selection.ends[MQ.L][MQ.L];320 const right = selection.ends[MQ.R][MQ.R];321 assert.equal(left, END_OF_EXPR);322 assert.equal(right.ctrlSeq, '-');323 assert.equal(mathField.getContent(), expr);324 });325 it('should select an expression when deleting from outside', () => {326 mathField.setContent('\\left(35x+5\\right)');327 mathField.pressKey(Keys.BACKSPACE);328 assert(mathField.isSelected());329 assert.equal(mathField.getContent(), '\\left(35x+5\\right)');330 });331 // TODO(kevinb) fix this behavior so that we delete the exponent too332 it.skip('should not delete squared exponents', () => {333 mathField.setContent('35x^2');334 mathField.pressKey(Keys.BACKSPACE);335 assert.equal(mathField.getContent(), '35x^2');336 mathField.pressKey(Keys.BACKSPACE);337 assert.equal(mathField.getContent(), '35x^{ }');338 });339 it('should not delete non-square exponents', () => {340 mathField.setContent('35x^5');341 mathField.pressKey(Keys.BACKSPACE);342 assert.equal(mathField.getContent(), '35x^5');343 mathField.pressKey(Keys.BACKSPACE);344 assert.equal(mathField.getContent(), '35x^{ }');345 });346 it('should delete an empty exponent', () => {347 mathField.setContent('35x^{}');348 mathField.pressKey(Keys.LEFT);349 mathField.pressKey(Keys.BACKSPACE);350 assert.equal(mathField.getContent(), '35x');351 });352 it('should delete an empty square root', () => {353 mathField.setContent('\\sqrt{}');354 mathField.pressKey(Keys.LEFT);355 mathField.pressKey(Keys.BACKSPACE);356 assert.equal(mathField.getContent(), '');357 });358 it('should delete an empty radical when cursor is in index', () => {359 mathField.setContent('\\sqrt[]{}');360 mathField.moveToStart();361 mathField.pressKey(Keys.RIGHT);362 mathField.pressKey(Keys.BACKSPACE);363 assert.equal(mathField.getContent(), '');364 });365 it('should delete an empty radical when cursor is in body', () => {366 mathField.pressKey(Keys.RADICAL);367 mathField.pressKey(Keys.RIGHT);368 mathField.pressKey(Keys.BACKSPACE);369 assert.equal(mathField.getContent(), '');370 });371 it('should select an empty radical with non-empty root', () => {372 mathField.pressKey(Keys.CUBE_ROOT);373 const expr = mathField.getContent();374 mathField.pressKey(Keys.BACKSPACE);375 assert(mathField.isSelected());376 assert.equal(mathField.getContent(), expr);377 });378 it('should normally delete within a non-empty radical', () => {379 mathField.pressKey(Keys.CUBE_ROOT);380 const expr = mathField.getContent();381 mathField.pressKey('NUM_2');382 mathField.pressKey(Keys.BACKSPACE);383 assert.equal(mathField.getContent(), expr);384 });385 it('deletes nthroot index normally', () => {386 mathField.setContent('\\sqrt[3]{35x+5}');387 mathField.moveToStart();388 mathField.pressKey(Keys.RIGHT);389 mathField.pressKey(Keys.RIGHT);390 mathField.pressKey(Keys.BACKSPACE);391 const cursor = mathField.getCursor();392 assert.equal(cursor[MQ.L], END_OF_EXPR);393 assert.equal(mathField.getContent(), '\\sqrt[]{35x+5}');394 });395 it('converts nthroot to sqrt when deleting from index (1)', () => {396 mathField.setContent('\\sqrt[]{35x+5}');397 mathField.moveToStart();398 mathField.pressKey(Keys.RIGHT);399 mathField.pressKey(Keys.BACKSPACE);400 const cursor = mathField.getCursor();401 assert.equal(cursor[MQ.L], END_OF_EXPR);402 assert.equal(mathField.getContent(), '\\sqrt{35x+5}');403 });404 it('converts nthroot to sqrt when deleting from index (2)', () => {405 mathField.setContent('1+\\sqrt[]{35x+5}');406 mathField.moveToStart();407 mathField.pressKey(Keys.RIGHT);408 mathField.pressKey(Keys.RIGHT);409 mathField.pressKey(Keys.RIGHT);410 mathField.pressKey(Keys.BACKSPACE);411 const cursor = mathField.getCursor();412 assert.equal(cursor[MQ.L].ctrlSeq, '+');413 assert.equal(mathField.getContent(), '1+\\sqrt{35x+5}');414 });415 it('should not delete if the index has contents', () => {416 const expr = '\\sqrt[3]{35x+5}';417 mathField.setContent(expr);418 mathField.moveToStart();419 mathField.pressKey(Keys.RIGHT);420 mathField.pressKey(Keys.BACKSPACE);421 assert.equal(mathField.getContent(), expr);422 });423 it('should select a full square root before deleting it', () => {424 const expr = '\\sqrt{35x+5}';425 mathField.setContent(expr);426 mathField.pressKey(Keys.BACKSPACE);427 assert(mathField.isSelected());428 assert.equal(mathField.getContent(), expr);429 });430 it('should select a full nth-root before deleting it', () => {431 const expr = '\\sqrt[3]{35x+5}';432 mathField.setContent(expr);433 mathField.pressKey(Keys.BACKSPACE);434 assert(mathField.isSelected());435 assert.equal(mathField.getContent(), expr);436 });437 it('should delete log when inside empty log', () => {438 mathField.setContent('\\log\\left(\\right)');439 mathField.pressKey(Keys.LEFT);440 mathField.pressKey(Keys.BACKSPACE);441 assert.equal(mathField.getContent(), '');442 });443 it('should select log when inside full log at head', () => {444 const expr = '\\log\\left(35x\\right)';445 mathField.setContent(expr);446 mathField.moveToStart();447 mathField.pressKey(Keys.RIGHT);448 mathField.pressKey(Keys.BACKSPACE);449 assert(mathField.isSelected());450 assert.equal(mathField.getContent(), expr);451 });452 it('should select log when outside full log at tail (1)', () => {453 const expr = '\\log\\left(35x\\right)';454 mathField.setContent(expr);455 mathField.pressKey(Keys.BACKSPACE);456 assert(mathField.isSelected());457 assert.equal(mathField.getContent(), expr);458 });459 it('should select log when outside full log at tail (2)', () => {460 const expr = '1+\\log\\left(35x\\right)';461 mathField.setContent(expr);462 mathField.pressKey(Keys.BACKSPACE);463 const selection = mathField.getSelection();464 const left = selection.ends[MQ.L][MQ.L];465 const right = selection.ends[MQ.R][MQ.R];466 assert.equal(left.ctrlSeq, '+');467 assert.equal(right, END_OF_EXPR);468 assert.equal(mathField.getContent(), expr);469 });470 it('should select log when outside full log at tail (3)', () => {471 const expr = '1+\\log\\left(35x\\right)-1';472 mathField.setContent(expr);473 mathField.pressKey(Keys.LEFT);474 mathField.pressKey(Keys.LEFT);475 mathField.pressKey(Keys.BACKSPACE);476 const selection = mathField.getSelection();477 const left = selection.ends[MQ.L][MQ.L];478 const right = selection.ends[MQ.R][MQ.R];479 assert.equal(left.ctrlSeq, '+');480 assert.equal(right.ctrlSeq, '-');481 assert.equal(mathField.getContent(), expr);482 });483 it('should select log when outside full log at tail (4)', () => {484 const expr = '\\log\\left(35x\\right)-1';485 mathField.setContent(expr);486 mathField.pressKey(Keys.LEFT);487 mathField.pressKey(Keys.LEFT);488 mathField.pressKey(Keys.BACKSPACE);489 const selection = mathField.getSelection();490 const left = selection.ends[MQ.L][MQ.L];491 const right = selection.ends[MQ.R][MQ.R];492 assert.equal(left, END_OF_EXPR);493 assert.equal(right.ctrlSeq, '-');494 assert.equal(mathField.getContent(), expr);495 });496 it('should delete empty log when at index', () => {497 mathField.setContent('\\log_{ }\\left(\\right)');498 mathField.moveToStart();499 // Move right once to get into the parens, and then left twice to500 // get to the empty index.501 mathField.pressKey(Keys.RIGHT);502 mathField.pressKey(Keys.LEFT);503 mathField.pressKey(Keys.LEFT);504 mathField.pressKey(Keys.BACKSPACE);505 assert.equal(mathField.getContent(), '');506 });507 it('should delete log index normally', () => {508 mathField.setContent('\\log_5\\left(\\right)');509 mathField.moveToStart();510 // Move right once to get into the parens, and then left twice to511 // get to the index.512 mathField.pressKey(Keys.RIGHT);513 mathField.pressKey(Keys.LEFT);514 mathField.pressKey(Keys.LEFT);515 mathField.pressKey(Keys.BACKSPACE);516 assert.equal(mathField.getContent(), '\\log_{ }\\left(\\right)');517 });518 it('should move to index from inside empty log with index', () => {519 mathField.setContent('\\log_5\\left(\\right)');520 mathField.pressKey(Keys.LEFT);521 mathField.pressKey(Keys.BACKSPACE);522 const cursor = mathField.getCursor();523 assert.equal(cursor[MQ.L].ctrlSeq, '5');524 assert.equal(mathField.getContent(), '\\log_5\\left(\\right)');525 });526 it('should select full log when deleting from empty index (1)', () => {527 const expr = '\\log_{ }\\left(x\\right)';528 mathField.setContent(expr);529 mathField.moveToStart();530 // Move right once to get into the parens, and then left twice to531 // get to the empty index.532 mathField.pressKey(Keys.RIGHT);533 mathField.pressKey(Keys.LEFT);534 mathField.pressKey(Keys.LEFT);535 mathField.pressKey(Keys.BACKSPACE);536 assert(mathField.isSelected());537 assert.equal(mathField.getContent(), expr);538 });539 it('should select full log when deleting from empty index (2)', () => {540 const expr = '1+\\log_{ }\\left(x\\right)';541 mathField.setContent(expr);542 mathField.moveToStart();543 // Move right once to get into the parens, and then left twice to544 // get to the empty index.545 mathField.pressKey(Keys.RIGHT);546 mathField.pressKey(Keys.RIGHT);547 mathField.pressKey(Keys.RIGHT);548 mathField.pressKey(Keys.LEFT);549 mathField.pressKey(Keys.LEFT);550 mathField.pressKey(Keys.BACKSPACE);551 const selection = mathField.getSelection();552 const left = selection.ends[MQ.L][MQ.L];553 const right = selection.ends[MQ.R][MQ.R];554 assert.equal(left.ctrlSeq, '+');555 assert.equal(right, END_OF_EXPR);556 assert.equal(mathField.getContent(), expr);557 });558 it('should select full log when deleting from empty index (3)', () => {559 const expr = '1+\\log_{ }\\left(x\\right)-1';560 mathField.setContent(expr);561 mathField.moveToStart();562 // Move right three times to get into the parens, and then left563 // twice to get to the start of the empty index.564 mathField.pressKey(Keys.RIGHT);565 mathField.pressKey(Keys.RIGHT);566 mathField.pressKey(Keys.RIGHT);567 mathField.pressKey(Keys.LEFT);568 mathField.pressKey(Keys.LEFT);569 mathField.pressKey(Keys.BACKSPACE);570 const selection = mathField.getSelection();571 const left = selection.ends[MQ.L][MQ.L];572 const right = selection.ends[MQ.R][MQ.R];573 assert.equal(left.ctrlSeq, '+');574 assert.equal(right.ctrlSeq, '-');575 assert.equal(mathField.getContent(), expr);576 });577 it('should select full log when deleting from empty index (4)', () => {578 const expr = '\\log_{ }\\left(x\\right)-1';579 mathField.setContent(expr);580 mathField.moveToStart();581 // Move right once to get into the parens, and then left twice to582 // get to the start of the empty index.583 mathField.pressKey(Keys.RIGHT);584 mathField.pressKey(Keys.LEFT);585 mathField.pressKey(Keys.LEFT);586 mathField.pressKey(Keys.BACKSPACE);587 const selection = mathField.getSelection();588 const left = selection.ends[MQ.L][MQ.L];589 const right = selection.ends[MQ.R][MQ.R];590 assert.equal(left, END_OF_EXPR);591 assert.equal(right.ctrlSeq, '-');592 assert.equal(mathField.getContent(), expr);593 });594 });595 describe('Left arrow', () => {596 it('skips function names', () => {597 mathField.pressKey(Keys.COS);598 const cursor = mathField.getCursor();599 // Verify that we're inside the function.600 assert.equal(cursor[MQ.L], END_OF_EXPR);601 assert.equal(cursor[MQ.R], END_OF_EXPR);602 // Navigate left.603 mathField.pressKey(Keys.LEFT);604 // Verify that we moved beyond the body of the function.605 assert.equal(cursor[MQ.L], END_OF_EXPR);606 assert.equal(cursor[MQ.R].ctrlSeq, '\\c');607 });608 it('does not skip out of a function with valid content present', () => {609 mathField.pressKey(Keys.COS);610 mathField.pressKey(Keys.PLUS);611 const cursor = mathField.getCursor();612 // Verify that we're inside the function.613 assert.equal(cursor[MQ.L].ctrlSeq, '+');614 assert.equal(cursor[MQ.R], END_OF_EXPR);615 // Navigate left.616 mathField.pressKey(Keys.LEFT);617 // Verify that we didn't move out of the function.618 assert.equal(cursor[MQ.L], END_OF_EXPR);619 assert.equal(cursor[MQ.R].ctrlSeq, '+');620 });621 });622 describe('Right arrow', () => {623 it('skips function names', () => {624 mathField.setContent('\\cos\\left(5\\right)');625 mathField.moveToStart();626 const cursor = mathField.getCursor();627 // Verify that we're outside the function.628 assert.equal(cursor[MQ.L], END_OF_EXPR);629 assert.equal(cursor[MQ.R].ctrlSeq, '\\c');630 // Navigate right.631 mathField.pressKey(Keys.RIGHT);632 // Verify that we moved into the body of the function.633 assert.equal(cursor[MQ.L], END_OF_EXPR);634 assert.equal(cursor[MQ.R].ctrlSeq, '5');635 });636 });637 describe.skip('Jump out', () => {638 // TODO(charlie): Write extensive tests for the 'Jump out' behavior.639 });640 describe.skip('Equals =, !=, <, <=, >, >=', () => {641 });...
test_context-tracking.js
Source:test_context-tracking.js
...38 });39 }40 });41 it('should treat number-only expressions as non-jumpable', () => {42 mathField.pressKey('NUM_1');43 mathField.pressKey('NUM_2');44 const cursor = mathField.pressKey('NUM_3');45 assert.equal(cursor.context, CursorContexts.NONE);46 });47 it('should treat numbers and ternary operators as non-jumpable', () => {48 mathField.pressKey('NUM_1');49 mathField.pressKey(Keys.CDOT);50 const cursor = mathField.pressKey('NUM_2');51 assert.equal(cursor.context, CursorContexts.NONE);52 });53 describe('Before fraction', () => {54 it('should detect when immediately to the left', () => {55 const cursor = mathField.pressKey(Keys.FRAC_EXCLUSIVE);56 assert.equal(cursor.context, CursorContexts.BEFORE_FRACTION);57 });58 it('should detect when numbers are between', () => {59 mathField.pressKey('NUM_1');60 mathField.pressKey(Keys.FRAC_EXCLUSIVE);61 mathField.pressKey(Keys.LEFT);62 const cursor = mathField.pressKey(Keys.LEFT);63 assert.equal(cursor.context, CursorContexts.BEFORE_FRACTION);64 });65 it('should not detect when operators are between', () => {66 mathField.pressKey('NUM_1');67 mathField.pressKey(Keys.PLUS);68 mathField.pressKey('NUM_2');69 mathField.pressKey(Keys.FRAC_EXCLUSIVE);70 mathField.pressKey(Keys.LEFT);71 mathField.pressKey(Keys.LEFT);72 mathField.pressKey(Keys.LEFT);73 const cursor = mathField.pressKey(Keys.LEFT);74 assert.equal(cursor.context, CursorContexts.NONE);75 });76 it('should not detect when parens are between', () => {77 mathField.pressKey('NUM_1');78 mathField.pressKey(Keys.LEFT_PAREN);79 mathField.pressKey(Keys.RIGHT_PAREN);80 mathField.pressKey('NUM_2');81 mathField.pressKey(Keys.FRAC_EXCLUSIVE);82 mathField.pressKey(Keys.LEFT);83 mathField.pressKey(Keys.LEFT);84 mathField.pressKey(Keys.LEFT);85 mathField.pressKey(Keys.LEFT);86 const cursor = mathField.pressKey(Keys.LEFT);87 assert.equal(cursor.context, CursorContexts.NONE);88 });89 });90 describe('In parens', () => {91 it('should detect when inside empty parens', () => {92 mathField.pressKey(Keys.LEFT_PAREN);93 mathField.pressKey(Keys.RIGHT_PAREN);94 const cursor = mathField.pressKey(Keys.LEFT);95 assert.equal(cursor.context, CursorContexts.IN_PARENS);96 });97 it('should detect when inside non-empty parens', () => {98 mathField.pressKey(Keys.LEFT_PAREN);99 mathField.pressKey('NUM_2');100 mathField.pressKey(Keys.RIGHT_PAREN);101 const cursor = mathField.pressKey(Keys.LEFT);102 assert.equal(cursor.context, CursorContexts.IN_PARENS);103 });104 });105 describe('In superscript', () => {106 it('should detect when inside empty superscript', () => {107 mathField.pressKey('NUM_2');108 const cursor = mathField.pressKey(Keys.EXP);109 assert.equal(cursor.context, CursorContexts.IN_SUPER_SCRIPT);110 });111 it('should detect when inside non-empty superscript', () => {112 mathField.pressKey('NUM_2');113 mathField.pressKey(Keys.EXP);114 const cursor = mathField.pressKey('NUM_3');115 assert.equal(cursor.context, CursorContexts.IN_SUPER_SCRIPT);116 });117 });118 describe('In subscript', () => {119 it('should detect when inside empty superscript', () => {120 const cursor = mathField.pressKey(Keys.LOG_N);121 assert.equal(cursor.context, CursorContexts.IN_SUB_SCRIPT);122 });123 it('should detect when inside non-empty superscript', () => {124 mathField.pressKey(Keys.LOG_N);125 const cursor = mathField.pressKey('NUM_2');126 assert.equal(cursor.context, CursorContexts.IN_SUB_SCRIPT);127 });128 });129 describe('In numerator', () => {130 it('should detect when inside empty numerator', () => {131 const cursor = mathField.pressKey(Keys.FRAC_INCLUSIVE);132 assert.equal(cursor.context, CursorContexts.IN_NUMERATOR);133 });134 it('should detect when inside non-empty numerator', () => {135 mathField.pressKey(Keys.FRAC_INCLUSIVE);136 const cursor = mathField.pressKey('NUM_2');137 assert.equal(cursor.context, CursorContexts.IN_NUMERATOR);138 });139 });140 describe('In denominator', () => {141 it('should detect when inside empty denominator', () => {142 mathField.pressKey(Keys.FRAC_INCLUSIVE);143 const cursor = mathField.pressKey(Keys.RIGHT);144 assert.equal(cursor.context, CursorContexts.IN_DENOMINATOR);145 });146 it('should detect when inside non-empty denominator', () => {147 mathField.pressKey(Keys.FRAC_INCLUSIVE);148 mathField.pressKey(Keys.RIGHT);149 const cursor = mathField.pressKey('NUM_2');150 assert.equal(cursor.context, CursorContexts.IN_DENOMINATOR);151 });152 });153 describe('Nesting', () => {154 it('should defer to jumping into fraction if possible', () => {155 // Move inside parens, but include a fraction.156 mathField.pressKey(Keys.LEFT_PAREN);157 mathField.pressKey('NUM_2');158 mathField.pressKey(Keys.FRAC_EXCLUSIVE);159 const cursor = mathField.pressKey(Keys.LEFT);160 assert.equal(cursor.context, CursorContexts.BEFORE_FRACTION);161 });162 it('should defer to the nearest parent (1)', () => {163 // Move inside parens, inside a superscript.164 mathField.pressKey('NUM_2');165 mathField.pressKey(Keys.EXP);166 mathField.pressKey(Keys.LEFT_PAREN);167 const cursor = mathField.pressKey('NUM_3');168 assert.equal(cursor.context, CursorContexts.IN_PARENS);169 });170 it('should defer to the nearest parent (2)', () => {171 // Nest fractions, and put cursor in the denominator of the fraction172 // in the numerator.173 mathField.pressKey(Keys.FRAC_INCLUSIVE);174 mathField.pressKey(Keys.FRAC_INCLUSIVE);175 const cursor = mathField.pressKey(Keys.RIGHT);176 assert.equal(cursor.context, CursorContexts.IN_DENOMINATOR);177 });178 });...
control_mapping.py
Source:control_mapping.py
1import time2from win32_utils.directkeys import *3from win32_utils.keyboard_simulation import Simulate_Keyboard4def defense():5 Simulate_Keyboard.press_key('l')6 time.sleep(0.05)7 Simulate_Keyboard.release_key('l')8 # time.sleep(0.1)9def attack():10 PressKey(J)11 time.sleep(0.05)12 ReleaseKey(J)13 # time.sleep(0.1)14def go_forward():15 PressKey(W)16 time.sleep(0.4)17 ReleaseKey(W)18def go_back():19 PressKey(S)20 time.sleep(0.4)21 ReleaseKey(S)22def go_left():23 PressKey(A)24 time.sleep(0.4)25 ReleaseKey(A)26def go_right():27 PressKey(D)28 time.sleep(0.4)29 ReleaseKey(D)30def jump():31 Simulate_Keyboard.press_key('spacebar')32 time.sleep(0.1)33 Simulate_Keyboard.release_key('spacebar')34 # time.sleep(0.1)35def dodge(): # éªé¿36 # PressKey(Q)37 Simulate_Keyboard.press_key('alt')38 time.sleep(0.1)39 Simulate_Keyboard.release_key('alt')40 # time.sleep(0.1)41def dodge_right(): # éªé¿42 # PressKey(Q)43 Simulate_Keyboard.press_key('alt')44 Simulate_Keyboard.press_key('d')45 time.sleep(0.1)46 Simulate_Keyboard.release_key('d')47 Simulate_Keyboard.release_key('alt')48 # time.sleep(0.1)49def dodge_left(): # éªé¿50 # PressKey(Q)51 Simulate_Keyboard.press_key('alt')52 Simulate_Keyboard.press_key('a')53 time.sleep(0.1)54 Simulate_Keyboard.release_key('a')55 Simulate_Keyboard.release_key('alt')56 # time.sleep(0.1)57def dodge_back(): # éªé¿58 # PressKey(Q)59 Simulate_Keyboard.press_key('alt')60 Simulate_Keyboard.release_key('s')61 time.sleep(0.1)62 Simulate_Keyboard.release_key('s')63 Simulate_Keyboard.release_key('alt')64 # time.sleep(0.1)65def dodge_forward(): # éªé¿66 # PressKey(Q)67 Simulate_Keyboard.press_key('alt')68 Simulate_Keyboard.release_key('w')69 time.sleep(0.1)70 Simulate_Keyboard.release_key('w')71 Simulate_Keyboard.release_key('alt')72 # time.sleep(0.1)73def lock_vision():74 PressKey(V)75 time.sleep(0.3)76 ReleaseKey(V)77 time.sleep(0.1)78def recover():79 Simulate_Keyboard.press_key("r")80 time.sleep(0.3)81 Simulate_Keyboard.release_key("r")82def go_forward_QL(t):83 PressKey(W)84 time.sleep(t)85 ReleaseKey(W)86def turn_left(t):87 PressKey(left)88 time.sleep(t)89 ReleaseKey(left)90def turn_up(t):91 PressKey(up)92 time.sleep(t)93 ReleaseKey(up)94def turn_right(t):95 PressKey(right)96 time.sleep(t)97 ReleaseKey(right)98def F_go():99 PressKey(F)100 time.sleep(0.5)101 ReleaseKey(F)102# comb103def jump_forward(t):104 PressKey(W)105 time.sleep(t)106 Simulate_Keyboard.press_key('spacebar')107 Simulate_Keyboard.release_key('spacebar')108 ReleaseKey(W)109def jump_back(t):110 PressKey(S)111 time.sleep(t)112 Simulate_Keyboard.press_key('spacebar')113 Simulate_Keyboard.release_key('spacebar')114 ReleaseKey(S)115def jump_left(t):116 PressKey(A)117 time.sleep(t)118 Simulate_Keyboard.press_key('spacebar')119 Simulate_Keyboard.release_key('spacebar')120 ReleaseKey(A)121def jump_right(t):122 PressKey(D)123 time.sleep(t)124 Simulate_Keyboard.press_key('spacebar')125 Simulate_Keyboard.release_key('spacebar')126 ReleaseKey(D)127def press_esc():128 PressKey(esc)129 time.sleep(0.3)130 ReleaseKey(esc)131def nonAction():132 pass133from win32_utils.keyboard_simulation import Simulate_Keyboard134def interrupt_game():135 Simulate_Keyboard.press_key('esc')136 return 1137def continue_game(interrupt_state):138 if interrupt_state != 0:139 Simulate_Keyboard.release_key('esc')140 return 0141 return interrupt_state142# def dead():143# PressKey(M)144# time.sleep(0.5)...
index.ts
Source:index.ts
1export enum KEYS {2 ARROW_UP,3 ARROW_DOWN,4 ARROW_LEFT,5 ARROW_RIGHT,6 NO_KEY7}8export interface Command {9 execute(): void;10 undo(): KEYS;11}12export class PressKey {13 private _currentKey: KEYS = KEYS.NO_KEY;14 moveUp() {15 this._currentKey = KEYS.ARROW_UP;16 console.log("Key UP Pressed");17 }18 moveDown() {19 this._currentKey = KEYS.ARROW_DOWN;20 console.log("Key DOWN Pressed");21 }22 moveLeft() {23 this._currentKey = KEYS.ARROW_LEFT;24 console.log("Key LEFT Pressed");25 }26 moveRight() {27 this._currentKey = KEYS.ARROW_RIGHT;28 console.log("Key RIGHT Pressed");29 }30 get currentKey(): KEYS {31 return this._currentKey;32 }33}34export class NoCommand implements Command {35 execute() {}36 undo() {37 return KEYS.NO_KEY;38 }39}40export class MoveLeftCommand implements Command {41 private pressKey: PressKey;42 private previousKey: KEYS;43 constructor(pressKey: PressKey) {44 this.pressKey = pressKey;45 }46 execute() {47 this.previousKey = pressKey.currentKey;48 this.pressKey.moveLeft();49 }50 undo(): KEYS {51 return this.previousKey;52 }53}54export class MoveUpCommand implements Command {55 private pressKey: PressKey;56 private previousKey: KEYS;57 constructor(pressKey: PressKey) {58 this.pressKey = pressKey;59 }60 execute() {61 this.previousKey = pressKey.currentKey;62 this.pressKey.moveUp();63 }64 undo(): KEYS {65 return this.previousKey;66 }67}68export class MoveDownCommand implements Command {69 private pressKey: PressKey;70 private previousKey: KEYS;71 constructor(pressKey: PressKey) {72 this.pressKey = pressKey;73 }74 execute() {75 this.previousKey = pressKey.currentKey;76 this.pressKey.moveDown();77 }78 undo(): KEYS {79 return this.previousKey;80 }81}82export class KeyBoard {83 private doCommands: Map<KEYS, Command> = new Map();84 private currentCommand: Command;85 constructor() {86 this.initCommands();87 }88 private initCommands() {89 const noCommand = new NoCommand();90 this.doCommands.set(KEYS.ARROW_UP, noCommand);91 this.doCommands.set(KEYS.ARROW_DOWN, noCommand);92 this.doCommands.set(KEYS.ARROW_LEFT, noCommand);93 this.doCommands.set(KEYS.ARROW_RIGHT, noCommand);94 this.doCommands.set(KEYS.NO_KEY, noCommand);95 }96 setCommand(key: KEYS, doCommand: Command) {97 this.doCommands.set(key, doCommand);98 }99 onKeyPressed(key: KEYS) {100 this.doCommands.get(key).execute();101 this.currentCommand = this.doCommands.get(key);102 }103 undoKeyPressed() {104 const prevKey = this.currentCommand.undo();105 console.log(`Undoing...returning to key ${prevKey}`);106 this.doCommands.get(prevKey).execute();107 }108 toString() {109 console.group(`---Commands---`);110 this.doCommands.forEach(v => {111 console.log(v);112 });113 console.groupEnd();114 }115}116const pressKey: PressKey = new PressKey();117const moveUpCommand: Command = new MoveUpCommand(pressKey);118const moveDownCommand: Command = new MoveDownCommand(pressKey);119const moveLeftCommand: Command = new MoveLeftCommand(pressKey);120const keyboard = new KeyBoard();121keyboard.setCommand(KEYS.ARROW_UP, moveUpCommand);122keyboard.setCommand(KEYS.ARROW_DOWN, moveDownCommand);123keyboard.setCommand(KEYS.ARROW_LEFT, moveLeftCommand);124keyboard.toString();125keyboard.onKeyPressed(KEYS.ARROW_UP);126keyboard.onKeyPressed(KEYS.ARROW_LEFT);127keyboard.undoKeyPressed();128keyboard.onKeyPressed(KEYS.ARROW_LEFT);129keyboard.onKeyPressed(KEYS.ARROW_DOWN);...
autoBot.py
Source:autoBot.py
...54 ii_ = Input_I()55 ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra) )56 x = Input( ctypes.c_ulong(1), ii_ )57 ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))58def pressKey(key):59 PressKey(key)60 time.sleep(1)61 ReleaseKey(key)62 time.sleep(1)63def pattern_1():64 pressKey(LEFT)65 pressKey(LEFT)66 pressKey(LCTRL)67 pressKey(LCTRL)68 pressKey(LEFT)69 pressKey(LEFT)70 pressKey(W)71 pressKey(A)72 pressKey(RIGHT)73 pressKey(RIGHT)74 pressKey(D)75 pressKey(S)76def pattern_2():77 pressKey(LEFT)78 pressKey(LEFT)79 pressKey(D)80 pressKey(A)81 pressKey(LEFT)82 pressKey(LEFT)83 pressKey(W)84 pressKey(S) 85 pressKey(RIGHT)86 pressKey(RIGHT)87 pressKey(LCTRL)88 pressKey(LCTRL)89# directx scan codes90# http://www.gamespp.com/directx/directInputKeyboardScanCodes.html91if __name__ == '__main__':92 93 if(hllDll.GetKeyState(VK_NUMLOCK)):94 pressKey(NUMLCK)95 while (True):96 pattern_1()97 pattern_2()98 99#https://guidedhacking.com/threads/creating-a-c-bot-that-sends-keystrokes-and-mouse-movement.11837/100#https://guidedhacking.com/threads/maplestory-packet-hack-ngs-bypass.14202/...
drive.py
Source:drive.py
1from grabscreen import grabscreen2import torch3import numpy as np4from grabkeys import key_check5from grabscreen import grabscreen6import cv27import time8from directkeys import PressKey,ReleaseKey, W, A, S, D9import random10weights = np.array([1, 0.4, 0.5, 0.5, 0.5, 0.5, 1.5, 0.5, 0.2])11w = [1,0,0,0,0,0,0,0,0]12s = [0,1,0,0,0,0,0,0,0]13a = [0,0,1,0,0,0,0,0,0]14d = [0,0,0,1,0,0,0,0,0]15wa = [0,0,0,0,1,0,0,0,0]16wd = [0,0,0,0,0,1,0,0,0]17sa = [0,0,0,0,0,0,1,0,0]18sd = [0,0,0,0,0,0,0,1,0]19def straight():20 PressKey(W)21 ReleaseKey(A)22 ReleaseKey(D)23 ReleaseKey(S)24def left():25 PressKey(A)26 ReleaseKey(W)27 ReleaseKey(D)28 ReleaseKey(S)29def right():30 PressKey(D)31 ReleaseKey(A)32 ReleaseKey(W)33 ReleaseKey(S)34def reverse():35 PressKey(S)36 ReleaseKey(A)37 ReleaseKey(W)38 ReleaseKey(D)39def forward_left():40 PressKey(W)41 PressKey(A)42 ReleaseKey(D)43 ReleaseKey(S)44def forward_right():45 PressKey(W)46 PressKey(D)47 ReleaseKey(A)48 ReleaseKey(S)49def reverse_left():50 PressKey(S)51 PressKey(A)52 ReleaseKey(W)53 ReleaseKey(D)54def reverse_right():55 PressKey(S)56 PressKey(D)57 ReleaseKey(W)58 ReleaseKey(A)59def no_keys():60 PressKey(W)61 ReleaseKey(A)62 ReleaseKey(S)63 ReleaseKey(D)64model = torch.load('driveNet-ResNetMini.pth')65def main():66 67 paused = False68 while(True):69 if not paused:70 screen = grabscreen()71 prediction = model(torch.tensor(np.expand_dims(screen.reshape(3, 128, 128), axis=0)).float())72 #prediction = model(torch.tensor([screen.reshape(3, 128 ,128)]))73 prediction = prediction.detach().numpy()74 prediction = prediction * np.array([1.3, 1, 1, 1, 1, 1, 1, 1, 1])75 #prediction = prediction * np.array([4.5, 0.1, 0.1, 0.1, 1.8, 1.8, 0.5, 0.5, 0.2])76 print(np.argmax(prediction))77 if np.argmax(prediction) == np.argmax(w):78 straight()79 elif np.argmax(prediction) == np.argmax(s):80 reverse()81 if np.argmax(prediction) == np.argmax(a):82 left()83 if np.argmax(prediction) == np.argmax(d):84 right()85 if np.argmax(prediction) == np.argmax(wa):86 forward_left()87 if np.argmax(prediction) == np.argmax(wd):88 forward_right()89 if np.argmax(prediction) == np.argmax(sa):90 reverse_left()91 if np.argmax(prediction) == np.argmax(sd):92 reverse_right()...
Using AI Code Generation
1const { openBrowser, goto, write, press, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await goto("google.com");6 await write("Taiko", into("Search"));7 await press("Enter");8 } catch (e) {
Using AI Code Generation
1const { openBrowser, goto, press, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await press("Enter");7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13`type(text, options)`14const { openBrowser, goto, textBox, write, closeBrowser } = require('taiko');15(async () => {16 try {17 await openBrowser();18 await goto("google.com");19 await write("Taiko", into(textBox("Search")));20 } catch (e) {21 console.error(e);22 } finally {23 await closeBrowser();24 }25})();26`clear(options)`27const { openBrowser, goto, textBox, write, clear, closeBrowser } = require('taiko');28(async () => {29 try {30 await openBrowser();31 await goto("google.com");32 await write("Taiko", into(textBox("Search")));33 await clear(textBox("Search"));34 } catch (e) {35 console.error(e);36 } finally {37 await closeBrowser();38 }39})();40`focus(selector)`
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, press } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await press("Enter");7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, closeBrowser, pressKeys } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await goto("google.com");18 await pressKeys("Ctrl+Shift+T");19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, closeBrowser, rightClick } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await goto("google.com");30 await rightClick();31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();37const { openBrowser, goto, closeBrowser, scrollDown } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await goto("google.com");42 await scrollDown(100);43 } catch (e) {44 console.error(e);45 } finally {46 await closeBrowser();47 }48})();49const { openBrowser, goto, closeBrowser, scrollUp } = require('taiko');50(async () => {51 try {52 await openBrowser();
Using AI Code Generation
1const { openBrowser, goto, write, press, click, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko");6 await press("Enter");7 await click("Taiko");8 } catch (error) {9 console.error(error);10 } finally {11 await closeBrowser();12 }13})();
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, press, pressKey } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await press('Enter');
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, press, write, $, click, waitFor, link, listItem } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko");6 await press("Enter");7 await click(link("Taiko - Test Automation Framework for Modern Web Applications"));8 await waitFor(5000);9 await click(listItem("Getting Started"));10 await waitFor(5000);11 await click(link("Installation"));12 await waitFor(5000);13 await click(link("Installi
Using AI Code Generation
1(async () => {2 await openBrowser();3 await goto("google.com");4 await write("Taiko");5 await pressKey("Enter");6 await closeBrowser();7})();8(async () => {9 await openBrowser();10 await goto("google.com");11 await write("Taiko");12 await press("Enter");13 await closeBrowser();14})();15(async () => {16 await openBrowser();17 await goto("google.com");18 await focus(textBox("Search"));19 await write("Taiko");20 await press("Enter");21 await closeBrowser();22})();23(async () => {24 await openBrowser();25 await goto("google.com");26 await hover(textBox("Search"));27 await write("Taiko");28 await press("Enter");29 await closeBrowser();30})();31(async () => {32 await openBrowser();33 await goto("google.com");34 await write("Taiko");35 await clear(textBox("Search"));36 await write("Taiko");37 await press("Enter");38 await closeBrowser();39})();40(async () => {41 await openBrowser();42 await goto("google.com");43 await attach("path/to/file", to(textBox("Search")));44 await write("Taiko");45 await press("Enter
Using AI Code Generation
1const { press, openBrowser, goto, write, closeBrowser, $, click, waitFor, pressKey, into, textBox, toRightOf, toLeftOf, above, below, attach, to, link, text, button, image, focus, evaluate, intercept, emulate, setConfig, highlight, screenshot, scrollDown, scrollUp, scrollTo, scrollRight, scrollLeft, mouseAction, doubleClick, rightClick, hover, dragAndDrop, accept, dismiss, clear, reload, navigateBack, navigateForward, title, currentURL, toRightOf, toLeftOf, above, below, link, text, button, image, focus, evaluate, intercept, emulate, setConfig, highlight, screenshot, scrollDown, scrollUp, scrollTo, scrollRight, scrollLeft, mouseAction, doubleClick, rightClick, hover, dragAndDrop, accept, dismiss, clear, reload, navigateBack, navigateForward, title, currentURL } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko", into(textBox(toRightOf("Search"))));6 await press("Enter");7 await click("Taiko");8 await waitFor(5000);9 await pressKey('ArrowDown');10 await pressKey('ArrowDown');
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!!