How to use createCommand method in Testcafe

Best JavaScript code snippet using testcafe

test-run-commands-test.js

Source:test-run-commands-test.js Github

copy

Full Screen

...59 meta: true60 }61 }62 };63 let command = createCommand(commandObj);64 expect(JSON.parse(JSON.stringify(command))).eql({65 type: TYPE.click,66 selector: makeSelector('#yo'),67 options: {68 offsetX: 23,69 offsetY: 32,70 caretPos: 2,71 speed: 0.5,72 modifiers: {73 ctrl: true,74 alt: true,75 shift: true,76 meta: true77 }78 }79 });80 commandObj = {81 type: TYPE.click,82 selector: '#yo'83 };84 command = createCommand(commandObj);85 expect(JSON.parse(JSON.stringify(command))).eql({86 type: TYPE.click,87 selector: makeSelector('#yo'),88 options: {89 offsetX: null,90 offsetY: null,91 caretPos: null,92 speed: null,93 modifiers: {94 ctrl: false,95 alt: false,96 shift: false,97 meta: false98 }99 }100 });101 });102 it('Should create RightClickCommand from object', () => {103 let commandObj = {104 type: TYPE.rightClick,105 selector: '#yo',106 yo: 'test',107 options: {108 offsetX: 23,109 offsetY: 32,110 caretPos: 2,111 speed: 0.5,112 dummy: 'yo',113 modifiers: {114 ctrl: true,115 shift: false,116 dummy: 'yo',117 alt: true,118 meta: false119 }120 }121 };122 let command = createCommand(commandObj);123 expect(JSON.parse(JSON.stringify(command))).eql({124 type: TYPE.rightClick,125 selector: makeSelector('#yo'),126 options: {127 offsetX: 23,128 offsetY: 32,129 caretPos: 2,130 speed: 0.5,131 modifiers: {132 ctrl: true,133 alt: true,134 shift: false,135 meta: false136 }137 }138 });139 commandObj = {140 type: TYPE.rightClick,141 selector: '#yo'142 };143 command = createCommand(commandObj);144 expect(JSON.parse(JSON.stringify(command))).eql({145 type: TYPE.rightClick,146 selector: makeSelector('#yo'),147 options: {148 offsetX: null,149 offsetY: null,150 caretPos: null,151 speed: null,152 modifiers: {153 ctrl: false,154 alt: false,155 shift: false,156 meta: false157 }158 }159 });160 });161 it('Should create DoubleClickCommand from object', () => {162 let commandObj = {163 type: TYPE.doubleClick,164 selector: '#yo',165 yo: 'test',166 options: {167 offsetX: 23,168 offsetY: 32,169 caretPos: 2,170 speed: 0.5,171 dummy: 'yo',172 modifiers: {173 ctrl: true,174 shift: false,175 dummy: 'yo',176 alt: true,177 meta: false178 }179 }180 };181 let command = createCommand(commandObj);182 expect(JSON.parse(JSON.stringify(command))).eql({183 type: TYPE.doubleClick,184 selector: makeSelector('#yo'),185 options: {186 offsetX: 23,187 offsetY: 32,188 caretPos: 2,189 speed: 0.5,190 modifiers: {191 ctrl: true,192 alt: true,193 shift: false,194 meta: false195 }196 }197 });198 commandObj = {199 type: TYPE.doubleClick,200 selector: '#yo'201 };202 command = createCommand(commandObj);203 expect(JSON.parse(JSON.stringify(command))).eql({204 type: TYPE.doubleClick,205 selector: makeSelector('#yo'),206 options: {207 offsetX: null,208 offsetY: null,209 caretPos: null,210 speed: null,211 modifiers: {212 ctrl: false,213 alt: false,214 shift: false,215 meta: false216 }217 }218 });219 });220 it('Should create HoverCommand from object', () => {221 let commandObj = {222 type: TYPE.hover,223 selector: '#yo',224 yo: 'test',225 options: {226 offsetX: 23,227 offsetY: 32,228 caretPos: 2,229 speed: 0.5,230 dummy: 'yo',231 modifiers: {232 ctrl: true,233 shift: false,234 dummy: 'yo',235 alt: true,236 meta: false237 }238 }239 };240 let command = createCommand(commandObj);241 expect(JSON.parse(JSON.stringify(command))).eql({242 type: TYPE.hover,243 selector: makeSelector('#yo'),244 options: {245 offsetX: 23,246 offsetY: 32,247 speed: 0.5,248 modifiers: {249 ctrl: true,250 alt: true,251 shift: false,252 meta: false253 }254 }255 });256 commandObj = {257 type: TYPE.hover,258 selector: '#yo'259 };260 command = createCommand(commandObj);261 expect(JSON.parse(JSON.stringify(command))).eql({262 type: TYPE.hover,263 selector: makeSelector('#yo'),264 options: {265 offsetX: null,266 offsetY: null,267 speed: null,268 modifiers: {269 ctrl: false,270 alt: false,271 shift: false,272 meta: false273 }274 }275 });276 });277 it('Should create DragCommand from object', () => {278 let commandObj = {279 type: TYPE.drag,280 selector: '#yo',281 dragOffsetX: 10,282 dragOffsetY: -15,283 dummy: false,284 options: {285 offsetX: 23,286 offsetY: 32,287 caretPos: 2,288 speed: 0.5,289 dummy: 1,290 modifiers: {291 ctrl: true,292 shift: false,293 dummy: 'yo',294 alt: true,295 meta: false296 }297 }298 };299 let command = createCommand(commandObj);300 expect(JSON.parse(JSON.stringify(command))).eql({301 type: TYPE.drag,302 selector: makeSelector('#yo'),303 dragOffsetX: 10,304 dragOffsetY: -15,305 options: {306 offsetX: 23,307 offsetY: 32,308 speed: 0.5,309 modifiers: {310 ctrl: true,311 alt: true,312 shift: false,313 meta: false314 }315 }316 });317 commandObj = {318 type: TYPE.drag,319 selector: '#yo',320 dragOffsetX: 10,321 dragOffsetY: -15322 };323 command = createCommand(commandObj);324 expect(JSON.parse(JSON.stringify(command))).eql({325 type: TYPE.drag,326 selector: makeSelector('#yo'),327 dragOffsetX: 10,328 dragOffsetY: -15,329 options: {330 offsetX: null,331 offsetY: null,332 speed: null,333 modifiers: {334 ctrl: false,335 alt: false,336 shift: false,337 meta: false338 }339 }340 });341 });342 it('Should create DragToElementCommand from object', () => {343 let commandObj = {344 type: TYPE.dragToElement,345 selector: '#yo',346 destinationSelector: '#destination',347 dragOffsetX: 10,348 options: {349 offsetX: 23,350 offsetY: 32,351 destinationOffsetX: 12,352 destinationOffsetY: 21,353 caretPos: 2,354 speed: 0.5,355 dummy: 1,356 modifiers: {357 ctrl: true,358 shift: false,359 dummy: 'yo',360 alt: true,361 meta: false362 }363 }364 };365 let command = createCommand(commandObj);366 expect(JSON.parse(JSON.stringify(command))).eql({367 type: TYPE.dragToElement,368 selector: makeSelector('#yo'),369 destinationSelector: makeSelector('#destination'),370 options: {371 offsetX: 23,372 offsetY: 32,373 destinationOffsetX: 12,374 destinationOffsetY: 21,375 speed: 0.5,376 modifiers: {377 ctrl: true,378 alt: true,379 shift: false,380 meta: false381 }382 }383 });384 commandObj = {385 type: TYPE.dragToElement,386 selector: '#yo',387 destinationSelector: '#destination'388 };389 command = createCommand(commandObj);390 expect(JSON.parse(JSON.stringify(command))).eql({391 type: TYPE.dragToElement,392 selector: makeSelector('#yo'),393 destinationSelector: makeSelector('#destination'),394 options: {395 offsetX: null,396 offsetY: null,397 destinationOffsetX: null,398 destinationOffsetY: null,399 speed: null,400 modifiers: {401 ctrl: false,402 alt: false,403 shift: false,404 meta: false405 }406 }407 });408 });409 it('Should create TypeTextCommand from object', () => {410 let commandObj = {411 type: TYPE.typeText,412 selector: '#yo',413 text: 'testText',414 yo: 'test',415 options: {416 offsetX: 23,417 offsetY: 32,418 caretPos: 2,419 speed: 0.5,420 dummy: 'yo',421 replace: true,422 paste: true,423 modifiers: {424 ctrl: true,425 shift: false,426 dummy: 'yo',427 alt: false,428 meta: false429 }430 }431 };432 let command = createCommand(commandObj);433 expect(JSON.parse(JSON.stringify(command))).eql({434 type: TYPE.typeText,435 selector: makeSelector('#yo'),436 text: 'testText',437 options: {438 offsetX: 23,439 offsetY: 32,440 caretPos: 2,441 speed: 0.5,442 replace: true,443 paste: true,444 modifiers: {445 ctrl: true,446 alt: false,447 shift: false,448 meta: false449 }450 }451 });452 commandObj = {453 type: TYPE.typeText,454 selector: '#yo',455 text: 'testText'456 };457 command = createCommand(commandObj);458 expect(JSON.parse(JSON.stringify(command))).eql({459 type: TYPE.typeText,460 selector: makeSelector('#yo'),461 text: 'testText',462 options: {463 offsetX: null,464 offsetY: null,465 caretPos: null,466 speed: null,467 replace: false,468 paste: false,469 modifiers: {470 ctrl: false,471 alt: false,472 shift: false,473 meta: false474 }475 }476 });477 });478 it('Should create SelectTextCommand from object', () => {479 let commandObj = {480 type: TYPE.selectText,481 selector: '#yo',482 startPos: 1,483 endPos: 2,484 yo: 'test',485 options: {486 offsetX: 23,487 dummy: 'yo',488 speed: 0.5489 }490 };491 let command = createCommand(commandObj);492 expect(JSON.parse(JSON.stringify(command))).eql({493 type: TYPE.selectText,494 selector: makeSelector('#yo'),495 startPos: 1,496 endPos: 2,497 options: {498 speed: 0.5499 }500 });501 commandObj = {502 type: TYPE.selectText,503 selector: '#yo'504 };505 command = createCommand(commandObj);506 expect(JSON.parse(JSON.stringify(command))).eql({507 type: TYPE.selectText,508 selector: makeSelector('#yo'),509 startPos: null,510 endPos: null,511 options: {512 speed: null513 }514 });515 });516 it('Should create SelectTextAreaContentCommand from object', () => {517 let commandObj = {518 type: TYPE.selectTextAreaContent,519 selector: '#yo',520 startLine: 0,521 startPos: 1,522 endLine: 2,523 endPos: 3,524 yo: 5,525 options: {526 offsetX: 23,527 dummy: 'yo',528 speed: 0.5529 }530 };531 let command = createCommand(commandObj);532 expect(JSON.parse(JSON.stringify(command))).eql({533 type: TYPE.selectTextAreaContent,534 selector: makeSelector('#yo'),535 startLine: 0,536 startPos: 1,537 endLine: 2,538 endPos: 3,539 options: {540 speed: 0.5541 }542 });543 commandObj = {544 type: TYPE.selectTextAreaContent,545 selector: '#yo'546 };547 command = createCommand(commandObj);548 expect(JSON.parse(JSON.stringify(command))).eql({549 type: TYPE.selectTextAreaContent,550 selector: makeSelector('#yo'),551 startLine: null,552 startPos: null,553 endLine: null,554 endPos: null,555 options: {556 speed: null557 }558 });559 });560 it('Should create SelectEditableContentCommand from object', () => {561 let commandObj = {562 type: TYPE.selectEditableContent,563 selector: '#yo',564 startSelector: '#node1',565 endSelector: '#node2',566 yo: 'test',567 options: {568 offsetX: 23,569 dummy: 'yo',570 speed: 0.5571 }572 };573 let command = createCommand(commandObj);574 expect(JSON.parse(JSON.stringify(command))).eql({575 type: TYPE.selectEditableContent,576 startSelector: makeSelector('#node1'),577 endSelector: makeSelector('#node2'),578 options: {579 speed: 0.5580 }581 });582 commandObj = {583 type: TYPE.selectEditableContent,584 selector: '#yo',585 startSelector: '#node1'586 };587 command = createCommand(commandObj);588 expect(JSON.parse(JSON.stringify(command))).eql({589 type: TYPE.selectEditableContent,590 startSelector: makeSelector('#node1'),591 endSelector: null,592 options: {593 speed: null594 }595 });596 });597 it('Should create PressKeyCommand from object', () => {598 const commandObj = {599 type: TYPE.pressKey,600 selector: '#yo',601 keys: 'a+b c',602 yo: 'test',603 options: {604 offsetX: 23,605 offsetY: 32,606 dummy: 'yo',607 speed: 0.5,608 modifiers: {609 ctrl: true,610 shift: false,611 dummy: 'yo',612 alt: false,613 meta: false614 }615 }616 };617 const command = createCommand(commandObj);618 expect(JSON.parse(JSON.stringify(command))).eql({619 type: TYPE.pressKey,620 keys: 'a+b c',621 options: {622 speed: 0.5623 }624 });625 });626 it('Should create WaitCommand from object', () => {627 const commandObj = {628 type: TYPE.wait,629 timeout: 1000630 };631 const command = createCommand(commandObj);632 expect(JSON.parse(JSON.stringify(command))).eql({633 type: TYPE.wait,634 timeout: 1000635 });636 });637 it('Should create NavigateToCommand from object', () => {638 const commandObj = {639 type: TYPE.navigateTo,640 url: 'localhost',641 stateSnapshot: 'stateSnapshot',642 forceReload: true643 };644 const command = createCommand(commandObj);645 expect(JSON.parse(JSON.stringify(command))).eql({646 type: TYPE.navigateTo,647 url: 'localhost',648 stateSnapshot: 'stateSnapshot',649 forceReload: true650 });651 });652 it('Should create SetFilesToUploadCommand from object', function () {653 let commandObj = {654 type: TYPE.setFilesToUpload,655 selector: '#yo',656 filePath: '/test/path',657 dummy: 'test',658 options: {659 dummy: 'yo'660 }661 };662 let command = createCommand(commandObj);663 expect(JSON.parse(JSON.stringify(command))).eql({664 type: TYPE.setFilesToUpload,665 selector: makeSelector('#yo', true),666 filePath: '/test/path'667 });668 commandObj = {669 type: TYPE.setFilesToUpload,670 selector: '#yo',671 filePath: ['/test/path/1', '/test/path/2'],672 dummy: 'test',673 options: {674 dummy: 'yo'675 }676 };677 command = createCommand(commandObj);678 expect(JSON.parse(JSON.stringify(command))).eql({679 type: TYPE.setFilesToUpload,680 selector: makeSelector('#yo', true),681 filePath: ['/test/path/1', '/test/path/2']682 });683 });684 it('Should create ClearUploadCommand from object', function () {685 const commandObj = {686 type: TYPE.clearUpload,687 selector: '#yo',688 dummy: 'test',689 options: {690 dummy: 'yo'691 }692 };693 const command = createCommand(commandObj);694 expect(JSON.parse(JSON.stringify(command))).eql({695 type: TYPE.clearUpload,696 selector: makeSelector('#yo', true)697 });698 });699 it('Should create TakeScreenshotCommand from object', function () {700 let commandObj = {701 type: TYPE.takeScreenshot,702 selector: '#yo',703 path: 'custom',704 dummy: 'test',705 fullPage: true,706 options: {707 dummy: 'yo'708 }709 };710 let command = createCommand(commandObj);711 expect(JSON.parse(JSON.stringify(command))).eql({712 type: TYPE.takeScreenshot,713 markData: '',714 markSeed: null,715 path: 'custom',716 fullPage: true717 });718 commandObj = {719 type: TYPE.takeScreenshot,720 selector: '#yo',721 dummy: 'test',722 fullPage: void 0,723 options: {724 dummy: 'yo'725 }726 };727 command = createCommand(commandObj);728 expect(JSON.parse(JSON.stringify(command))).eql({729 type: TYPE.takeScreenshot,730 markData: '',731 markSeed: null,732 path: ''733 });734 });735 it('Should create TakeElementScreenshotCommand from object', function () {736 const commandObj = {737 type: TYPE.takeElementScreenshot,738 selector: '#yo',739 path: 'custom',740 dummy: 'test',741 options: {742 crop: {743 left: 50,744 top: 13745 },746 modifiers: {747 alt: true748 }749 }750 };751 const command = createCommand(commandObj);752 expect(JSON.parse(JSON.stringify(command))).eql({753 type: TYPE.takeElementScreenshot,754 markData: '',755 markSeed: null,756 selector: makeSelector('#yo'),757 path: 'custom',758 options: {759 scrollTargetX: null,760 scrollTargetY: null,761 speed: null,762 crop: {763 left: 50,764 right: null,765 top: 13,766 bottom: null767 },768 includeMargins: false,769 includeBorders: true,770 includePaddings: true771 }772 });773 });774 it('Should create ResizeWindowCommand from object', function () {775 const commandObj = {776 type: TYPE.resizeWindow,777 selector: '#yo',778 dummy: 'test',779 width: 100,780 height: 100,781 options: {782 dummy: 'yo'783 }784 };785 const command = createCommand(commandObj);786 expect(JSON.parse(JSON.stringify(command))).eql({787 type: TYPE.resizeWindow,788 width: 100,789 height: 100790 });791 });792 it('Should create ResizeWindowToFitDeviceCommand from object', function () {793 let commandObj = {794 type: TYPE.resizeWindowToFitDevice,795 selector: '#yo',796 dummy: 'test',797 device: 'iPhone',798 options: {799 dummy: 'yo',800 portraitOrientation: true801 }802 };803 let command = createCommand(commandObj);804 expect(JSON.parse(JSON.stringify(command))).eql({805 type: TYPE.resizeWindowToFitDevice,806 device: 'iPhone',807 options: { portraitOrientation: true }808 });809 commandObj = {810 type: TYPE.resizeWindowToFitDevice,811 device: 'iPhone'812 };813 command = createCommand(commandObj);814 expect(JSON.parse(JSON.stringify(command))).eql({815 type: TYPE.resizeWindowToFitDevice,816 device: 'iPhone',817 options: { portraitOrientation: false }818 });819 });820 it('Should create SwitchToIframeCommand from object', function () {821 const commandObj = {822 type: TYPE.switchToIframe,823 selector: '#iframe'824 };825 const command = createCommand(commandObj);826 expect(JSON.parse(JSON.stringify(command))).eql({827 type: TYPE.switchToIframe,828 selector: makeSelector('#iframe')829 });830 });831 it('Should create SwitchToMainWindowCommand from object', function () {832 const commandObj = {833 type: TYPE.switchToMainWindow834 };835 const command = createCommand(commandObj);836 expect(JSON.parse(JSON.stringify(command))).eql({837 type: TYPE.switchToMainWindow838 });839 });840 it('Should create SetTestSpeedCommand from object', function () {841 const commandObj = {842 type: TYPE.setTestSpeed,843 speed: 0.5844 };845 const command = createCommand(commandObj);846 expect(JSON.parse(JSON.stringify(command))).eql({847 type: TYPE.setTestSpeed,848 speed: 0.5849 });850 });851 it('Should create SetPageLoadTimeoutCommand from object', function () {852 const commandObj = {853 type: TYPE.setPageLoadTimeout,854 duration: 3855 };856 const command = createCommand(commandObj);857 expect(JSON.parse(JSON.stringify(command))).eql({858 type: TYPE.setPageLoadTimeout,859 duration: 3860 });861 });862 it('Should create AssertionCommand from object', function () {863 let commandObj = {864 type: TYPE.assertion,865 assertionType: 'eql',866 actual: 1,867 expected: 0.2,868 expected2: 3.5,869 yo: 'test',870 message: 'ok',871 options: {872 offsetX: 23,873 timeout: 100874 }875 };876 let command = createCommand(commandObj);877 expect(JSON.parse(JSON.stringify(command))).eql({878 type: TYPE.assertion,879 assertionType: 'eql',880 actual: 1,881 expected: 0.2,882 expected2: 3.5,883 message: 'ok',884 options: {885 timeout: 100,886 allowUnawaitedPromise: false887 }888 });889 commandObj = {890 type: TYPE.assertion,891 assertionType: 'ok',892 actual: 1893 };894 command = createCommand(commandObj);895 expect(JSON.parse(JSON.stringify(command))).eql({896 type: TYPE.assertion,897 assertionType: 'ok',898 actual: 1,899 message: null,900 options: {901 allowUnawaitedPromise: false902 }903 });904 });905 it('Should create ExecuteExpressionCommand from object', function () {906 let commandObj = {907 type: TYPE.executeExpression,908 expression: 'js-expression',909 resultVariableName: 'variable'910 };911 let command = createCommand(commandObj);912 expect(JSON.parse(JSON.stringify(command))).eql({913 type: TYPE.executeExpression,914 expression: 'js-expression',915 resultVariableName: 'variable'916 });917 commandObj = {918 type: TYPE.executeExpression,919 expression: 'js-expression'920 };921 command = createCommand(commandObj);922 expect(JSON.parse(JSON.stringify(command))).eql({923 type: TYPE.executeExpression,924 expression: 'js-expression',925 resultVariableName: null926 });927 });928 it('Should process js expression as a Selector', function () {929 const commandObj = {930 type: TYPE.click,931 selector: {932 type: 'js-expr',933 value: "Selector('#yo')"934 }935 };936 const command = createCommand(commandObj);937 expect(JSON.parse(JSON.stringify(command))).eql({938 type: TYPE.click,939 selector: makeSelector('#yo'),940 options: {941 offsetX: null,942 offsetY: null,943 caretPos: null,944 speed: null,945 modifiers: {946 ctrl: false,947 alt: false,948 shift: false,949 meta: false950 }951 }952 });953 });954 it('Should process js expression as an assertion parameter', function () {955 const commandObj = {956 type: TYPE.assertion,957 assertionType: 'eql',958 actual: {959 type: 'js-expr',960 value: '1 + 2'961 },962 expected: 1963 };964 const command = createCommand(commandObj);965 expect(JSON.parse(JSON.stringify(command))).eql({966 type: TYPE.assertion,967 assertionType: 'eql',968 actual: 3,969 expected: 1,970 message: null,971 options: {972 allowUnawaitedPromise: false973 }974 });975 });976 it('Should create RecorderCommand from object', function () {977 let commandObj = {978 type: TYPE.recorder,979 subtype: 'test',980 options: {981 dummy: 'yo'982 }983 };984 let command = createCommand(commandObj);985 expect(JSON.parse(JSON.stringify(command))).eql({986 type: TYPE.recorder,987 subtype: 'test',988 forceExecutionInTopWindowOnly: false989 });990 commandObj = {991 type: TYPE.recorder,992 subtype: 'test',993 forceExecutionInTopWindowOnly: true,994 options: {995 dummy: 'yo'996 }997 };998 command = createCommand(commandObj);999 expect(JSON.parse(JSON.stringify(command))).eql({1000 type: TYPE.recorder,1001 subtype: 'test',1002 forceExecutionInTopWindowOnly: true1003 });1004 });1005 });1006 describe('Validation', function () {1007 it('Should validate СlickСommand', function () {1008 assertThrow(1009 function () {1010 return createCommand({1011 type: TYPE.click1012 });1013 },1014 {1015 isTestCafeError: true,1016 code: 'E23',1017 selectorName: 'selector',1018 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1019 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1020 callsite: null,1021 originError: null1022 }1023 );1024 assertThrow(1025 function () {1026 return createCommand({1027 type: TYPE.click,1028 selector: 11029 });1030 },1031 {1032 isTestCafeError: true,1033 code: 'E23',1034 selectorName: 'selector',1035 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1036 'node snapshot or a Promise returned by a Selector, but number was passed.',1037 callsite: null,1038 originError: null1039 }1040 );1041 assertThrow(1042 function () {1043 return createCommand({1044 type: TYPE.click,1045 selector: 'element',1046 options: 11047 });1048 },1049 {1050 isTestCafeError: true,1051 code: 'E14',1052 actualType: 'number',1053 callsite: null1054 }1055 );1056 assertThrow(1057 function () {1058 return createCommand({1059 type: TYPE.click,1060 selector: 'element',1061 options: {1062 offsetX: 'offsetX'1063 }1064 });1065 },1066 {1067 isTestCafeError: true,1068 code: 'E9',1069 optionName: 'offsetX',1070 actualValue: 'string',1071 callsite: null1072 }1073 );1074 assertThrow(1075 function () {1076 return createCommand({1077 type: TYPE.click,1078 selector: 'element',1079 options: {1080 offsetX: 10.51081 }1082 });1083 },1084 {1085 isTestCafeError: true,1086 code: 'E9',1087 optionName: 'offsetX',1088 actualValue: 10.5,1089 callsite: null1090 }1091 );1092 });1093 it('Should validate RightСlickСommand', function () {1094 assertThrow(1095 function () {1096 return createCommand({1097 type: TYPE.rightClick1098 });1099 },1100 {1101 isTestCafeError: true,1102 code: 'E23',1103 selectorName: 'selector',1104 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1105 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1106 callsite: null,1107 originError: null1108 }1109 );1110 assertThrow(1111 function () {1112 return createCommand({1113 type: TYPE.rightClick,1114 selector: true1115 });1116 },1117 {1118 isTestCafeError: true,1119 code: 'E23',1120 selectorName: 'selector',1121 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector,' +1122 ' node snapshot or a Promise returned by a Selector, but boolean was passed.',1123 callsite: null,1124 originError: null1125 }1126 );1127 assertThrow(1128 function () {1129 return createCommand({1130 type: TYPE.rightClick,1131 selector: 'element',1132 options: 'options'1133 });1134 },1135 {1136 isTestCafeError: true,1137 code: 'E14',1138 actualType: 'string',1139 callsite: null1140 }1141 );1142 assertThrow(1143 function () {1144 return createCommand({1145 type: TYPE.rightClick,1146 selector: 'element',1147 options: {1148 offsetX: false1149 }1150 });1151 },1152 {1153 isTestCafeError: true,1154 code: 'E9',1155 optionName: 'offsetX',1156 actualValue: 'boolean',1157 callsite: null1158 }1159 );1160 assertThrow(1161 function () {1162 return createCommand({1163 type: TYPE.rightClick,1164 selector: 'element',1165 options: {1166 modifiers: {1167 shift: 'true'1168 }1169 }1170 });1171 },1172 {1173 isTestCafeError: true,1174 code: 'E11',1175 optionName: 'modifiers.shift',1176 actualValue: 'string',1177 callsite: null1178 }1179 );1180 });1181 it('Should validate DoubleСlickСommand', function () {1182 assertThrow(1183 function () {1184 return createCommand({1185 type: TYPE.doubleClick1186 });1187 },1188 {1189 isTestCafeError: true,1190 code: 'E23',1191 selectorName: 'selector',1192 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1193 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1194 callsite: null,1195 originError: null1196 }1197 );1198 assertThrow(1199 function () {1200 return createCommand({1201 type: TYPE.doubleClick,1202 selector: true1203 });1204 },1205 {1206 isTestCafeError: true,1207 code: 'E23',1208 selectorName: 'selector',1209 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1210 'node snapshot or a Promise returned by a Selector, but boolean was passed.',1211 callsite: null,1212 originError: null1213 }1214 );1215 assertThrow(1216 function () {1217 return createCommand({1218 type: TYPE.doubleClick,1219 selector: 'element',1220 options: 11221 });1222 },1223 {1224 isTestCafeError: true,1225 code: 'E14',1226 actualType: 'number',1227 callsite: null1228 }1229 );1230 assertThrow(1231 function () {1232 return createCommand({1233 type: TYPE.doubleClick,1234 selector: 'element',1235 options: {1236 caretPos: '5'1237 }1238 });1239 },1240 {1241 isTestCafeError: true,1242 code: 'E10',1243 optionName: 'caretPos',1244 actualValue: 'string',1245 callsite: null1246 }1247 );1248 });1249 it('Should validate HoverСommand', function () {1250 assertThrow(1251 function () {1252 return createCommand({1253 type: TYPE.hover1254 });1255 },1256 {1257 isTestCafeError: true,1258 code: 'E23',1259 selectorName: 'selector',1260 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1261 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1262 callsite: null,1263 originError: null1264 }1265 );1266 assertThrow(1267 function () {1268 return createCommand({1269 type: TYPE.hover,1270 selector: 11271 });1272 },1273 {1274 isTestCafeError: true,1275 code: 'E23',1276 selectorName: 'selector',1277 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1278 'node snapshot or a Promise returned by a Selector, but number was passed.',1279 callsite: null,1280 originError: null1281 }1282 );1283 assertThrow(1284 function () {1285 return createCommand({1286 type: TYPE.hover,1287 selector: 'element',1288 options: true1289 });1290 },1291 {1292 isTestCafeError: true,1293 code: 'E14',1294 actualType: 'boolean',1295 callsite: null1296 }1297 );1298 assertThrow(1299 function () {1300 return createCommand({1301 type: TYPE.hover,1302 selector: 'element',1303 options: {1304 offsetX: 'offsetX'1305 }1306 });1307 },1308 {1309 isTestCafeError: true,1310 code: 'E9',1311 optionName: 'offsetX',1312 actualValue: 'string',1313 callsite: null1314 }1315 );1316 assertThrow(1317 function () {1318 return createCommand({1319 type: TYPE.hover,1320 selector: 'element',1321 options: {1322 offsetY: 1.011323 }1324 });1325 },1326 {1327 isTestCafeError: true,1328 code: 'E9',1329 optionName: 'offsetY',1330 actualValue: 1.01,1331 callsite: null1332 }1333 );1334 });1335 it('Should validate DragСommand', function () {1336 assertThrow(1337 function () {1338 return createCommand({1339 type: TYPE.drag1340 });1341 },1342 {1343 isTestCafeError: true,1344 code: 'E23',1345 selectorName: 'selector',1346 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1347 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1348 callsite: null,1349 originError: null1350 }1351 );1352 assertThrow(1353 function () {1354 return createCommand({1355 type: TYPE.drag,1356 selector: 11357 });1358 },1359 {1360 isTestCafeError: true,1361 code: 'E23',1362 selectorName: 'selector',1363 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1364 'node snapshot or a Promise returned by a Selector, but number was passed.',1365 callsite: null,1366 originError: null1367 }1368 );1369 assertThrow(1370 function () {1371 return createCommand({1372 type: TYPE.drag,1373 selector: 'element'1374 });1375 },1376 {1377 isTestCafeError: true,1378 code: 'E20',1379 argumentName: 'dragOffsetX',1380 actualValue: 'undefined',1381 callsite: null1382 }1383 );1384 assertThrow(1385 function () {1386 return createCommand({1387 type: TYPE.drag,1388 selector: 'element',1389 dragOffsetX: 101390 });1391 },1392 {1393 isTestCafeError: true,1394 code: 'E20',1395 argumentName: 'dragOffsetY',1396 actualValue: 'undefined',1397 callsite: null1398 }1399 );1400 assertThrow(1401 function () {1402 return createCommand({1403 type: TYPE.drag,1404 selector: 'element',1405 dragOffsetX: 10,1406 dragOffsetY: 10.51407 });1408 },1409 {1410 isTestCafeError: true,1411 code: 'E20',1412 argumentName: 'dragOffsetY',1413 actualValue: 10.5,1414 callsite: null1415 }1416 );1417 assertThrow(1418 function () {1419 return createCommand({1420 type: TYPE.drag,1421 selector: 'element',1422 dragOffsetX: 1,1423 dragOffsetY: -1,1424 options: 11425 });1426 },1427 {1428 isTestCafeError: true,1429 code: 'E14',1430 actualType: 'number',1431 callsite: null1432 }1433 );1434 });1435 it('Should validate DragToElementСommand', function () {1436 assertThrow(1437 function () {1438 return createCommand({1439 type: TYPE.dragToElement1440 });1441 },1442 {1443 isTestCafeError: true,1444 code: 'E23',1445 selectorName: 'selector',1446 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1447 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1448 callsite: null,1449 originError: null1450 }1451 );1452 assertThrow(1453 function () {1454 return createCommand({1455 type: TYPE.dragToElement,1456 selector: 11457 });1458 },1459 {1460 isTestCafeError: true,1461 code: 'E23',1462 selectorName: 'selector',1463 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1464 'node snapshot or a Promise returned by a Selector, but number was passed.',1465 callsite: null,1466 originError: null1467 }1468 );1469 assertThrow(1470 function () {1471 return createCommand({1472 type: TYPE.dragToElement,1473 selector: 'element'1474 });1475 },1476 {1477 isTestCafeError: true,1478 code: 'E23',1479 selectorName: 'destinationSelector',1480 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1481 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1482 callsite: null,1483 originError: null1484 }1485 );1486 assertThrow(1487 function () {1488 return createCommand({1489 type: TYPE.dragToElement,1490 selector: 'element',1491 destinationSelector: 11492 });1493 },1494 {1495 isTestCafeError: true,1496 code: 'E23',1497 selectorName: 'destinationSelector',1498 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1499 'node snapshot or a Promise returned by a Selector, but number was passed.',1500 callsite: null,1501 originError: null1502 }1503 );1504 assertThrow(1505 function () {1506 return createCommand({1507 type: TYPE.dragToElement,1508 selector: 'element',1509 destinationSelector: 'destination',1510 options: 11511 });1512 },1513 {1514 isTestCafeError: true,1515 code: 'E14',1516 actualType: 'number',1517 callsite: null1518 }1519 );1520 });1521 it('Should validate TypeTextСommand', function () {1522 assertThrow(1523 function () {1524 return createCommand({1525 type: TYPE.typeText1526 });1527 },1528 {1529 isTestCafeError: true,1530 code: 'E23',1531 selectorName: 'selector',1532 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1533 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1534 callsite: null,1535 originError: null1536 }1537 );1538 assertThrow(1539 function () {1540 return createCommand({1541 type: TYPE.typeText,1542 selector: 11543 });1544 },1545 {1546 isTestCafeError: true,1547 code: 'E23',1548 selectorName: 'selector',1549 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1550 'node snapshot or a Promise returned by a Selector, but number was passed.',1551 callsite: null,1552 originError: null1553 }1554 );1555 assertThrow(1556 function () {1557 return createCommand({1558 type: TYPE.typeText,1559 selector: 'element'1560 });1561 },1562 {1563 isTestCafeError: true,1564 code: 'E16',1565 argumentName: 'text',1566 actualValue: 'undefined',1567 callsite: null1568 }1569 );1570 assertThrow(1571 function () {1572 return createCommand({1573 type: TYPE.typeText,1574 selector: 'element',1575 text: 21576 });1577 },1578 {1579 isTestCafeError: true,1580 code: 'E16',1581 argumentName: 'text',1582 actualValue: 'number',1583 callsite: null1584 }1585 );1586 assertThrow(1587 function () {1588 return createCommand({1589 type: TYPE.typeText,1590 selector: 'element',1591 text: ''1592 });1593 },1594 {1595 isTestCafeError: true,1596 code: 'E16',1597 argumentName: 'text',1598 actualValue: '""',1599 callsite: null1600 }1601 );1602 assertThrow(1603 function () {1604 return createCommand({1605 type: TYPE.typeText,1606 selector: 'element',1607 text: 'testText',1608 options: true1609 });1610 },1611 {1612 isTestCafeError: true,1613 code: 'E14',1614 actualType: 'boolean',1615 callsite: null1616 }1617 );1618 assertThrow(1619 function () {1620 return createCommand({1621 type: TYPE.typeText,1622 selector: 'element',1623 text: 'testText',1624 options: {1625 offsetX: 'offsetX'1626 }1627 });1628 },1629 {1630 isTestCafeError: true,1631 code: 'E9',1632 optionName: 'offsetX',1633 actualValue: 'string',1634 callsite: null1635 }1636 );1637 assertThrow(1638 function () {1639 return createCommand({1640 type: TYPE.typeText,1641 selector: 'element',1642 text: 'testText',1643 options: {1644 replace: 101645 }1646 });1647 },1648 {1649 isTestCafeError: true,1650 code: 'E11',1651 optionName: 'replace',1652 actualValue: 'number',1653 callsite: null1654 }1655 );1656 });1657 it('Should validate SelectTextСommand', function () {1658 assertThrow(1659 function () {1660 return createCommand({1661 type: TYPE.selectText1662 });1663 },1664 {1665 isTestCafeError: true,1666 code: 'E23',1667 selectorName: 'selector',1668 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1669 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1670 callsite: null,1671 originError: null1672 }1673 );1674 assertThrow(1675 function () {1676 return createCommand({1677 type: TYPE.selectText,1678 selector: {}1679 });1680 },1681 {1682 isTestCafeError: true,1683 code: 'E23',1684 selectorName: 'selector',1685 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1686 'node snapshot or a Promise returned by a Selector, but object was passed.',1687 callsite: null,1688 originError: null1689 }1690 );1691 assertThrow(1692 function () {1693 return createCommand({1694 type: TYPE.selectText,1695 selector: 'element',1696 startPos: ''1697 });1698 },1699 {1700 isTestCafeError: true,1701 code: 'E22',1702 argumentName: 'startPos',1703 actualValue: 'string',1704 callsite: null1705 }1706 );1707 assertThrow(1708 function () {1709 return createCommand({1710 type: TYPE.selectText,1711 selector: 'element',1712 startPos: 5.51713 });1714 },1715 {1716 isTestCafeError: true,1717 code: 'E22',1718 argumentName: 'startPos',1719 actualValue: 5.5,1720 callsite: null1721 }1722 );1723 assertThrow(1724 function () {1725 return createCommand({1726 type: TYPE.selectText,1727 selector: 'element',1728 endPos: NaN1729 });1730 },1731 {1732 isTestCafeError: true,1733 code: 'E22',1734 argumentName: 'endPos',1735 actualValue: NaN,1736 callsite: null1737 }1738 );1739 assertThrow(1740 function () {1741 return createCommand({1742 type: TYPE.selectText,1743 selector: 'element',1744 endPos: -11745 });1746 },1747 {1748 isTestCafeError: true,1749 code: 'E22',1750 argumentName: 'endPos',1751 actualValue: -1,1752 callsite: null1753 }1754 );1755 assertThrow(1756 function () {1757 return createCommand({1758 type: TYPE.selectText,1759 selector: 'element',1760 options: 11761 });1762 },1763 {1764 isTestCafeError: true,1765 code: 'E14',1766 actualType: 'number',1767 callsite: null1768 }1769 );1770 });1771 it('Should validate SelectTextAreaContentСommand', function () {1772 assertThrow(1773 function () {1774 return createCommand({1775 type: TYPE.selectTextAreaContent1776 });1777 },1778 {1779 isTestCafeError: true,1780 code: 'E23',1781 selectorName: 'selector',1782 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1783 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1784 callsite: null,1785 originError: null1786 }1787 );1788 assertThrow(1789 function () {1790 return createCommand({1791 type: TYPE.selectTextAreaContent,1792 selector: {}1793 });1794 },1795 {1796 isTestCafeError: true,1797 code: 'E23',1798 selectorName: 'selector',1799 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1800 'node snapshot or a Promise returned by a Selector, but object was passed.',1801 callsite: null,1802 originError: null1803 }1804 );1805 assertThrow(1806 function () {1807 return createCommand({1808 type: TYPE.selectTextAreaContent,1809 selector: 'element',1810 startLine: ''1811 });1812 },1813 {1814 isTestCafeError: true,1815 code: 'E22',1816 argumentName: 'startLine',1817 actualValue: 'string',1818 callsite: null1819 }1820 );1821 assertThrow(1822 function () {1823 return createCommand({1824 type: TYPE.selectTextAreaContent,1825 selector: 'element',1826 startLine: 5.51827 });1828 },1829 {1830 isTestCafeError: true,1831 code: 'E22',1832 argumentName: 'startLine',1833 actualValue: 5.5,1834 callsite: null1835 }1836 );1837 assertThrow(1838 function () {1839 return createCommand({1840 type: TYPE.selectTextAreaContent,1841 selector: 'element',1842 endLine: NaN1843 });1844 },1845 {1846 isTestCafeError: true,1847 code: 'E22',1848 argumentName: 'endLine',1849 actualValue: NaN,1850 callsite: null1851 }1852 );1853 assertThrow(1854 function () {1855 return createCommand({1856 type: TYPE.selectTextAreaContent,1857 selector: 'element',1858 endLine: -11859 });1860 },1861 {1862 isTestCafeError: true,1863 code: 'E22',1864 argumentName: 'endLine',1865 actualValue: -1,1866 callsite: null1867 }1868 );1869 assertThrow(1870 function () {1871 return createCommand({1872 type: TYPE.selectTextAreaContent,1873 selector: 'element',1874 options: 11875 });1876 },1877 {1878 isTestCafeError: true,1879 code: 'E14',1880 actualType: 'number',1881 callsite: null1882 }1883 );1884 });1885 it('Should validate SelectEditableContentСommand', function () {1886 assertThrow(1887 function () {1888 return createCommand({1889 type: TYPE.selectEditableContent1890 });1891 },1892 {1893 isTestCafeError: true,1894 code: 'E23',1895 selectorName: 'startSelector',1896 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1897 'node snapshot or a Promise returned by a Selector, but undefined was passed.',1898 callsite: null,1899 originError: null1900 }1901 );1902 assertThrow(1903 function () {1904 return createCommand({1905 type: TYPE.selectEditableContent,1906 startSelector: 11907 });1908 },1909 {1910 isTestCafeError: true,1911 code: 'E23',1912 selectorName: 'startSelector',1913 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1914 'node snapshot or a Promise returned by a Selector, but number was passed.',1915 callsite: null,1916 originError: null1917 }1918 );1919 assertThrow(1920 function () {1921 return createCommand({1922 type: TYPE.selectEditableContent,1923 startSelector: 'node1',1924 endSelector: true1925 });1926 },1927 {1928 isTestCafeError: true,1929 code: 'E23',1930 selectorName: 'endSelector',1931 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +1932 'node snapshot or a Promise returned by a Selector, but boolean was passed.',1933 callsite: null,1934 originError: null1935 }1936 );1937 assertThrow(1938 function () {1939 return createCommand({1940 type: TYPE.selectEditableContent,1941 startSelector: 'node1',1942 endSelector: 'node2',1943 options: 11944 });1945 },1946 {1947 isTestCafeError: true,1948 code: 'E14',1949 actualType: 'number',1950 callsite: null1951 }1952 );1953 });1954 it('Should validate PressKeyСommand', function () {1955 assertThrow(1956 function () {1957 return createCommand({1958 type: TYPE.pressKey1959 });1960 },1961 {1962 isTestCafeError: true,1963 code: 'E16',1964 argumentName: 'keys',1965 actualValue: 'undefined',1966 callsite: null1967 }1968 );1969 assertThrow(1970 function () {1971 return createCommand({1972 type: TYPE.pressKey,1973 keys: true1974 });1975 },1976 {1977 isTestCafeError: true,1978 code: 'E16',1979 argumentName: 'keys',1980 actualValue: 'boolean',1981 callsite: null1982 }1983 );1984 assertThrow(1985 function () {1986 return createCommand({1987 type: TYPE.pressKey,1988 keys: ''1989 });1990 },1991 {1992 isTestCafeError: true,1993 code: 'E16',1994 argumentName: 'keys',1995 actualValue: '""',1996 callsite: null1997 }1998 );1999 assertThrow(2000 function () {2001 return createCommand({2002 type: TYPE.pressKey,2003 keys: 'a',2004 options: 12005 });2006 },2007 {2008 isTestCafeError: true,2009 code: 'E14',2010 actualType: 'number',2011 callsite: null2012 }2013 );2014 });2015 it('Should validate WaitСommand', function () {2016 assertThrow(2017 function () {2018 return createCommand({2019 type: TYPE.wait2020 });2021 },2022 {2023 isTestCafeError: true,2024 code: 'E22',2025 argumentName: 'timeout',2026 actualValue: 'undefined',2027 callsite: null2028 }2029 );2030 assertThrow(2031 function () {2032 return createCommand({2033 type: TYPE.wait,2034 timeout: -52035 });2036 },2037 {2038 isTestCafeError: true,2039 code: 'E22',2040 argumentName: 'timeout',2041 actualValue: -5,2042 callsite: null2043 }2044 );2045 });2046 it('Should validate NavigateToCommand', function () {2047 assertThrow(2048 function () {2049 return createCommand({2050 type: TYPE.navigateTo2051 });2052 },2053 {2054 isTestCafeError: true,2055 code: 'E16',2056 argumentName: 'url',2057 actualValue: 'undefined',2058 callsite: null2059 }2060 );2061 assertThrow(2062 function () {2063 return createCommand({2064 type: TYPE.navigateTo,2065 url: true2066 });2067 },2068 {2069 isTestCafeError: true,2070 code: 'E16',2071 argumentName: 'url',2072 actualValue: 'boolean',2073 callsite: null2074 }2075 );2076 assertThrow(2077 function () {2078 return createCommand({2079 type: TYPE.navigateTo,2080 url: ''2081 });2082 },2083 {2084 isTestCafeError: true,2085 code: 'E16',2086 argumentName: 'url',2087 actualValue: '""',2088 callsite: null2089 }2090 );2091 assertErrorMessage(2092 function () {2093 return createCommand({2094 type: TYPE.navigateTo,2095 url: 'mail://testcafe@devexpress.com'2096 });2097 },2098 'Cannot prepare tests due to an error.\n\nThe specified "mail://testcafe@devexpress.com" test page URL uses an unsupported mail:// protocol. Only relative URLs or absolute URLs with http://, https:// and file:// protocols are supported.'2099 );2100 });2101 it('Should validate SetFilesToUploadCommand', function () {2102 assertThrow(2103 function () {2104 return createCommand({2105 type: TYPE.setFilesToUpload2106 });2107 },2108 {2109 isTestCafeError: true,2110 code: 'E23',2111 selectorName: 'selector',2112 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +2113 'node snapshot or a Promise returned by a Selector, but undefined was passed.',2114 callsite: null,2115 originError: null2116 }2117 );2118 assertThrow(2119 function () {2120 return createCommand({2121 type: TYPE.setFilesToUpload,2122 selector: 12123 });2124 },2125 {2126 isTestCafeError: true,2127 code: 'E23',2128 selectorName: 'selector',2129 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +2130 'node snapshot or a Promise returned by a Selector, but number was passed.',2131 callsite: null,2132 originError: null2133 }2134 );2135 assertThrow(2136 function () {2137 return createCommand({2138 type: TYPE.setFilesToUpload,2139 selector: 'element'2140 });2141 },2142 {2143 isTestCafeError: true,2144 code: 'E18',2145 argumentName: 'filePath',2146 actualValue: 'undefined',2147 callsite: null2148 }2149 );2150 assertThrow(2151 function () {2152 return createCommand({2153 type: TYPE.setFilesToUpload,2154 selector: 'element',2155 filePath: 22156 });2157 },2158 {2159 isTestCafeError: true,2160 code: 'E18',2161 argumentName: 'filePath',2162 actualValue: 'number',2163 callsite: null2164 }2165 );2166 assertThrow(2167 function () {2168 return createCommand({2169 type: TYPE.setFilesToUpload,2170 selector: 'element',2171 filePath: ''2172 });2173 },2174 {2175 isTestCafeError: true,2176 code: 'E18',2177 argumentName: 'filePath',2178 actualValue: '""',2179 callsite: null2180 }2181 );2182 assertThrow(2183 function () {2184 return createCommand({2185 type: TYPE.setFilesToUpload,2186 selector: 'element',2187 filePath: {}2188 });2189 },2190 {2191 isTestCafeError: true,2192 code: 'E18',2193 argumentName: 'filePath',2194 actualValue: 'object',2195 callsite: null2196 }2197 );2198 assertThrow(2199 function () {2200 return createCommand({2201 type: TYPE.setFilesToUpload,2202 selector: 'element',2203 filePath: []2204 });2205 },2206 {2207 isTestCafeError: true,2208 code: 'E18',2209 argumentName: 'filePath',2210 actualValue: '[]',2211 callsite: null2212 }2213 );2214 assertThrow(2215 function () {2216 return createCommand({2217 type: TYPE.setFilesToUpload,2218 selector: 'element',2219 filePath: ['123', 42]2220 });2221 },2222 {2223 isTestCafeError: true,2224 code: 'E19',2225 argumentName: 'filePath',2226 actualValue: 'number',2227 elementIndex: 1,2228 callsite: null2229 }2230 );2231 assertThrow(2232 function () {2233 return createCommand({2234 type: TYPE.setFilesToUpload,2235 selector: 'element',2236 filePath: ['123', '']2237 });2238 },2239 {2240 isTestCafeError: true,2241 code: 'E19',2242 argumentName: 'filePath',2243 actualValue: '""',2244 elementIndex: 1,2245 callsite: null2246 }2247 );2248 });2249 it('Should validate ClearUploadCommand', function () {2250 assertThrow(2251 function () {2252 return createCommand({2253 type: TYPE.clearUpload2254 });2255 },2256 {2257 isTestCafeError: true,2258 code: 'E23',2259 selectorName: 'selector',2260 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +2261 'node snapshot or a Promise returned by a Selector, but undefined was passed.',2262 callsite: null,2263 originError: null2264 }2265 );2266 assertThrow(2267 function () {2268 return createCommand({2269 type: TYPE.clearUpload,2270 selector: 12271 });2272 },2273 {2274 isTestCafeError: true,2275 code: 'E23',2276 selectorName: 'selector',2277 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +2278 'node snapshot or a Promise returned by a Selector, but number was passed.',2279 callsite: null,2280 originError: null2281 }2282 );2283 });2284 it('Should validate TakeScreenshot', function () {2285 assertThrow(2286 function () {2287 return createCommand({2288 type: TYPE.takeScreenshot,2289 path: 12290 });2291 },2292 {2293 isTestCafeError: true,2294 code: 'E16',2295 actualValue: 'number',2296 argumentName: 'path',2297 callsite: null2298 }2299 );2300 assertThrow(2301 function () {2302 return createCommand({2303 type: TYPE.takeScreenshot,2304 path: ''2305 });2306 },2307 {2308 isTestCafeError: true,2309 code: 'E16',2310 actualValue: '""',2311 argumentName: 'path',2312 callsite: null2313 }2314 );2315 });2316 it('Should validate ResizeWindowСommand', function () {2317 assertThrow(2318 function () {2319 return createCommand({2320 type: TYPE.resizeWindow2321 });2322 },2323 {2324 isTestCafeError: true,2325 code: 'E22',2326 argumentName: 'width',2327 actualValue: 'undefined',2328 callsite: null2329 }2330 );2331 assertThrow(2332 function () {2333 return createCommand({2334 type: TYPE.resizeWindow,2335 width: 5,2336 height: -52337 });2338 },2339 {2340 isTestCafeError: true,2341 code: 'E22',2342 argumentName: 'height',2343 actualValue: -5,2344 callsite: null2345 }2346 );2347 });2348 it('Should validate ResizeWindowToFitDeviceСommand', function () {2349 assertThrow(2350 function () {2351 return createCommand({2352 type: TYPE.resizeWindowToFitDevice2353 });2354 },2355 {2356 isTestCafeError: true,2357 code: 'E16',2358 argumentName: 'device',2359 actualValue: 'undefined',2360 callsite: null2361 }2362 );2363 assertThrow(2364 function () {2365 return createCommand({2366 type: TYPE.resizeWindowToFitDevice,2367 device: 52368 });2369 },2370 {2371 isTestCafeError: true,2372 code: 'E16',2373 argumentName: 'device',2374 actualValue: 'number',2375 callsite: null2376 }2377 );2378 assertThrow(2379 function () {2380 return createCommand({2381 type: TYPE.resizeWindowToFitDevice,2382 device: ''2383 });2384 },2385 {2386 isTestCafeError: true,2387 code: 'E16',2388 argumentName: 'device',2389 actualValue: '""',2390 callsite: null2391 }2392 );2393 assertThrow(2394 function () {2395 return createCommand({2396 type: TYPE.resizeWindowToFitDevice,2397 device: 'iPhone 555'2398 });2399 },2400 {2401 isTestCafeError: true,2402 code: 'E38',2403 argumentName: 'device',2404 actualValue: 'iPhone 555',2405 callsite: null2406 }2407 );2408 assertThrow(2409 function () {2410 return createCommand({2411 type: TYPE.resizeWindowToFitDevice,2412 device: 'iPhone',2413 options: { portraitOrientation: {} }2414 });2415 },2416 {2417 isTestCafeError: true,2418 code: 'E11',2419 optionName: 'portraitOrientation',2420 actualValue: 'object',2421 callsite: null2422 }2423 );2424 });2425 it('Should validate SetTestSpeedCommand', function () {2426 assertThrow(2427 function () {2428 return createCommand({2429 type: TYPE.setTestSpeed2430 });2431 },2432 {2433 isTestCafeError: true,2434 code: 'E47',2435 argumentName: 'speed',2436 actualValue: 'undefined',2437 callsite: null2438 }2439 );2440 assertThrow(2441 function () {2442 return createCommand({2443 type: TYPE.setTestSpeed,2444 speed: 22445 });2446 },2447 {2448 isTestCafeError: true,2449 code: 'E47',2450 argumentName: 'speed',2451 actualValue: 2,2452 callsite: null2453 }2454 );2455 });2456 it('Should validate SetPageLoadTimeoutCommand', function () {2457 assertThrow(2458 function () {2459 return createCommand({2460 type: TYPE.setPageLoadTimeout2461 });2462 },2463 {2464 isTestCafeError: true,2465 code: 'E22',2466 argumentName: 'duration',2467 actualValue: 'undefined',2468 callsite: null2469 }2470 );2471 assertThrow(2472 function () {2473 return createCommand({2474 type: TYPE.setPageLoadTimeout,2475 duration: -12476 });2477 },2478 {2479 isTestCafeError: true,2480 code: 'E22',2481 argumentName: 'duration',2482 actualValue: -1,2483 callsite: null2484 }2485 );2486 });2487 it('Should validate AssertionСommand', function () {2488 assertThrow(2489 function () {2490 return createCommand({2491 type: TYPE.assertion2492 });2493 },2494 {2495 isTestCafeError: true,2496 code: 'E16',2497 argumentName: 'assertionType',2498 actualValue: 'undefined',2499 callsite: null2500 }2501 );2502 assertThrow(2503 function () {2504 return createCommand({2505 type: TYPE.assertion,2506 assertionType: 1232507 });2508 },2509 {2510 isTestCafeError: true,2511 code: 'E16',2512 argumentName: 'assertionType',2513 actualValue: 'number',2514 callsite: null2515 }2516 );2517 assertThrow(2518 function () {2519 return createCommand({2520 type: TYPE.assertion,2521 assertionType: 'ok',2522 options: 12523 });2524 },2525 {2526 isTestCafeError: true,2527 code: 'E14',2528 actualType: 'number',2529 callsite: null2530 }2531 );2532 assertThrow(2533 function () {2534 return createCommand({2535 type: TYPE.assertion,2536 assertionType: 'ok',2537 options: {2538 timeout: 'timeout'2539 }2540 });2541 },2542 {2543 isTestCafeError: true,2544 code: 'E10',2545 optionName: 'timeout',2546 actualValue: 'string',2547 callsite: null2548 }2549 );2550 assertThrow(2551 function () {2552 return createCommand({2553 type: TYPE.assertion,2554 assertionType: 'ok',2555 options: {2556 timeout: 10.52557 }2558 });2559 },2560 {2561 isTestCafeError: true,2562 code: 'E10',2563 optionName: 'timeout',2564 actualValue: 10.5,2565 callsite: null2566 }2567 );2568 assertThrow(2569 function () {2570 return createCommand({2571 type: TYPE.assertion,2572 assertionType: 'ok',2573 actual: {2574 type: 'js-expr',2575 value: 'invalid js code'2576 }2577 });2578 },2579 {2580 isTestCafeError: true,2581 argumentName: 'actual',2582 actualValue: 'invalid js code',2583 errMsg: 'Unexpected identifier',2584 code: 'E59',2585 callsite: null,2586 originError: null2587 }2588 );2589 });2590 it('Should validate ExecuteExpressionСommand', function () {2591 assertThrow(2592 function () {2593 return createCommand({2594 type: TYPE.executeExpression2595 });2596 },2597 {2598 isTestCafeError: true,2599 code: 'E16',2600 argumentName: 'expression',2601 actualValue: 'undefined',2602 callsite: null2603 }2604 );2605 assertThrow(2606 function () {2607 return createCommand({2608 type: TYPE.executeExpression,2609 expression: 1232610 });2611 },2612 {2613 isTestCafeError: true,2614 code: 'E16',2615 argumentName: 'expression',2616 actualValue: 'number',2617 callsite: null2618 }2619 );2620 assertThrow(2621 function () {2622 return createCommand({2623 type: TYPE.executeExpression,2624 expression: 'js-expression',2625 resultVariableName: 1232626 });2627 },2628 {2629 isTestCafeError: true,2630 code: 'E16',2631 argumentName: 'resultVariableName',2632 actualValue: 'number',2633 callsite: null2634 }2635 );2636 assertThrow(2637 function () {2638 return createCommand({2639 type: TYPE.executeExpression,2640 expression: 'js-expression',2641 resultVariableName: ''2642 });2643 },2644 {2645 isTestCafeError: true,2646 code: 'E16',2647 argumentName: 'resultVariableName',2648 actualValue: '""',2649 callsite: null2650 }2651 );2652 });2653 it('Should validate ExecuteAsyncExpressionCommand', function () {2654 assertThrow(2655 function () {2656 return createCommand({2657 type: TYPE.executeAsyncExpression2658 });2659 },2660 {2661 isTestCafeError: true,2662 code: 'E16',2663 argumentName: 'expression',2664 actualValue: 'undefined',2665 callsite: null2666 }2667 );2668 assertThrow(2669 function () {2670 return createCommand({2671 type: TYPE.executeAsyncExpression,2672 expression: 1232673 });2674 },2675 {2676 isTestCafeError: true,2677 code: 'E16',2678 argumentName: 'expression',2679 actualValue: 'number',2680 callsite: null2681 }2682 );2683 });2684 it('Should validate js expression as Selector', function () {2685 assertThrow(2686 function () {2687 return createCommand({2688 type: TYPE.click,2689 selector: {2690 type: 'js-expr',2691 value: 'Selector()'2692 }2693 });2694 },2695 {2696 isTestCafeError: true,2697 code: 'E23',2698 selectorName: 'selector',2699 errMsg: 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +2700 'node snapshot or a Promise returned by a Selector, but undefined was passed.',2701 callsite: null,2702 originError: null2703 }2704 );2705 assertThrow(2706 function () {2707 return createCommand({2708 type: TYPE.click,2709 selector: {2710 type: 'js-expr',2711 value: 'yo'2712 }2713 });2714 },2715 {2716 isTestCafeError: true,2717 code: 'E23',2718 selectorName: 'selector',2719 errMsg: 'yo is not defined',2720 callsite: null,2721 originError: null2722 }2723 );2724 });2725 it('Should validate RecorderCommand', function () {2726 assertThrow(2727 function () {2728 return createCommand({2729 type: TYPE.recorder2730 });2731 },2732 {2733 isTestCafeError: true,2734 code: 'E16',2735 argumentName: 'subtype',2736 actualValue: 'undefined',2737 callsite: null2738 }2739 );2740 assertThrow(2741 function () {2742 return createCommand({2743 type: TYPE.recorder,2744 subtype: ''2745 });2746 },2747 {2748 isTestCafeError: true,2749 code: 'E16',2750 argumentName: 'subtype',2751 actualValue: '""',2752 callsite: null2753 }2754 );2755 assertThrow(2756 function () {2757 return createCommand({2758 type: TYPE.recorder,2759 subtype: 22760 });2761 },2762 {2763 isTestCafeError: true,2764 code: 'E16',2765 argumentName: 'subtype',2766 actualValue: 'number',2767 callsite: null2768 }2769 );2770 });2771 });...

Full Screen

Full Screen

seed.js

Source:seed.js Github

copy

Full Screen

...26 return store.createTestCase(generate({ words: 2 }).spaced)27 }28 const targets = ['a', 'button']29 function generateCommand(test) {30 const command = test.createCommand()31 command.setCommand(32 CommandsArray[Math.floor(Math.random() * CommandsArray.length)]33 )34 let targetChance = Math.floor(Math.random() * 10)35 command.setTarget(36 targetChance < targets.length ? targets[targetChance] : ''37 )38 command.setValue(39 Math.floor(Math.random() * 2) ? generate({ words: 1 }).spaced : ''40 )41 return command42 }43 function randomBetween(min, max) {44 return Math.floor(Math.random() * (max - min)) + min45 }46 for (let i = 0; i < numberOfSuites; i++) {47 let suite = generateSuite()48 for (let j = 0; j < randomBetween(3, 6); j++) {49 const testCase = generateTestCase()50 for (let k = 0; k < randomBetween(9, 16); k++) {51 generateCommand(testCase)52 }53 suite.addTestCase(testCase)54 }55 }56 const url = 'http://the-internet.herokuapp.com'57 store.setUrl(url)58 store.addUrl(url)59 const yeeOldTest = store.createTestCase('send KEY_ENTER')60 yeeOldTest.createCommand(61 undefined,62 'open',63 'https://en.wikipedia.org/wiki/Main_Page'64 )65 yeeOldTest.createCommand(undefined, 'type', 'id=searchInput', 'selenium')66 yeeOldTest.createCommand(67 undefined,68 'sendKeys',69 'id=searchInput',70 '${KEY_ENTER}'71 )72 const controlFlowIfTest = store.createTestCase('control flow if')73 controlFlowIfTest.createCommand(74 undefined,75 'executeScript',76 'return "a"',77 'myVar'78 )79 controlFlowIfTest.createCommand(undefined, 'if', '${myVar} === "a"')80 controlFlowIfTest.createCommand(81 undefined,82 'executeScript',83 'return "a"',84 'output'85 )86 controlFlowIfTest.createCommand(undefined, 'elseIf', '${myVar} === "b"')87 controlFlowIfTest.createCommand(88 undefined,89 'executeScript',90 'return "b"',91 'output'92 )93 controlFlowIfTest.createCommand(undefined, 'else')94 controlFlowIfTest.createCommand(95 undefined,96 'executeScript',97 'return "c"',98 'output'99 )100 controlFlowIfTest.createCommand(undefined, 'end')101 controlFlowIfTest.createCommand(undefined, 'assert', 'output', 'a')102 const controlFlowElseIfTest = store.createTestCase('control flow else if')103 controlFlowElseIfTest.createCommand(104 undefined,105 'executeScript',106 'return "b"',107 'myVar'108 )109 controlFlowElseIfTest.createCommand(undefined, 'if', '${myVar} === "a"')110 controlFlowElseIfTest.createCommand(111 undefined,112 'executeScript',113 'return "a"',114 'output'115 )116 controlFlowElseIfTest.createCommand(undefined, 'elseIf', '${myVar} === "b"')117 controlFlowElseIfTest.createCommand(118 undefined,119 'executeScript',120 'return "b"',121 'output'122 )123 controlFlowElseIfTest.createCommand(undefined, 'else')124 controlFlowElseIfTest.createCommand(125 undefined,126 'executeScript',127 'return "c"',128 'output'129 )130 controlFlowElseIfTest.createCommand(undefined, 'end')131 controlFlowElseIfTest.createCommand(undefined, 'assert', 'output', 'b')132 const controlFlowElseTest = store.createTestCase('control flow else')133 controlFlowElseTest.createCommand(134 undefined,135 'executeScript',136 'return "c"',137 'myVar'138 )139 controlFlowElseTest.createCommand(undefined, 'if', '${myVar} === "a"')140 controlFlowElseTest.createCommand(141 undefined,142 'executeScript',143 'return "a"',144 'output'145 )146 controlFlowElseTest.createCommand(undefined, 'elseIf', '${myVar} === "b"')147 controlFlowElseTest.createCommand(148 undefined,149 'executeScript',150 'return "b"',151 'output'152 )153 controlFlowElseTest.createCommand(undefined, 'else')154 controlFlowElseTest.createCommand(155 undefined,156 'executeScript',157 'return "c"',158 'output'159 )160 controlFlowElseTest.createCommand(undefined, 'end')161 controlFlowElseTest.createCommand(undefined, 'assert', 'output', 'c')162 const controlFlowDoTest = store.createTestCase('control flow do')163 controlFlowDoTest.createCommand(164 undefined,165 'executeScript',166 'return 1',167 'check'168 )169 controlFlowDoTest.createCommand(undefined, 'do')170 controlFlowDoTest.createCommand(171 undefined,172 'executeScript',173 'return ${check} + 1',174 'check'175 )176 controlFlowDoTest.createCommand(undefined, 'repeatIf', '${check} < 3')177 controlFlowDoTest.createCommand(undefined, 'assert', 'check', '3')178 const controlFlowTimesTest = store.createTestCase('control flow times')179 controlFlowTimesTest.createCommand(180 undefined,181 'executeScript',182 'return 1',183 'check'184 )185 controlFlowTimesTest.createCommand(undefined, 'times', '2')186 controlFlowTimesTest.createCommand(187 undefined,188 'executeScript',189 'return ${check} + 1',190 'check'191 )192 controlFlowTimesTest.createCommand(undefined, 'end')193 controlFlowTimesTest.createCommand(undefined, 'assert', 'check', '3')194 const controlFlowWhileTest = store.createTestCase('control flow while')195 controlFlowWhileTest.createCommand(196 undefined,197 'executeScript',198 'return 1',199 'check'200 )201 controlFlowWhileTest.createCommand(undefined, 'while', '${check} < 3')202 controlFlowWhileTest.createCommand(203 undefined,204 'executeScript',205 'return ${check} + 1',206 'check'207 )208 controlFlowWhileTest.createCommand(undefined, 'end')209 controlFlowWhileTest.createCommand(undefined, 'assert', 'check', '3')210 const controlFlowForEachTest = store.createTestCase('control flow for each')211 controlFlowForEachTest.createCommand(212 undefined,213 'executeScript',214 'return 0',215 'count'216 )217 controlFlowForEachTest.createCommand(218 undefined,219 'executeScript',220 `return [{'a': 0}, {'a': 1}, {'a': 2}, {'a': 3}, {'a': '4'}]`,221 'collection'222 )223 controlFlowForEachTest.createCommand(224 undefined,225 'forEach',226 'collection',227 'iteratorVar'228 )229 controlFlowForEachTest.createCommand(230 undefined,231 'executeScript',232 'return ${count} == ${iteratorVar}.a',233 'result'234 )235 controlFlowForEachTest.createCommand(undefined, 'assert', 'result', 'true')236 controlFlowForEachTest.createCommand(237 undefined,238 'executeScript',239 'return ${count} += 1',240 'count'241 )242 controlFlowForEachTest.createCommand(undefined, 'end')243 const controlFlowForEachNestedTest = store.createTestCase(244 'control flow for each (nested)'245 )246 controlFlowForEachNestedTest.createCommand(247 undefined,248 'executeScript',249 `return 0`,250 'count'251 )252 controlFlowForEachNestedTest.createCommand(253 undefined,254 'executeScript',255 `return [[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]]`,256 'numbersCol'257 )258 controlFlowForEachNestedTest.createCommand(259 undefined,260 'forEach',261 'numbersCol',262 'numbers'263 )264 controlFlowForEachNestedTest.createCommand(265 undefined,266 'forEach',267 'numbers',268 'number'269 )270 controlFlowForEachNestedTest.createCommand(271 undefined,272 'executeScript',273 'return ${count} + 1',274 'count'275 )276 controlFlowForEachNestedTest.createCommand(undefined, 'end')277 controlFlowForEachNestedTest.createCommand(undefined, 'end')278 controlFlowForEachNestedTest.createCommand(undefined, 'assert', 'count', '15')279 const executeScriptTest = store.createTestCase('execute script')280 executeScriptTest.createCommand(281 undefined,282 'executeScript',283 'return true',284 'blah'285 )286 executeScriptTest.createCommand(undefined, 'assert', 'blah', 'true')287 executeScriptTest.createCommand(undefined, 'executeScript', 'true')288 executeScriptTest.createCommand(undefined, 'echo', '${blah}')289 const executeScriptArray = store.createTestCase('execute script array')290 executeScriptArray.createCommand(291 undefined,292 'executeScript',293 'return [1,2,3]',294 'x'295 )296 executeScriptArray.createCommand(297 undefined,298 'executeScript',299 'return ${x}[0] + 1',300 'y'301 )302 executeScriptArray.createCommand(undefined, 'assert', 'y', '2')303 const executeScriptObject = store.createTestCase('execute script object')304 executeScriptObject.createCommand(305 undefined,306 'executeScript',307 'return { x: 3 }',308 'x'309 )310 executeScriptObject.createCommand(311 undefined,312 'executeScript',313 'return ${x}.x + 2',314 'y'315 )316 executeScriptObject.createCommand(undefined, 'assert', 'y', '5')317 const executeScriptPrimitives = store.createTestCase(318 'execute script primitives'319 )320 executeScriptPrimitives.createCommand(321 undefined,322 'executeScript',323 'return true',324 'bool'325 )326 executeScriptPrimitives.createCommand(undefined, 'assert', 'bool', 'true')327 executeScriptPrimitives.createCommand(328 undefined,329 'executeScript',330 'return 3.14',331 'float'332 )333 executeScriptPrimitives.createCommand(undefined, 'assert', 'float', '3.14')334 executeScriptPrimitives.createCommand(335 undefined,336 'executeScript',337 'return "test"',338 'string'339 )340 executeScriptPrimitives.createCommand(undefined, 'assert', 'string', 'test')341 const checkTest = store.createTestCase('check')342 checkTest.createCommand(undefined, 'open', '/checkboxes')343 const command = checkTest.createCommand(undefined, 'check', 'css=input')344 command.setTargets([345 ['id=something', 'id'],346 ['name=something-else', 'name'],347 ['linkText=number density', 'linkText'],348 ["xpath=//a[contains(text(),'number density')]", 'xpath:link'],349 ['css=main .class > p a.link', 'css'],350 ["xpath=(//a[contains(text(),'number line')])[2]", 'xpath:link'],351 ["(//a[contains(text(),'number line')])[2]", 'xpath:link'],352 ["//a[contains(text(),'number density')]", 'xpath:link'],353 ["//div[@id='mw-content-text']/div/p[2]/a[5]", 'xpath:idRelative'],354 ["//a[contains(@href, '/wiki/Number_density')]", 'xpath:href'],355 ['//a[5]', 'xpath:position'],356 ])357 checkTest.createCommand(undefined, 'assertChecked', 'css=input')358 checkTest.createCommand(undefined, 'uncheck', 'css=input')359 checkTest.createCommand(undefined, 'assertNotChecked', 'css=input')360 const clickTest = store.createTestCase('click')361 clickTest.createCommand(undefined, 'open', '/')362 clickTest.createCommand(undefined, 'click', 'linkText=Dropdown')363 clickTest.createCommand(undefined, 'assertText', 'css=h3', 'Dropdown List')364 clickTest.createCommand(undefined, 'open', '/')365 clickTest.createCommand(undefined, 'click', 'link=Dropdown')366 clickTest.createCommand(undefined, 'assertText', 'css=h3', 'Dropdown List')367 clickTest.createCommand(undefined, 'open', '/')368 clickTest.createCommand(undefined, 'click', 'partialLinkText=ropd')369 clickTest.createCommand(undefined, 'assertText', 'css=h3', 'Dropdown List')370 const clickAtTest = store.createTestCase('click at')371 clickAtTest.createCommand(undefined, 'open', '/')372 clickAtTest.createCommand(undefined, 'clickAt', 'css=a')373 const commentTest = store.createTestCase('comment')374 commentTest.createCommand(undefined, '//commented code')375 commentTest.createCommand(undefined, '', '', '', 'blah')376 commentTest.createCommand(undefined, '', '', '')377 commentTest.createCommand(undefined, 'open', '/', '', 'also blah')378 const framesTest = store.createTestCase('frames')379 framesTest.createCommand(undefined, 'open', '/nested_frames')380 framesTest.createCommand(undefined, 'selectFrame', 'index=0')381 framesTest.createCommand(undefined, 'selectFrame', 'index=1')382 framesTest.createCommand(undefined, 'assertText', 'css=#content', 'MIDDLE')383 framesTest.createCommand(undefined, 'selectFrame', 'relative=parent')384 framesTest.createCommand(undefined, 'selectFrame', 'index=1')385 framesTest.createCommand(undefined, 'assertText', 'css=#content', 'MIDDLE')386 framesTest.createCommand(undefined, 'selectFrame', 'relative=top')387 framesTest.createCommand(undefined, 'selectFrame', 'index=0')388 framesTest.createCommand(undefined, 'selectFrame', 'index=1')389 framesTest.createCommand(undefined, 'assertText', 'css=#content', 'MIDDLE')390 const selectTest = store.createTestCase('select')391 selectTest.createCommand(undefined, 'open', '/dropdown')392 selectTest.createCommand(undefined, 'select', 'id=dropdown', 'value=1')393 selectTest.createCommand(undefined, 'assertSelectedValue', 'id=dropdown', '1')394 selectTest.createCommand(395 undefined,396 'assertNotSelectedValue',397 'id=dropdown',398 '2'399 )400 selectTest.createCommand(401 undefined,402 'assertSelectedLabel',403 'id=dropdown',404 'Option 1'405 )406 selectTest.createCommand(undefined, 'select', 'id=dropdown', 'Option 2')407 selectTest.createCommand(undefined, 'assertSelectedValue', 'id=dropdown', '2')408 selectTest.createCommand(409 undefined,410 'assertNotSelectedValue',411 'id=dropdown',412 '1'413 )414 selectTest.createCommand(415 undefined,416 'assertSelectedLabel',417 'id=dropdown',418 'Option 2'419 )420 const sendKeysTest = store.createTestCase('send keys')421 sendKeysTest.createCommand(undefined, 'open', '/login')422 sendKeysTest.createCommand(undefined, 'sendKeys', 'css=#username', 'tomsmith')423 sendKeysTest.createCommand(424 undefined,425 'sendKeys',426 "xpath=//input[@id='password']",427 'SuperSecretPassword!${KEY_ENTER}'428 )429 sendKeysTest.createCommand(430 undefined,431 'assertText',432 'id=flash',433 'You logged into a secure area!\\n×'434 )435 const storeTextTest = store.createTestCase('store text')436 storeTextTest.createCommand(undefined, 'open', '/login')437 storeTextTest.createCommand(undefined, 'sendKeys', 'css=#username', 'blah')438 storeTextTest.createCommand(undefined, 'storeValue', 'css=#username', 'aVar')439 storeTextTest.createCommand(undefined, 'assert', 'aVar', 'blah')440 const submitTest = store.createTestCase('submit')441 submitTest.createCommand(undefined, 'open', '/login')442 submitTest.createCommand(undefined, 'sendKeys', 'css=#username', 'tomsmith')443 submitTest.createCommand(444 undefined,445 'sendKeys',446 'css=#password',447 'SuperSecretPassword!'448 )449 submitTest.createCommand(undefined, 'submit', 'css=#login')450 submitTest.createCommand(451 undefined,452 'assertElementPresent',453 'css=.flash.success'454 )455 const waitTest1 = store.createTestCase('wait for element present')456 waitTest1.createCommand(undefined, 'open', '/dynamic_loading/2')457 waitTest1.createCommand(undefined, 'clickAt', 'css=#start button')458 waitTest1.createCommand(459 undefined,460 'waitForElementPresent',461 'css=#finish',462 '5000'463 )464 waitTest1.createCommand(465 undefined,466 'assertText',467 'css=#finish',468 'Hello World!'469 )470 const waitTest2 = store.createTestCase('wait for element not present')471 waitTest2.createCommand(undefined, 'open', '/dynamic_controls')472 waitTest2.createCommand(undefined, 'clickAt', 'css=#checkbox-example button')473 waitTest2.createCommand(474 undefined,475 'waitForElementNotPresent',476 'css=#checkbox',477 '5000'478 )479 waitTest2.createCommand(undefined, 'assertElementNotPresent', 'css=#checkbox')480 const waitTest3 = store.createTestCase('wait for element visible')481 waitTest3.createCommand(undefined, 'open', '/dynamic_loading/1')482 waitTest3.createCommand(undefined, 'clickAt', 'css=#start button')483 waitTest3.createCommand(484 undefined,485 'waitForElementVisible',486 'css=#finish',487 '5000'488 )489 waitTest3.createCommand(490 undefined,491 'assertText',492 'css=#finish',493 'Hello World!'494 )495 const waitTest4 = store.createTestCase('wait for element not visible')496 waitTest4.createCommand(undefined, 'open', '/dynamic_loading/1')497 waitTest4.createCommand(undefined, 'clickAt', 'css=#start button')498 waitTest4.createCommand(499 undefined,500 'waitForElementNotVisible',501 'css=#loading',502 '5000'503 )504 waitTest4.createCommand(505 undefined,506 'assertText',507 'css=#finish',508 'Hello World!'509 )510 const waitTest5 = store.createTestCase(511 'wait for element editable (and not editable)'512 )513 waitTest5.createCommand(undefined, 'open', '/dynamic_controls')514 waitTest5.createCommand(undefined, 'clickAt', 'css=#input-example button')515 waitTest5.createCommand(516 undefined,517 'waitForElementEditable',518 'css=#input-example input',519 '5000'520 )521 waitTest5.createCommand(522 undefined,523 'assertEditable',524 'css=#input-example input'525 )526 waitTest5.createCommand(undefined, 'clickAt', 'css=#input-example button')527 waitTest5.createCommand(528 undefined,529 'waitForElementNotEditable',530 'css=#input-example input',531 '5000'532 )533 waitTest5.createCommand(534 undefined,535 'assertNotEditable',536 'css=#input-example input'537 )538 const locatorFallbackTest = store.createTestCase('locator fallback')539 locatorFallbackTest.createCommand(undefined, 'open', '/dynamic_loading/2')540 locatorFallbackTest.createCommand(undefined, 'click', 'css=button')541 const locatorFallbackTestCommand = new Command(542 undefined,543 'clickAt',544 'css=#finis > h4'545 )546 locatorFallbackTestCommand.setTargets([547 ['css=#finis > h4', 'css'],548 ['css=#finish > h4', 'css'],549 ])550 locatorFallbackTest.addCommand(locatorFallbackTestCommand)551 locatorFallbackTest.createCommand(552 undefined,553 'assertText',554 'css=#finish > h4',555 'Hello World!'556 )557 const confirmationDialogTest = store.createTestCase('confirmation dialog')558 confirmationDialogTest.createCommand(undefined, 'open', '/javascript_alerts')559 confirmationDialogTest.createCommand(560 undefined,561 'chooseOkOnNextConfirmation',562 ''563 )564 confirmationDialogTest.createCommand(565 undefined,566 'click',567 'css=li:nth-child(2) > button'568 )569 confirmationDialogTest.createCommand(570 undefined,571 'assertConfirmation',572 'I am a JS Confirm'573 )574 confirmationDialogTest.createCommand(575 undefined,576 'webdriverChooseOkOnVisibleConfirmation',577 ''578 )579 const selectWindow = store.createTestCase('select window')580 selectWindow.createCommand(undefined, 'open', '/')581 selectWindow.createCommand(undefined, 'storeWindowHandle', 'handle')582 selectWindow.createCommand(undefined, 'echo', '${handle}')583 const click = selectWindow.createCommand(584 undefined,585 'click',586 'linkText=Elemental Selenium'587 )588 click.setOpensWindow(true)589 click.setWindowHandleName('newWindow')590 selectWindow.createCommand(undefined, 'assertTitle', 'The Internet')591 selectWindow.createCommand(undefined, 'selectWindow', 'handle=${handle}')592 selectWindow.createCommand(undefined, 'assertTitle', 'The Internet')593 selectWindow.createCommand(undefined, 'selectWindow', 'handle=${newWindow}')594 selectWindow.createCommand(595 undefined,596 'assertTitle',597 'Elemental Selenium: Receive a Free, Weekly Tip on Using Selenium like a Pro'598 )599 selectWindow.createCommand(undefined, 'close')600 selectWindow.createCommand(undefined, 'selectWindow', 'handle=${handle}')601 selectWindow.createCommand(undefined, 'assertTitle', 'The Internet')602 const login = store.createTestCase('login')603 login.createCommand(undefined, 'open', '/login')604 login.createCommand(undefined, 'sendKeys', 'id=username', '${username}')605 login.createCommand(undefined, 'sendKeys', 'id=password', '${password}')606 login.createCommand(undefined, 'click', 'css=#login button')607 const reuse = store.createTestCase('reuse')608 reuse.createCommand(undefined, 'store', 'tomsmith', 'username')609 reuse.createCommand(undefined, 'store', 'SuperSecretPassword!', 'password')610 reuse.createCommand(undefined, 'run', 'login')611 reuse.createCommand(612 undefined,613 'assertText',614 'id=flash',615 'You logged into a secure area!\\n×'616 )617 const storeJson = store.createTestCase('store json')618 storeJson.createCommand(undefined, 'storeJson', `[{"a":0}]`, 'blah')619 storeJson.createCommand(620 undefined,621 'executeScript',622 'return ${blah}.length == 1',623 'result'624 )625 storeJson.createCommand(undefined, 'assert', 'result', 'true')626 const accessVariable = store.createTestCase('access variable')627 accessVariable.createCommand(628 undefined,629 'storeJson',630 `{"a": [{"b":0}, {"b":1}]}`,631 'blah'632 )633 accessVariable.createCommand(undefined, 'store', '${blah.a[0].b}', 'result')634 accessVariable.createCommand(undefined, 'assert', 'result', '0')635 const accessVariableAssert = store.createTestCase('access variable assert')636 accessVariableAssert.createCommand(undefined, 'storeJson', `{"a":0}`, 'blah')637 accessVariableAssert.createCommand(undefined, 'assert', 'blah.a', '0')638 const accessVariableArray = store.createTestCase('access variable array')639 accessVariableArray.createCommand(640 undefined,641 'storeJson',642 `[{"a":0}, {"a":1}]`,643 'blah'644 )645 accessVariableArray.createCommand(undefined, 'assert', 'blah[1].a', '1')646 const accessVariableNestedJson = store.createTestCase(647 'access variable nested json'648 )649 accessVariableNestedJson.createCommand(650 undefined,651 'storeJson',652 `[{"a":[{"b":0}, {"b":{"c":1}}]}, {"a":2}]`,653 'blah'654 )655 accessVariableNestedJson.createCommand(656 undefined,657 'assert',658 'blah[0].a[1].b.c',659 '1'660 )661 const accessVariableForEach = store.createTestCase('access variable for each')662 accessVariableForEach.createCommand(663 undefined,664 'executeScript',665 'return 0',666 'result'667 )668 accessVariableForEach.createCommand(669 undefined,670 'storeJson',671 `{"a":[{"b":0}, {"b":1}, {"b":2}]}`,672 'blah'673 )674 accessVariableForEach.createCommand(675 undefined,676 'forEach',677 'blah.a',678 'iterator'679 )680 accessVariableForEach.createCommand(681 undefined,682 'executeScript',683 'return ${result} + ${iterator.b}',684 'result'685 )686 accessVariableForEach.createCommand(undefined, 'end', '', '')687 accessVariableForEach.createCommand(undefined, 'assert', 'result', '3')688 const suiteAll = store.createSuite('all tests')689 store.tests.forEach(function(test) {690 suiteAll.addTestCase(test)691 })692 const suiteControlFlow = store.createSuite('control flow')693 suiteControlFlow.addTestCase(controlFlowIfTest)694 suiteControlFlow.addTestCase(controlFlowElseIfTest)695 suiteControlFlow.addTestCase(controlFlowElseTest)696 suiteControlFlow.addTestCase(controlFlowDoTest)697 suiteControlFlow.addTestCase(controlFlowTimesTest)698 suiteControlFlow.addTestCase(controlFlowWhileTest)699 suiteControlFlow.addTestCase(controlFlowForEachTest)700 suiteControlFlow.addTestCase(controlFlowForEachNestedTest)701 const smokeSuite = store.createSuite('smoke')...

Full Screen

Full Screen

playback-tree.spec.js

Source:playback-tree.spec.js Github

copy

Full Screen

...18 createPlaybackTree,19 createCommandNodesFromCommandStack,20} from '../../src/playback-tree'21import { ControlFlowCommandNames } from '../../src/playback-tree/commands'22function createCommand(command) {23 return {24 command,25 target: '',26 value: '',27 }28}29describe('Control Flow', () => {30 describe('Process', () => {31 describe('Linked List Validation', () => {32 test('nodes contain command references and levels', () => {33 let input = [createCommand('command1'), createCommand('command2')]34 let stack = createCommandNodesFromCommandStack(input)35 expect(stack[0].command).toEqual(input[0])36 expect(stack[0].level).toEqual(0)37 expect(stack[1].command).toEqual(input[1])38 expect(stack[1].level).toEqual(0)39 })40 test('command-command', () => {41 let input = [createCommand('command1'), createCommand('command2')]42 let stack = createCommandNodesFromCommandStack(input)43 expect(stack[0].next).toEqual(stack[1])44 expect(stack[0].left).toBeUndefined()45 expect(stack[0].right).toBeUndefined()46 expect(stack[1].next).toBeUndefined()47 expect(stack[1].left).toBeUndefined()48 expect(stack[1].right).toBeUndefined()49 })50 test('if-command-elseIf-command-else-command-end', () => {51 let input = [52 createCommand(ControlFlowCommandNames.if),53 createCommand('command'),54 createCommand(ControlFlowCommandNames.elseIf),55 createCommand('command'),56 createCommand(ControlFlowCommandNames.else),57 createCommand('command'),58 createCommand(ControlFlowCommandNames.end),59 ]60 let stack = createCommandNodesFromCommandStack(input)61 // if62 expect(stack[0].next).toBeUndefined()63 expect(stack[0].right).toEqual(stack[1])64 expect(stack[0].left).toEqual(stack[2])65 // command66 expect(stack[1].next).toEqual(stack[6])67 expect(stack[1].right).toBeUndefined()68 expect(stack[1].left).toBeUndefined()69 // elseIf70 expect(stack[2].next).toBeUndefined()71 expect(stack[2].right).toEqual(stack[3])72 expect(stack[2].left).toEqual(stack[4])73 // command74 expect(stack[3].next).toEqual(stack[6])75 expect(stack[3].right).toBeUndefined()76 expect(stack[3].left).toBeUndefined()77 // else78 expect(stack[4].next).toEqual(stack[5])79 expect(stack[4].right).toBeUndefined()80 expect(stack[4].left).toBeUndefined()81 // command82 expect(stack[5].next).toEqual(stack[6])83 expect(stack[5].right).toBeUndefined()84 expect(stack[5].left).toBeUndefined()85 // end86 expect(stack[6].next).toBeUndefined()87 expect(stack[6].right).toBeUndefined()88 expect(stack[6].left).toBeUndefined()89 })90 test('while-end', () => {91 let input = [92 createCommand(ControlFlowCommandNames.while),93 createCommand(ControlFlowCommandNames.end),94 ]95 let stack = createCommandNodesFromCommandStack(input)96 expect(stack[0].next).toBeUndefined()97 expect(stack[0].right).toEqual(stack[1])98 expect(stack[0].left).toEqual(stack[1])99 expect(stack[1].next).toBeUndefined()100 expect(stack[1].right).toBeUndefined()101 expect(stack[1].left).toBeUndefined()102 })103 test('while-command-end', () => {104 let input = [105 createCommand(ControlFlowCommandNames.while),106 createCommand('command'),107 createCommand(ControlFlowCommandNames.end),108 ]109 let stack = createCommandNodesFromCommandStack(input)110 expect(stack[0].next).toBeUndefined()111 expect(stack[0].right).toEqual(stack[1])112 expect(stack[0].left).toEqual(stack[2])113 expect(stack[1].next).toEqual(stack[0])114 expect(stack[1].right).toBeUndefined()115 expect(stack[1].left).toBeUndefined()116 expect(stack[2].next).toBeUndefined()117 expect(stack[2].right).toBeUndefined()118 expect(stack[2].left).toBeUndefined()119 })120 test('while-command-command-end', () => {121 let input = [122 createCommand(ControlFlowCommandNames.while),123 createCommand('command'),124 createCommand('command'),125 createCommand(ControlFlowCommandNames.end),126 ]127 let stack = createCommandNodesFromCommandStack(input)128 expect(stack[0].next).toBeUndefined()129 expect(stack[0].right).toEqual(stack[1])130 expect(stack[0].left).toEqual(stack[3])131 expect(stack[1].next).toEqual(stack[2])132 expect(stack[1].right).toBeUndefined()133 expect(stack[1].left).toBeUndefined()134 expect(stack[2].next).toEqual(stack[0])135 expect(stack[2].right).toBeUndefined()136 expect(stack[2].left).toBeUndefined()137 expect(stack[3].next).toBeUndefined()138 expect(stack[3].right).toBeUndefined()139 expect(stack[3].left).toBeUndefined()140 })141 test('while-if-end-end', () => {142 let input = [143 createCommand(ControlFlowCommandNames.while), // 0144 createCommand(ControlFlowCommandNames.if), // 1145 createCommand('command'), // 2146 createCommand(ControlFlowCommandNames.end), // 3147 createCommand(ControlFlowCommandNames.end), // 4148 ]149 let stack = createCommandNodesFromCommandStack(input)150 expect(stack[0].next).toBeUndefined()151 expect(stack[0].right).toEqual(stack[1])152 expect(stack[0].left).toEqual(stack[4])153 expect(stack[1].next).toBeUndefined()154 expect(stack[1].right).toEqual(stack[2])155 expect(stack[1].left).toEqual(stack[3])156 expect(stack[2].next).toEqual(stack[3])157 expect(stack[2].right).toBeUndefined()158 expect(stack[2].left).toBeUndefined()159 expect(stack[3].next).toEqual(stack[0])160 expect(stack[3].right).toBeUndefined()161 expect(stack[3].left).toBeUndefined()162 expect(stack[4].next).toBeUndefined()163 expect(stack[4].right).toBeUndefined()164 expect(stack[4].left).toBeUndefined()165 })166 test('while-if-end-command-end', () => {167 let input = [168 createCommand(ControlFlowCommandNames.while), // 0169 createCommand(ControlFlowCommandNames.if), // 1170 createCommand('command'), // 2171 createCommand(ControlFlowCommandNames.end), // 3172 createCommand('command'), // 4173 createCommand(ControlFlowCommandNames.end), // 5174 ]175 let stack = createCommandNodesFromCommandStack(input)176 expect(stack[0].next).toBeUndefined()177 expect(stack[0].right).toEqual(stack[1])178 expect(stack[0].left).toEqual(stack[5])179 expect(stack[1].next).toBeUndefined()180 expect(stack[1].right).toEqual(stack[2])181 expect(stack[1].left).toEqual(stack[3])182 expect(stack[2].next).toEqual(stack[3])183 expect(stack[2].right).toBeUndefined()184 expect(stack[2].left).toBeUndefined()185 expect(stack[3].next).toEqual(stack[4])186 expect(stack[3].right).toBeUndefined()187 expect(stack[3].left).toBeUndefined()188 expect(stack[4].next).toEqual(stack[0])189 expect(stack[4].right).toBeUndefined()190 expect(stack[4].left).toBeUndefined()191 expect(stack[5].next).toBeUndefined()192 expect(stack[5].right).toBeUndefined()193 expect(stack[5].left).toBeUndefined()194 })195 test('if-command-while-command-end-end', () => {196 let input = [197 createCommand(ControlFlowCommandNames.if),198 createCommand('command'),199 createCommand(ControlFlowCommandNames.while),200 createCommand('command'),201 createCommand(ControlFlowCommandNames.end),202 createCommand(ControlFlowCommandNames.end),203 ]204 let stack = createCommandNodesFromCommandStack(input)205 // if206 expect(stack[0].next).toBeUndefined()207 expect(stack[0].right).toEqual(stack[1])208 expect(stack[0].left).toEqual(stack[5])209 // command210 expect(stack[1].next).toEqual(stack[2])211 expect(stack[1].right).toBeUndefined()212 expect(stack[1].left).toBeUndefined()213 // while214 expect(stack[2].next).toBeUndefined()215 expect(stack[2].right).toEqual(stack[3])216 expect(stack[2].left).toEqual(stack[4])217 // command218 expect(stack[3].next).toEqual(stack[2])219 expect(stack[3].right).toBeUndefined()220 expect(stack[3].left).toBeUndefined()221 // end222 expect(stack[4].next).toEqual(stack[5])223 expect(stack[4].right).toBeUndefined()224 expect(stack[4].left).toBeUndefined()225 // end226 expect(stack[5].next).toBeUndefined()227 expect(stack[5].right).toBeUndefined()228 expect(stack[5].left).toBeUndefined()229 })230 test('if-while-command-end-command-else-command-end', () => {231 let input = [232 createCommand(ControlFlowCommandNames.if),233 createCommand(ControlFlowCommandNames.while),234 createCommand('command'),235 createCommand(ControlFlowCommandNames.end),236 createCommand('command'),237 createCommand(ControlFlowCommandNames.else),238 createCommand('command'),239 createCommand(ControlFlowCommandNames.end),240 ]241 let stack = createCommandNodesFromCommandStack(input)242 // if243 expect(stack[0].next).toBeUndefined()244 expect(stack[0].right).toEqual(stack[1])245 expect(stack[0].left).toEqual(stack[5])246 // while247 expect(stack[1].next).toBeUndefined()248 expect(stack[1].right).toEqual(stack[2])249 expect(stack[1].left).toEqual(stack[3])250 // command251 expect(stack[2].next).toEqual(stack[1])252 expect(stack[2].right).toBeUndefined()253 expect(stack[2].left).toBeUndefined()254 // end255 expect(stack[3].next).toEqual(stack[4])256 expect(stack[3].right).toBeUndefined()257 expect(stack[3].left).toBeUndefined()258 // command259 expect(stack[4].next).toEqual(stack[7])260 expect(stack[4].right).toBeUndefined()261 expect(stack[4].left).toBeUndefined()262 // else263 expect(stack[5].next).toEqual(stack[6])264 expect(stack[5].right).toBeUndefined()265 expect(stack[5].left).toBeUndefined()266 // command267 expect(stack[6].next).toEqual(stack[7])268 expect(stack[6].right).toBeUndefined()269 expect(stack[6].left).toBeUndefined()270 // end271 expect(stack[7].next).toBeUndefined()272 expect(stack[7].right).toBeUndefined()273 expect(stack[7].left).toBeUndefined()274 })275 test('do-command-repeatIf-command', () => {276 let input = [277 createCommand(ControlFlowCommandNames.do),278 createCommand('command'),279 createCommand(ControlFlowCommandNames.repeatIf),280 createCommand('command'),281 ]282 let stack = createCommandNodesFromCommandStack(input)283 expect(stack[0].next).toEqual(stack[1])284 expect(stack[0].right).toBeUndefined()285 expect(stack[0].left).toBeUndefined()286 expect(stack[1].next).toEqual(stack[2])287 expect(stack[1].right).toBeUndefined()288 expect(stack[1].left).toBeUndefined()289 expect(stack[2].next).toBeUndefined()290 expect(stack[2].right).toEqual(stack[0])291 expect(stack[2].left).toEqual(stack[3])292 })293 test('do-command-while-command-end-repeatIf', () => {294 let input = [295 createCommand(ControlFlowCommandNames.do),296 createCommand('command'),297 createCommand(ControlFlowCommandNames.while),298 createCommand('command'),299 createCommand(ControlFlowCommandNames.end),300 createCommand(ControlFlowCommandNames.repeatIf),301 ]302 let stack = createCommandNodesFromCommandStack(input)303 expect(stack[0].next).toEqual(stack[1])304 expect(stack[0].right).toBeUndefined()305 expect(stack[0].left).toBeUndefined()306 expect(stack[1].next).toEqual(stack[2])307 expect(stack[1].right).toBeUndefined()308 expect(stack[1].left).toBeUndefined()309 expect(stack[2].next).toBeUndefined()310 expect(stack[2].right).toEqual(stack[3])311 expect(stack[2].left).toEqual(stack[4])312 expect(stack[3].next).toEqual(stack[2])313 expect(stack[3].right).toBeUndefined()314 expect(stack[3].left).toBeUndefined()315 expect(stack[4].next).toEqual(stack[5])316 expect(stack[4].right).toBeUndefined()317 expect(stack[4].left).toBeUndefined()318 expect(stack[5].next).toBeUndefined()319 expect(stack[5].right).toEqual(stack[0])320 expect(stack[5].left).toBeUndefined()321 })322 test('times-command-end', () => {323 let input = [324 createCommand(ControlFlowCommandNames.times),325 createCommand('command'),326 createCommand(ControlFlowCommandNames.end),327 ]328 let stack = createCommandNodesFromCommandStack(input)329 expect(stack[0].next).toBeUndefined()330 expect(stack[0].right).toEqual(stack[1])331 expect(stack[0].left).toEqual(stack[2])332 expect(stack[1].next).toEqual(stack[0])333 expect(stack[1].right).toBeUndefined()334 expect(stack[1].left).toBeUndefined()335 expect(stack[2].next).toBeUndefined()336 expect(stack[2].right).toBeUndefined()337 expect(stack[2].left).toBeUndefined()338 })339 test('forEach-command-end', () => {340 let input = [341 createCommand(ControlFlowCommandNames.forEach),342 createCommand('command'),343 createCommand(ControlFlowCommandNames.end),344 ]345 let stack = createCommandNodesFromCommandStack(input)346 expect(stack[0].next).toBeUndefined()347 expect(stack[0].right).toEqual(stack[1])348 expect(stack[0].left).toEqual(stack[2])349 expect(stack[1].next).toEqual(stack[0])350 expect(stack[1].right).toBeUndefined()351 expect(stack[1].left).toBeUndefined()352 expect(stack[2].next).toBeUndefined()353 expect(stack[2].right).toBeUndefined()354 expect(stack[2].left).toBeUndefined()355 })356 test('if-if-if-if-end-end-end-command-end', () => {357 let input = [358 createCommand(ControlFlowCommandNames.if),359 createCommand(ControlFlowCommandNames.if),360 createCommand(ControlFlowCommandNames.if),361 createCommand(ControlFlowCommandNames.if),362 createCommand(ControlFlowCommandNames.end),363 createCommand(ControlFlowCommandNames.end),364 createCommand(ControlFlowCommandNames.end),365 createCommand('command'),366 createCommand(ControlFlowCommandNames.end),367 ]368 let stack = createCommandNodesFromCommandStack(input)369 expect(stack[0].next).toBeUndefined()370 expect(stack[0].right).toEqual(stack[1])371 expect(stack[0].left).toEqual(stack[8])372 expect(stack[1].next).toBeUndefined()373 expect(stack[1].right).toEqual(stack[2])374 expect(stack[1].left).toEqual(stack[6])375 expect(stack[2].next).toBeUndefined()376 expect(stack[2].right).toEqual(stack[3])377 expect(stack[2].left).toEqual(stack[5])378 expect(stack[3].next).toBeUndefined()379 expect(stack[3].right).toEqual(stack[4])380 expect(stack[3].left).toEqual(stack[4])381 expect(stack[4].next).toEqual(stack[5])382 expect(stack[4].right).toBeUndefined()383 expect(stack[4].left).toBeUndefined()384 expect(stack[5].next).toEqual(stack[6])385 expect(stack[5].right).toBeUndefined()386 expect(stack[5].left).toBeUndefined()387 expect(stack[6].next).toEqual(stack[7])388 expect(stack[6].right).toBeUndefined()389 expect(stack[6].left).toBeUndefined()390 expect(stack[7].next).toEqual(stack[8])391 expect(stack[7].right).toBeUndefined()392 expect(stack[7].left).toBeUndefined()393 expect(stack[8].next).toBeUndefined()394 expect(stack[8].right).toBeUndefined()395 expect(stack[8].left).toBeUndefined()396 })397 })398 })399 describe('Processed', () => {400 it('knows if there are control flow commands within the command stack', () => {401 let input = [402 createCommand(ControlFlowCommandNames.do),403 createCommand('command'),404 createCommand(ControlFlowCommandNames.repeatIf),405 ]406 const tree = createPlaybackTree(input)407 expect(tree.containsControlFlow).toBeTruthy()408 })409 it('do-command-repeatIf-end skips do', () => {410 let input = [411 createCommand(ControlFlowCommandNames.do),412 createCommand('command'),413 createCommand(ControlFlowCommandNames.repeatIf),414 ]415 let tree = createPlaybackTree(input)416 expect(tree.startingCommandNode.command).toEqual(input[0])417 expect(tree.startingCommandNode.next.command).toEqual(input[1])418 expect(tree.startingCommandNode.next.next.command).toEqual(input[2])419 expect(tree.startingCommandNode.next.next.right.command).toEqual(input[0])420 expect(tree.startingCommandNode.next.next.left).toBeUndefined()421 })422 it('populated tree exists with correct values', () => {423 let input = [424 createCommand(ControlFlowCommandNames.if),425 createCommand('command'),426 createCommand(ControlFlowCommandNames.else),427 createCommand(ControlFlowCommandNames.while),428 createCommand('command'),429 createCommand(ControlFlowCommandNames.end),430 createCommand(ControlFlowCommandNames.do),431 createCommand('command'),432 createCommand(ControlFlowCommandNames.while),433 createCommand('command'),434 createCommand(ControlFlowCommandNames.end),435 createCommand(ControlFlowCommandNames.repeatIf),436 createCommand(ControlFlowCommandNames.end),437 ]438 let tree = createPlaybackTree(input)439 expect(tree.startingCommandNode.command).toEqual(input[0]) // if440 expect(tree.startingCommandNode.right.command).toEqual(input[1]) // if -> command441 expect(tree.startingCommandNode.right.next.command).toEqual(input[12]) // if -> end442 expect(tree.startingCommandNode.left.command).toEqual(input[2]) // if -> while -> else443 expect(tree.startingCommandNode.left.next.right.command).toEqual(input[4]) // while -> command444 expect(tree.startingCommandNode.left.next.left.command).toEqual(input[5]) // while -> end445 expect(tree.startingCommandNode.left.next.left.next.command).toEqual(446 input[6]447 ) // do448 expect(449 tree.startingCommandNode.left.next.left.next.next.next.right.command450 ).toEqual(input[9]) // do -> while -> command...

Full Screen

Full Screen

create.js

Source:create.js Github

copy

Full Screen

1const Promise = require('bluebird');2const _ = require('lodash');3const path = require('path');4const { Command, flags } = require('@oclif/command');5const { BaseCommand } = require('oclif-plugin-base');6const { dump } = require('dumper.js');7const spinner = new (require('@geek/spinner'))();8const module_name = path.parse(module.id).name;9const chalk = require('chalk');10const fs = Promise.promisifyAll(require('fs-extra'));11const pathExists = require('path-exists');12const temp = require('temp');13const findit = require('findit');14const { using } = Promise;15const npm = require('@geek/npm');16const globby = require('globby');17const colors = require('colors');18const multimatch = require('multimatch');19const logger = func_name => {20 var prefix = func_name ? `[${module_name}.${func_name}] ` : `[${module_name}`;21 return _.wrap(require('debug')('hero'), (func, msg) => func(chalk.blue(prefix) + msg));22};23const debug = logger();24class CreateCommand extends BaseCommand {25 async run() {26 const { args, flags } = this.parse(CreateCommand);27 args.template = args.template || flags.template || this.compositeConfig.template || '@titanium/template-alloy-default';28 this.checkRequiredArgs(CreateCommand.args, args, flags, [ 'name' ]);29 args.currentYear = new Date().getFullYear();30 args.publisher = args.publisher || this.compositeConfig.publisher || 'my-company';31 if (!args.id) {32 // In order for a name to be safe for both iOS and Android,33 // it can't have anything other than alphanumeric characters.34 const safePublisher = args.publisher.trim().toLowerCase().replace(/[^a-z0-9]+/g, '');35 const safeName = args.name.trim().toLowerCase().replace(/[^a-z0-9]+/g, '');36 args.id = `${safePublisher}.${safeName}`;37 }38 args.id = args.id || `${_.snakeCase(args.publisher.trim()).toLowerCase()}.${_.snakeCase(args.name.trim()).toLowerCase()}`;39 args.path = args.path || path.join(process.cwd(), args.name);40 args.description = args.description || this.compositeConfig.description || 'Another awesome Titanium app!';41 args.guid = args.guid || this.compositeConfig.guid;42 if (args.guid === 'empty-guid') {43 args.guid = '00000000-0000-0000-0000-000000000000';44 // } else if (args.guid === 'new-guid') {45 } else if (_.isNil(args.guid)) {46 const uuidv4 = require('uuid/v4');47 args.guid = uuidv4();48 }49 args.copyright = args.copyright || this.compositeConfig.copyright || `Copyright (c) ${args.currentYear} ${args.publisher}`;50 args.url = args.url || this.compositeConfig.url || '';51 args.author_name = flags.author_name || this.compositeConfig.author_name || args.publisher;52 args.author_email = flags.author_email || this.compositeConfig.author_email || 'nobody@nowhere.com';53 args.author_url = flags.author_url || this.compositeConfig.author_url || args.url;54 args.github_username = flags.github_username || this.compositeConfig.github_username || 'my-github-username';55 args.repo_type = args.repo_type || 'git';56 args.repo_url = args.repo_url || `github:${args.github_username}/${args.name}`;57 args.bugs_url = flags.bugs_url || this.compositeConfig.bugs_url || `https://github.com/${args.github_username}/${args.name}/issues`;58 args.bugs_email = flags.bugs_email || this.compositeConfig.bugs_email || args.author_email;59 args.license = flags.license || this.compositeConfig.license || 'MIT';60 // dump(this.compositeConfig);61 // dump(this.config);62 // dump(args);63 const debug = logger('execute');64 var titanium_directory;65 debug(`args: ${JSON.stringify(args, null, 2)}`);66 debug(`__dirname: ${__dirname}`);67 debug(`process.cwd(): ${process.cwd()}`);68 var project_directory = args['path'];69 debug(`project_directory: ${project_directory}`);70 debug(`project_directory.exists: ${pathExists.sync(project_directory)}`);71 const getTempDirectory = () => {72 const temp_directory = temp.path({ prefix: 'titanium' });73 fs.emptyDirSync(temp_directory);74 debug(`temp_directory: ${JSON.stringify(temp_directory, null, 2)}`);75 return Promise.resolve(temp_directory).disposer((directory, promise) => {76 fs.removeSync(directory);77 });78 };79 const configure_project_directory = () => {80 spinner.start('Configuring project directory');81 return fs.ensureDirAsync(project_directory)82 .then(() => {83 spinner.info();84 spinner.note(project_directory, 1);85 });86 };87 const template_file = filename => {88 const debug = logger('template_file');89 filename = path.join(project_directory, filename);90 debug(`templating file: ${filename}`);91 spinner.start(filename, 2);92 return fs93 .readFileAsync(filename)94 .then(source => fs.writeFileAsync(filename, _.template(source)(args)))95 .then(() => spinner.note());96 };97 const template_other_files = () => {98 const debug = logger('template_other_files');99 spinner.info('Templating other files', 1);100 return Promise.mapSeries([ 'tiapp.xml', 'package.json' ], template_file);101 };102 const findTiappXml = root => {103 const debug = logger('findTiappXml');104 // eslint-disable-next-line promise/avoid-new105 return new Promise((resolve, reject) => {106 spinner.start('Looking for Titanium project file', 1);107 debug(`looking for tiapp.xml in: ${root}`);108 var finder = findit(root);109 finder.on('file', (file, stat) => {110 var filepath = path.parse(file);111 if (filepath.base === 'tiapp.xml') {112 spinner.succeed();113 resolve(filepath.dir);114 finder.stop();115 }116 });117 finder.on('end', () => {118 spinner.fail();119 spinner.fail(chalk.red('Titanium project file not found'), 2);120 reject('Titanium project file not found');121 });122 finder.on('error', error => {123 spinner.fail();124 reject(error);125 });126 }).then(result => {127 titanium_directory = result;128 if (!titanium_directory) {129 spinner.fail(chalk.red('Titanium project file not found'), 2);130 throw new Error('Titanium project file not found');131 }132 spinner.note(titanium_directory, 2);133 });134 };135 const configure_project_files = () => {136 spinner.info('Configuring project files');137 return ensure_package_json()138 .then(() => spinner.start('Finding template files', 1))139 .then(() => globby([ '**/*-template.*', '**/*.*-template' ], { cwd: args.path, onlyFiles: true, deep: true, dot: true }))140 .then(files => {141 spinner.succeed();142 spinner.info('Templating project files', 1);143 return Promise.mapSeries(files, file => {144 const new_filename = file.replace('-template', '');145 return fs146 .copyAsync(path.join(project_directory, file), path.join(project_directory, new_filename), { overwrite: true })147 .then(() => fs.removeSync(path.join(project_directory, file)))148 .then(() => template_file(new_filename));149 });150 });151 };152 const copy_template = name => {153 const debug = logger('copy_template');154 spinner.info('Installing template', 0);155 var source = path.resolve(name);156 debug(`source: ${source}`);157 spinner.start('Checking for local template', 1);158 return pathExists(source).then(exists => {159 debug(`pathExists.sync(source): ${exists}`);160 if (exists) {161 spinner.succeed();162 debug(`copying files to project root directory: ${project_directory}`);163 spinner.start('Copying template to project root directory', 1);164 return fs.copyAsync(source, project_directory, {165 clobber: true,166 filter: file => {167 return true;168 },169 }).then(() => {170 spinner.succeed();171 return true;172 });173 } else {174 spinner.skip();175 spinner.note('Local template not found.', 2);176 return using(getTempDirectory(), temp_directory => {177 const nodeModulesDir = path.join(temp_directory, 'node_modules');178 debug(`installing remote template to: ${project_directory}`);179 spinner.start(`Installing remote template: ${chalk.gray(name)}`, 1);180 return npm181 .install([ name, '--ignore-scripts', '--global-style' ], {182 cwd: temp_directory,183 silent: true,184 })185 .then(() => {186 // eslint-disable-next-line promise/avoid-new187 return new Promise((resolve, reject) => {188 spinner.succeed();189 spinner.start('Examining template', 1);190 var finder = findit(nodeModulesDir);191 finder.on('file', (file, stat) => {192 var filepath = path.parse(file);193 if (_.includes([ 'package.json', 'package-template.json' ], filepath.base)) {194 spinner.succeed();195 resolve(filepath.dir);196 finder.stop();197 }198 });199 });200 })201 .then(template_source => {202 debug(`copying files to project root directory: ${project_directory}`);203 spinner.start('Copying template to project root directory', 1);204 return fs.copyAsync(template_source, project_directory, {205 clobber: true,206 filter: file => {207 const filepath = file.substring(template_source.length);208 return multimatch(filepath, [ '*', '!/package.json' ]);209 },210 }).then(() => {211 spinner.succeed();212 return true;213 });214 });215 });216 }217 });218 };219 const ensure_package_json = () => {220 debug('ensuring that package.json exists in project root');221 spinner.info('Ensuring package.json exists in project root.', 1);222 const packagePath = path.join(project_directory, 'package.json');223 return fs.pathExists(packagePath)224 .then(exists => {225 if (!exists) {226 spinner.warn('package.json not found in project root.');227 spinner.start('creating default package.json in project root', 2);228 const pkg = {229 name: args.id,230 version: '0.0.1',231 description: args.description,232 main: 'index.js',233 scripts: [],234 keywords: [],235 author: args.author || args.publisher,236 license: args.license,237 };238 return fs.outputJsonAsync(packagePath, pkg)239 .then(() => spinner.succeed());240 } else {241 spinner.note('package.json found in project root directory', 2);242 }243 });244 };245 configure_project_directory()246 .then(() => copy_template(args.template))247 .then(() => findTiappXml(project_directory))248 .then(() => configure_project_files())249 .then(() => {250 spinner.start('Installing npm dependencies', 1);251 return npm252 .install({253 cwd: project_directory,254 silent: true,255 })256 .then(() => spinner.succeed());257 })258 .then(template_other_files)259 .catch(err => {260 console.error(`Error occurred: ${err}`);261 console.error(err);262 spinner.fail(err);263 });264 process.on('unhandledRejection', (reason, promise) => {265 console.error(`Error occurred: ${reason}`);266 console.error(reason);267 spinner.fail(reason);268 });269 }270}271CreateCommand.description = `Create a shiny new mobile application272...273Create a new mobile app from a template using all sorts of nifty options!274Tool will create an app using values from parameters or from the user config file which is located here: ~/.config/@geek/mobile/config.json275Future versions of the tool will allow setting config values from CLI.276`;277CreateCommand.topic = 'app';278CreateCommand.id = 'create';279CreateCommand.usagePrefix = `${`mobile ${CreateCommand.topic}:${CreateCommand.id}`.bold.yellow} my-app-name`;280// dump(flags);281CreateCommand.examples = `282${`Create app from template in npm package`.underline}283${CreateCommand.usagePrefix} [@scope/]<name>284${CreateCommand.usagePrefix} [@scope/]<name>@<tag>285${CreateCommand.usagePrefix} [@scope/]<name>@<version>286${CreateCommand.usagePrefix} [@scope/]<name>@<version range>287${`Create app from template in git repo`.underline}288${CreateCommand.usagePrefix} <git-host>:<git-user>/<repo-name>289${CreateCommand.usagePrefix} <git-host>:<git-user>/<repo-name>#<tag>290${CreateCommand.usagePrefix} <git-host>:<git-user>/<repo-name>#<branch>291${CreateCommand.usagePrefix} <git repo url>292${`(where <git-host> can be: github, bitbucket, or gitlab)`.italic}293${`Create app from template in tarball`.underline}294${CreateCommand.usagePrefix} <tarball file>295${CreateCommand.usagePrefix} <tarball url>296${`Create app from template in local directory`.underline}297${CreateCommand.usagePrefix} <folder>298`;299CreateCommand.args = [300 {301 name: 'name',302 required: false,303 description: 'Name of your project',304 },305 {306 name: 'template',307 required: false,308 description: 'Template to use for creating your new app',309 },310];311CreateCommand.flags = {312 template: flags.string({313 char: 't',314 description: '[default: @titanium/template-alloy-default] Template to use for creating your new app',315 required: false,316 }),317 id: flags.string({318 char: 'i',319 description: '[default: Generate from project name] ID for your project',320 required: false,321 }),322 name: flags.string({323 char: 'n',324 description: 'Name of your project',325 required: false,326 }),327 publisher: flags.string({328 char: 'p',329 description: 'Name of person/company publishing app',330 required: false,331 }),332 copyright: flags.string({333 char: 'c',334 description: 'Copyright for your project',335 required: false,336 }),337 description: flags.string({338 char: 'd',339 description: 'Description for your project',340 required: false,341 }),342 url: flags.string({343 char: 'u',344 description: 'URL for your project',345 required: false,346 }),347 path: flags.string({348 char: 'p',349 description: 'Specifies the directory where you want to initialize the project',350 required: false,351 }),352 license: flags.string({353 char: 'l',354 description: 'Specifies the license for the project',355 required: false,356 }),357 github_username: flags.string({358 description: 'Specifies the github username for the project',359 required: false,360 }),361 author_name: flags.string({362 description: 'Specifies the full name of the Author',363 required: false,364 }),365 author_email: flags.string({366 description: 'Specifies the email address of the Author',367 required: false,368 }),369 author_url: flags.string({370 description: 'Specifies the URL for the Author',371 required: false,372 }),373};...

Full Screen

Full Screen

mathcalc_keyboard.js

Source:mathcalc_keyboard.js Github

copy

Full Screen

...19(function () {20 var keyboard = KEYBOARDBUILDER.createKeyboard(6, 6);21 22// keyboard.addSpan(2);23// keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("MATH", "<KB>0"))).addClasses("modekeyboard", "modekeyboardselected").build());24// keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("CONFIG", "<KB>1"))).addClasses("modekeyboard").build());25// keyboard.addSpan(2);26 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton()27 .addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("<EXEC>calculator.radiansfactorswitch()")))28 .addVisitor(KEYBOARDBUILDER.createLabeler("calculator.radiansmodenext"))29 .addClasses("function2keyboard", "textkeyboard").build());30 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton()31 .addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("sin", "sin("),32 KEYBOARDBUILDER.createCommand("asin", "asin(")))33 .addClasses("textkeyboard").build());34 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton()35 .addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("cos", "cos("),36 KEYBOARDBUILDER.createCommand("acos", "acos(")))37 .addClasses("textkeyboard").build());38 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton()39 .addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("tan", "tan("),40 KEYBOARDBUILDER.createCommand("atan", "atan(")))41 .addClasses("textkeyboard").build());42 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(43 KEYBOARDBUILDER.createCommand("log", "log("),44 KEYBOARDBUILDER.createCommand("e\u207F", "exp(")))45 .addClasses("textkeyboard").build()); 46 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("ANS"))).addClasses("textkeyboard").build());47 48 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("("), KEYBOARDBUILDER.createCommand("["))).addClasses("textkeyboard").build());49 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand(","))).addClasses("textkeyboard").build());50 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand(")"), KEYBOARDBUILDER.createCommand("]"))).addClasses("textkeyboard").build()); 51 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("REV", "<REV>"))).addClasses("functionkeyboard", "textkeyboard").build()); 52 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("DEL", "<DEL>"))).addClasses("functionkeyboard", "textkeyboard").build());53 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("AC", "<EXEC>calculator.reset();", "<CLEAR>"))).addClasses("functionkeyboard", "textkeyboard").build());54 55 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("i"), KEYBOARDBUILDER.createCommand("x"))).addClasses("textkeyboard").build());56 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("7"))).addClasses("graykeyboard").build());57 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("8"))).addClasses("graykeyboard").build());58 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("9"))).addClasses("graykeyboard").build());59 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("\u221Ax", "sqrt("))).addClasses("textkeyboard").build());60 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("x\u207F", "^"))).addClasses("textkeyboard").build());61 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("e"), KEYBOARDBUILDER.createCommand("f"))).addClasses("textkeyboard").build());62 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("4"))).addClasses("graykeyboard").build());63 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("5"))).addClasses("graykeyboard").build());64 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("6"))).addClasses("graykeyboard").build());65 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("*"))).build());66 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("/"))).build());67 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("\u03C0", "pi"), KEYBOARDBUILDER.createCommand("="))).addClasses("textkeyboard").build());68 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("1"))).addClasses("graykeyboard").build());69 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("2"))).addClasses("graykeyboard").build());70 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("3"))).addClasses("graykeyboard").build());71 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("+"))).build());72 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("-"))).build());73 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("INV", "<KB>INV"))).addClasses("function2keyboard", "textkeyboard").build());74 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("0"))).addClasses("graykeyboard").build());75 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("."))).addClasses("graykeyboard").build());76 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("EXX", "E"))).addClasses("graykeyboard", "textkeyboard").build());77 keyboard.addButton(CALCBUTTONBUILDER.createCalcButton().addVisitor(KEYBOARDBUILDER.createCommander(KEYBOARDBUILDER.createCommand("ENTER", "<EXEC>calculator.eval(\"%%%%%%\")", "<CLEAR>"))).addClasses("execkeyboard", "textkeyboard").build(), 2);...

Full Screen

Full Screen

syntax-validation.spec.js

Source:syntax-validation.spec.js Github

copy

Full Screen

...15// specific language governing permissions and limitations16// under the License.17import { validateControlFlowSyntax } from '../../src/playback-tree/syntax-validation'18import { ControlFlowCommandNames } from '../../src/playback-tree/commands'19function createCommand(command) {20 return {21 command,22 target: '',23 value: '',24 }25}26describe('Control Flow', () => {27 describe('Preprocess', () => {28 describe('Syntax Validation', () => {29 test('if, end', () => {30 let result = validateControlFlowSyntax([31 createCommand(ControlFlowCommandNames.if),32 createCommand(ControlFlowCommandNames.end),33 ])34 expect(result).toBeTruthy()35 })36 test('if, else, end', () => {37 let result = validateControlFlowSyntax([38 createCommand(ControlFlowCommandNames.if),39 createCommand(ControlFlowCommandNames.else),40 createCommand(ControlFlowCommandNames.end),41 ])42 expect(result).toBeTruthy()43 })44 test('if, elseIf, end', () => {45 let result = validateControlFlowSyntax([46 createCommand(ControlFlowCommandNames.if),47 createCommand(ControlFlowCommandNames.elseIf),48 createCommand(ControlFlowCommandNames.end),49 ])50 expect(result).toBeTruthy()51 })52 test('if, elseIf, else, end', () => {53 let result = validateControlFlowSyntax([54 createCommand(ControlFlowCommandNames.if),55 createCommand(ControlFlowCommandNames.elseIf),56 createCommand(ControlFlowCommandNames.else),57 createCommand(ControlFlowCommandNames.end),58 ])59 expect(result).toBeTruthy()60 })61 test('while, end', () => {62 let result = new validateControlFlowSyntax([63 createCommand(ControlFlowCommandNames.while),64 createCommand(ControlFlowCommandNames.end),65 ])66 expect(result).toBeTruthy()67 })68 test('times, end', () => {69 let result = validateControlFlowSyntax([70 createCommand('times'),71 createCommand(ControlFlowCommandNames.end),72 ])73 expect(result).toBeTruthy()74 })75 test('do, repeatIf', () => {76 let result = validateControlFlowSyntax([77 createCommand(ControlFlowCommandNames.do),78 createCommand(ControlFlowCommandNames.repeatIf),79 ])80 expect(result).toBeTruthy()81 })82 test('do, while, end, repeatIf', () => {83 let result = validateControlFlowSyntax([84 createCommand(ControlFlowCommandNames.do),85 createCommand(ControlFlowCommandNames.while),86 createCommand(ControlFlowCommandNames.end),87 createCommand(ControlFlowCommandNames.repeatIf),88 ])89 expect(result).toBeTruthy()90 })91 })92 describe('Syntax Invalidation', () => {93 test('if', () => {94 let input = [createCommand(ControlFlowCommandNames.if)]95 expect(function() {96 validateControlFlowSyntax(input)97 }).toThrow('Incomplete block at if')98 })99 test('if, if, end', () => {100 let input = [101 createCommand(ControlFlowCommandNames.if),102 createCommand(ControlFlowCommandNames.if),103 createCommand(ControlFlowCommandNames.end),104 ]105 expect(function() {106 validateControlFlowSyntax(input)107 }).toThrow('Incomplete block at if')108 })109 test('if, else, elseIf, end', () => {110 let input = [111 createCommand(ControlFlowCommandNames.if),112 createCommand(ControlFlowCommandNames.else),113 createCommand(ControlFlowCommandNames.elseIf),114 createCommand(ControlFlowCommandNames.end),115 ]116 expect(function() {117 validateControlFlowSyntax(input)118 }).toThrow('Incorrect command order of else if / else')119 })120 test('if, else, else, end', () => {121 let input = [122 createCommand(ControlFlowCommandNames.if),123 createCommand(ControlFlowCommandNames.else),124 createCommand(ControlFlowCommandNames.else),125 createCommand(ControlFlowCommandNames.end),126 ]127 expect(function() {128 validateControlFlowSyntax(input)129 }).toThrow('Too many else commands used')130 })131 test('else', () => {132 let input = [createCommand(ControlFlowCommandNames.else)]133 expect(function() {134 validateControlFlowSyntax(input)135 }).toThrow('An else used outside of an if block')136 })137 test('else, else', () => {138 let input = [139 createCommand(ControlFlowCommandNames.else),140 createCommand(ControlFlowCommandNames.else),141 ]142 expect(function() {143 validateControlFlowSyntax(input)144 }).toThrow('An else used outside of an if block')145 })146 test('elseIf', () => {147 let input = [createCommand(ControlFlowCommandNames.elseIf)]148 expect(function() {149 validateControlFlowSyntax(input)150 }).toThrow('An else if used outside of an if block')151 })152 test('while', () => {153 let input = [createCommand(ControlFlowCommandNames.while)]154 expect(function() {155 validateControlFlowSyntax(input)156 }).toThrow('Incomplete block at while')157 })158 test('if, while', () => {159 let input = [160 createCommand(ControlFlowCommandNames.if),161 createCommand(ControlFlowCommandNames.while),162 ]163 expect(function() {164 validateControlFlowSyntax(input)165 }).toThrow('Incomplete block at while')166 })167 test('if, while, end', () => {168 let input = [169 createCommand(ControlFlowCommandNames.if),170 createCommand(ControlFlowCommandNames.while),171 createCommand(ControlFlowCommandNames.end),172 ]173 expect(function() {174 validateControlFlowSyntax(input)175 }).toThrow('Incomplete block at if')176 })177 test('if, while, else, end', () => {178 let input = [179 createCommand(ControlFlowCommandNames.if),180 createCommand(ControlFlowCommandNames.while),181 createCommand(ControlFlowCommandNames.else),182 createCommand(ControlFlowCommandNames.end),183 ]184 expect(function() {185 validateControlFlowSyntax(input)186 }).toThrow('An else used outside of an if block')187 })188 test('times', () => {189 let input = [createCommand('times')]190 expect(function() {191 validateControlFlowSyntax(input)192 }).toThrow('Incomplete block at times')193 })194 test('forEach', () => {195 let input = [createCommand(ControlFlowCommandNames.forEach)]196 expect(function() {197 validateControlFlowSyntax(input)198 }).toThrow(`Incomplete block at ${ControlFlowCommandNames.forEach}`)199 })200 test('repeatIf', () => {201 let input = [createCommand(ControlFlowCommandNames.repeatIf)]202 expect(function() {203 validateControlFlowSyntax(input)204 }).toThrow('A repeat if used without a do block')205 })206 test('do', () => {207 let input = [createCommand(ControlFlowCommandNames.do)]208 expect(function() {209 validateControlFlowSyntax(input)210 }).toThrow('Incomplete block at do')211 })212 test('end', () => {213 let input = [createCommand(ControlFlowCommandNames.end)]214 expect(function() {215 validateControlFlowSyntax(input)216 }).toThrow('Use of end without an opening keyword')217 })218 })219 })...

Full Screen

Full Screen

CommandFactory.js

Source:CommandFactory.js Github

copy

Full Screen

...64 * @method createCommand65 * @param {app.model.function.AbstractValueModel} abstractValueModel66 * @return {support.command.AbstractCommand} createdCommand67 */68app.factory.CommandFactory.prototype.createCommand = function createCommand(abstractValueModel) {69 var result = null,70 functionEnumValue = abstractValueModel.getFunctionEnumValue();71 switch (functionEnumValue) {72 case app.enum.FunctionEnum.EQUAL:73 {74 result = new app.command.ConditionEqualCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this.createCommand(abstractValueModel.getFunctionAttributes()[1]));75 break;76 }77 case app.enum.FunctionEnum.EQUAL_OR_GREATER:78 {79 result = new app.command.ConditionEqualOrGreaterCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this.createCommand(abstractValueModel.getFunctionAttributes()[1]));80 break;81 }82 case app.enum.FunctionEnum.GET_EVENT_ENTITY:83 {84 result = new app.command.GetEventEntityModelCommand(this._globalEventListener);85 break;86 }87 case app.enum.FunctionEnum.GET_ENTITY_PROPERTY:88 {89 result = new app.command.GetEntityPropertyCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this.createCommand(abstractValueModel.getFunctionAttributes()[1]));90 break;91 }92 case app.enum.FunctionEnum.GET_UNIT_COUNT:93 {94 result = new app.command.GetUnitCountCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this._entityModelList);95 break;96 }97 case app.enum.FunctionEnum.SHOW_CONSOLE_LOG:98 {99 result = new app.command.ShowConsoleLogCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]));100 break;101 }102 case app.enum.FunctionEnum.TURN_OFF_TRIGGER:103 {104 result = new app.command.TurnOffTriggerCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this._triggerModelList);105 break;106 }107 case app.enum.FunctionEnum.TURN_ON_TRIGGER:108 {109 result = new app.command.TurnOnTriggerCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]), this._triggerModelList);110 break;111 }112 case app.enum.FunctionEnum.GET_RESOURCES_VALUE:113 {114 result = new app.command.GetResourcesValueCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]) /*team*/, this.createCommand(abstractValueModel.getFunctionAttributes()[1]) /*resourceName*/, this._teamListModel);115 break;116 }117 case app.enum.FunctionEnum.CHANGE_OBJECTIVE_RESULT:118 {119 result = new app.command.ChangeObjectiveResultCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]) /*objectiveId*/, this.createCommand(abstractValueModel.getFunctionAttributes()[1]) /*objectiveresult*/, this._objectiveListModel);120 break;121 }122 case app.enum.FunctionEnum.GET_VARIABLE_VALUE:123 {124 result = new app.command.GetVariableValueCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]) /*variableId*/, this._variableListModel);125 break;126 }127 case app.enum.FunctionEnum.INCREMENT_VARIABLE_VALUE:128 {129 result = new app.command.IncrementVariableValueCommand(this.createCommand(abstractValueModel.getFunctionAttributes()[0]) /*variableId*/, this._variableListModel);130 break;131 }132 case app.enum.FunctionEnum.ALL_OBJECTIVES_COMPLETED:133 {134 result = new app.command.AllObjectivesCompletedCommand(this._objectiveListModel);135 break;136 }137 case app.enum.FunctionEnum.SHOW_VICTORY_POPUP:138 {139 result = new app.command.ShowVictoryPopupCommand();140 break;141 }142 case app.enum.FunctionEnum.MOVE:143 {144 result = new app.command.MoveCommand( this.createCommand(abstractValueModel.getFunctionAttributes()[0]) /*EntityId*/, this.createCommand(abstractValueModel.getFunctionAttributes()[1]) /*"destinationX"*/, this.createCommand(abstractValueModel.getFunctionAttributes()[2]) /*destinationX*/, this.createCommand(abstractValueModel.getFunctionAttributes()[3]) /*targetEntityId*/);145 break;146 }147 case app.enum.FunctionEnum.VALUE:148 {149 result = new app.command.AttributeCommand(abstractValueModel.getValue());150 break;151 }152 }153 return result;...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

2import * as Commands from './commands';3import { program } from 'commander';4// METADATA COMMANDS5// Local Commands6Commands.Metadata.LocalCompress.createCommand(program);7Commands.Metadata.LocalIgnore.createCommand(program);8Commands.Metadata.LocalList.createCommand(program);9Commands.Metadata.LocalDescribe.createCommand(program);10//Commands.Metadata.LocalCompare.createCommand(program);11Commands.Metadata.LocalRepair.createCommand(program);12Commands.Metadata.LocalPackageGenerator.createCommand(program);13Commands.Metadata.LocalRetrieveSpecial.createCommand(program);14// TODO: Get queriable objects (refresh metadata index) (all and specifics)15// OrgCommands16Commands.Metadata.OrgList.createCommand(program);17Commands.Metadata.OrgDescribe.createCommand(program);18Commands.Metadata.OrgCompare.createCommand(program);19Commands.Metadata.OrgBetweenCompare.createCommand(program);20Commands.Metadata.OrgRetrieveSpecial.createCommand(program);21Commands.Metadata.OrgPermissions.createCommand(program);22Commands.Metadata.OrgApexExecutor.createCommand(program);23// DATA COMMANDS24Commands.Data.Export.createCommand(program);25Commands.Data.Import.createCommand(program);26// Core Commands27Commands.Core.Update.createCommand(program);28Commands.Core.Version.createCommand(program);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const createTestCafe = require('testcafe');2let testcafe = null;3createTestCafe('localhost', 1337, 1338)4 .then(tc => {5 testcafe = tc;6 const runner = testcafe.createRunner();7 .src(['test.js'])8 .browsers(['chrome'])9 .run();10 })11 .then(failedCount => {12 console.log('Tests failed: ' + failedCount);13 testcafe.close();14 });15 ('My test', async t => {16 });17 ('My test', async t => {18 });19 ('My second test', async t => {20 });21test('My test', async t => {22});23test('My second test', async t => {24});25test('My test', async t => {26});27test('My second test', async t => {28});29test('My test', async t => {30});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button');5});6import { Selector } from 'testcafe';7test('My first test', async t => {8 .typeText('#developer-name', 'John Smith')9 .click('#submit-button')10 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');11});12import { Selector } from 'testcafe';13test('My first test', async t => {14 .typeText('#developer-name', 'John Smith')15 .click('#submit-button');16 const articleHeader = await Selector('#article-header');17 let headerText = await articleHeader.innerText;18 let id = await articleHeader.id;19});20import { Selector } from 'testcafe';21test('My first test', async t => {22 const articleHeader = Selector('#article-header');23 let headerText = await articleHeader.innerText;24 let id = await articleHeader.id;25});26import { Selector } from 'testcafe';27test('My first test', async t => {28 const articleHeader = Selector('#article-header');29 let headerText = await articleHeader.innerText;30 let id = await articleHeader.id;31});32import { Selector } from

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button');5});6import { Selector } from 'testcafe';7import { ClientFunction } from 'testcafe';8test('My first test', async t => {9 .typeText('#developer-name', 'John Smith')10 .click('#submit-button');11 const articleHeader = await Selector('.result-content').find('h1');12 let headerText = await articleHeader.innerText;13});14import { Selector } from 'testcafe';15import { ClientFunction } from 'testcafe';16test('My first test', async t => {17 .typeText('#developer-name', 'John Smith')18 .click('#submit-button');19 const articleHeader = await Selector('.result-content').find('h1');20 let headerText = await articleHeader.innerText;21 const getWindowDimensions = ClientFunction(() => {22 return {23 };24 });25 const windowDimensions = await getWindowDimensions();26 console.log('Width: ' + windowDimensions.width);27 console.log('Height: ' + windowDimensions.height);28});29import { Selector } from 'testcafe';30import { ClientFunction } from 'testcafe';31test('My first test', async t => {32 .typeText('#developer-name', 'John Smith')33 .click('#submit-button');34 const articleHeader = await Selector('.result-content').find('h1');35 let headerText = await articleHeader.innerText;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button')5 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9 .typeText('#developer-name', 'John Smith')10 .click('#submit-button')11 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');12});13import { Selector, ClientFunction } from 'testcafe';14test('My first test', async t => {15 const getLocation = ClientFunction(() => document.location.href);16 .typeText('#developer-name', 'John Smith')17 .click('#submit-button')18 .expect(getLocation()).contains('thank-you');19});20import { Selector, RequestLogger } from 'testcafe';21const logger = RequestLogger({ url: /\/api\/users/ }, {22});23 .requestHooks(logger);24test('My test', async t => {25 .click('#send-request');26 const entry = logger.requests[0];27 console.log(entry.request.headers);28 console.log(entry.response.statusCode);29 console.log(entry.response.headers);30 console.log(entry.response.body);31});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button')5 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9 .typeText('#developer-name', 'John Smith')10 .click('#submit-button')11 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15 .typeText('#developer-name', 'John Smith')16 .click('#submit-button')17 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');18});19import { Selector } from 'testcafe';20test('My first test', async t => {21 .typeText('#developer-name', 'John Smith')22 .click('#submit-button')23 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');24});25import { Selector } from 'testcafe';26test('My first test', async t => {27 .typeText('#developer-name', 'John Smith')28 .click('#submit-button')29 .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');30});

Full Screen

Using AI Code Generation

copy

Full Screen

1test('My first test', async t => {2 .typeText('#developer-name', 'John Smith')3 .click('#macos')4 .click('#submit-button');5});6const createTestCafe = require('testcafe');7let testcafe = null;8createTestCafe('localhost', 1337, 1338)9 .then(tc => {10 testcafe = tc;11 const runner = testcafe.createRunner();12 .src('test.js')13 .browsers('chrome')14 .run();15 })16 .then(failedCount => {17 console.log('Tests failed: ' + failedCount);18 testcafe.close();19 });20const createTestCafe = require('testcafe');21createTestCafe('localhost', 1337, 1338)22 .then(testcafe => {23 const runner = testcafe.createRunner();24 .src('test.js')25 .browsers('chrome')26 .run();27 const remoteConnection = testcafe.createBrowserConnection();28 .on('ready', () => {29 console.log('Remote browser is connected. We can open the page now.');30 .openBrowser(remoteConnection.url, 'chrome')31 .then(() => {32 console.log('The remote browser is opened.');33 });34 })35 .on('closed', () => {36 console.log('Connection closed');37 });38 console.log('To connect remote browser, use the following URL:');39 console.log(remoteConnection.url);40 });41const createTestCafe = require('testcafe');42createTestCafe('localhost', 1337, 1338)43 .then(testcafe => {44 const liveModeRunner = testcafe.createLiveModeRunner();45 .src('test.js')46 .browsers('chrome')47 .run();48 });49const createTestCafe = require('test

Full Screen

Using AI Code Generation

copy

Full Screen

1const createTestCafe = require('testcafe');2const fs = require('fs');3const { Selector } = require('testcafe');4const { ClientFunction } = require('testcafe');5const { t } = require('testcafe');6let testcafe = null;7createTestCafe('localhost', 1337, 1338)8 .then(tc => {9 testcafe = tc;10 const runner = testcafe.createRunner();11 .src(['test.js'])12 .browsers(['chrome'])13 .run();14 })15 .then(failedCount => {16 console.log('Tests failed: ' + failedCount);17 testcafe.close();18 });19test('My first test', async t => {20});21import { Selector } from 'testcafe';22test('My first test', async t => {23 const developerNameInput = Selector('#developer-name');24 const submitButton = Selector('#submit-button');25 .typeText(developerNameInput, 'John Smith')26 .click(submitButton)27});28import { Selector } from 'testcafe';29const developerNameInput = Selector('#developer-name');30const submitButton = Selector('#submit-button');31test('My first test', async t => {32 .typeText(developerNameInput, 'John Smith')33 .click(submitButton)34});35import { Selector } from 'testcafe';36const developerNameInput = Selector('#developer-name');37const submitButton = Selector('#submit-button');38const articleHeader = Selector('#article-header');39test('My first test', async t => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {Selector} from 'testcafe';2fixture('Login Fixture')3test('Login Test', async t => {4 .typeText(Selector('#username'), 'admin')5 .typeText(Selector('#password'), 'admin')6 .click(Selector('button').withText('Login'));7});8import {Selector} from 'testcafe';9fixture('Login Fixture')10test('Login Test', async t => {11 .typeText(Selector('#username'), 'admin')12 .typeText(Selector('#password'), 'admin')13 .click(Selector('button').withText('Login'));14});15import {Selector} from 'testcafe';16fixture('Login Fixture')17test('Login Test', async t => {18 .typeText(Selector('#username'), 'admin')19 .typeText(Selector('#password'), 'admin')20 .click(Selector('button').withText('Login'));21});22import {Selector} from 'testcafe';23fixture('Login Fixture')24test('Login Test', async t => {25 .typeText(Selector('#username'), 'admin')26 .typeText(Selector('#password'), 'admin')27 .click(Selector('button').withText('Login'));28});29import {Selector} from 'testcafe';30fixture('Login Fixture')31test('Login Test', async t => {32 .typeText(Selector('#username'), 'admin')33 .typeText(Selector('#password'), 'admin')

Full Screen

Using AI Code Generation

copy

Full Screen

1import { createCommand } from 'testcafe';2export const click = createCommand({3 run: (t, selector) => {4 return t.click(selector);5 },6 dependencies: { selector: Selector }7});8import { Selector } from 'testcafe';9test('My test', async t => {10 await t.click('#populate');11});12import { Selector, ClientFunction } from 'testcafe';13test('My test', async t => {14 await t.click('#populate');15});16import { Selector, ClientFunction } from 'testcafe';17test('My test', async t => {18 await t.click('#populate');19});20import { Selector, ClientFunction } from 'testcafe';21test('My test', async t => {22 await t.click('#populate');23});24import { Selector, ClientFunction } from 'testcafe';25test('My test', async t => {26 await t.click('#populate');27});28import { Selector, ClientFunction } from 'testcafe';29test('My test', async t => {30 await t.click('#populate');31});32import { Selector, ClientFunction } from 'testcafe';33test('My test', async t => {34 await t.click('#populate');35});36import { Selector, ClientFunction } from 'test

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

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful