How to use _goBack method in Playwright Internal

Best JavaScript code snippet using playwright-internal

XPath.test.js

Source:XPath.test.js Github

copy

Full Screen

1const fs = require('fs');2const diff = require('jest-diff');3const { DOMParser } = require('xmldom');4const ml = require('@ryel/multiline');5const XML = require('@ryel/xml');6const {7 ForwardAxis,8 Fn,9 Scope,10 Predicate,11 PathExpr,12 evaluate,13} = require('./XPath');14function toString (node) {15 return XML.prettify(node.toString());16}17expect.extend({18 toEqualXML (received, expected) {19 received = toString(received);20 expected = ml(expected);21 const pass = received === expected;22 const message = () => diff(expected, received);23 return { pass, message };24 },25});26describe('Scope', () => {27 it('Should find the closing index of a character, with no other scopes', () => {28 const received = Scope.indexOfClosing('()', Scope.Round);29 expect(received).toBe('()'.indexOf(')'));30 });31 it('Should find the closing index of a character, with other scopes', () => {32 const roundString = '(fn:true())';33 const round = Scope.indexOfClosing(roundString, Scope.Round);34 expect(round).toBe(roundString.indexOf(')', roundString.indexOf(')') + 1));35 const squareString = '(/w:p[fn:position()=1])';36 const square = Scope.indexOfClosing(squareString, Scope.Round);37 expect(square).toBe(squareString.indexOf(')', squareString.indexOf(')') + 1));38 });39});40describe('Parsing', () => {41 it('Should parse a child axis and name test', () => {42 const parsedPathExpr = PathExpr.parse('/w:document/w:body/w:p/w:bookmarkStart');43 expect(parsedPathExpr).toEqual([44 {45 PrimaryExpr: [ {46 Function: 'root',47 Arguments: [48 [ {49 Step: {50 ForwardAxis: 'self',51 NodeTest: {52 AnyKindTest: [53 '*',54 ],55 },56 },57 PredicateList: [],58 } ],59 ],60 PredicateList: [],61 } ],62 PredicateList: [],63 },64 {65 Step: {66 ForwardAxis: ForwardAxis.child,67 NodeTest: {68 NameTest: 'w:document',69 },70 },71 PredicateList: [],72 },73 {74 Step: {75 ForwardAxis: ForwardAxis.child,76 NodeTest: {77 NameTest: 'w:body',78 },79 },80 PredicateList: [],81 },82 {83 Step: {84 ForwardAxis: ForwardAxis.child,85 NodeTest: {86 NameTest: 'w:p',87 },88 },89 PredicateList: [],90 },91 {92 Step: {93 ForwardAxis: ForwardAxis.child,94 NodeTest: {95 NameTest: 'w:bookmarkStart',96 },97 },98 PredicateList: [],99 },100 ]);101 });102 it('Should parse a descendant axis and name test', () => {103 const parsedPathExpr = PathExpr.parse('//w:bookmarkStart');104 expect(parsedPathExpr).toEqual([105 {106 PrimaryExpr: [ {107 Function: 'root',108 Arguments: [109 [ {110 Step: {111 ForwardAxis: 'self',112 NodeTest: {113 AnyKindTest: [114 '*',115 ],116 },117 },118 PredicateList: [],119 } ],120 ],121 PredicateList: [],122 } ],123 PredicateList: [],124 },125 {126 Step: {127 ForwardAxis: ForwardAxis['descendant-or-self'],128 NodeTest: {129 AnyKindTest: [130 '*',131 ],132 },133 },134 PredicateList: [],135 },136 {137 Step: {138 ForwardAxis: ForwardAxis.child,139 NodeTest: {140 NameTest: 'w:bookmarkStart',141 },142 },143 PredicateList: [],144 },145 ]);146 });147 it('Should parse a position predicate', () => {148 const parsedPathExpr = PathExpr.parse('//w:p[1]/w:bookmarkStart');149 expect(parsedPathExpr).toEqual([150 {151 PrimaryExpr: [ {152 Function: 'root',153 Arguments: [154 [ {155 Step: {156 ForwardAxis: 'self',157 NodeTest: {158 AnyKindTest: [159 '*',160 ],161 },162 },163 PredicateList: [],164 } ],165 ],166 PredicateList: [],167 } ],168 PredicateList: [],169 },170 {171 Step: {172 ForwardAxis: ForwardAxis['descendant-or-self'],173 NodeTest: {174 AnyKindTest: [175 '*',176 ],177 },178 },179 PredicateList: [],180 },181 {182 Step: {183 ForwardAxis: ForwardAxis.child,184 NodeTest: {185 NameTest: 'w:p',186 },187 },188 PredicateList: [189 [ {190 Literal: 1,191 } ],192 ],193 },194 {195 Step: {196 ForwardAxis: ForwardAxis.child,197 NodeTest: {198 NameTest: 'w:bookmarkStart',199 },200 },201 PredicateList: [],202 },203 ]);204 });205 it('Should parse an attribute axis', () => {206 const parsedPathExpr = PathExpr.parse('//w:p[1]/w:bookmarkStart/attribute::*');207 expect(parsedPathExpr).toEqual([208 {209 PrimaryExpr: [ {210 Function: 'root',211 Arguments: [212 [ {213 Step: {214 ForwardAxis: 'self',215 NodeTest: {216 AnyKindTest: [217 '*',218 ],219 },220 },221 PredicateList: [],222 } ],223 ],224 PredicateList: [],225 } ],226 PredicateList: [],227 },228 {229 Step: {230 ForwardAxis: ForwardAxis['descendant-or-self'],231 NodeTest: {232 AnyKindTest: [233 '*',234 ],235 },236 },237 PredicateList: [],238 },239 {240 Step: {241 ForwardAxis: ForwardAxis.child,242 NodeTest: {243 NameTest: 'w:p',244 },245 },246 PredicateList: [247 [ {248 Literal: 1,249 } ],250 ],251 },252 {253 Step: {254 ForwardAxis: ForwardAxis.child,255 NodeTest: {256 NameTest: 'w:bookmarkStart',257 },258 },259 PredicateList: [],260 },261 {262 Step: {263 ForwardAxis: ForwardAxis.attribute,264 NodeTest: {265 NameTest: '*',266 },267 },268 PredicateList: [],269 },270 ]);271 });272 it('Should parse an attribute predicate', () => {273 const parsedPathExpr = PathExpr.parse('//w:p[@w14:paraId="604A9B26"]');274 expect(parsedPathExpr).toEqual([275 {276 PrimaryExpr: [ {277 Function: 'root',278 Arguments: [279 [ {280 Step: {281 ForwardAxis: 'self',282 NodeTest: {283 AnyKindTest: [284 '*',285 ],286 },287 },288 PredicateList: [],289 } ],290 ],291 PredicateList: [],292 } ],293 PredicateList: [],294 },295 {296 Step: {297 ForwardAxis: ForwardAxis['descendant-or-self'],298 NodeTest: {299 AnyKindTest: [300 '*',301 ],302 },303 },304 PredicateList: [],305 },306 {307 Step: {308 ForwardAxis: ForwardAxis.child,309 NodeTest: {310 NameTest: 'w:p',311 },312 },313 PredicateList: [314 [ {315 ComparisonExpr: {316 Left: [ {317 Step: {318 ForwardAxis: ForwardAxis.attribute,319 NodeTest: {320 NameTest: 'w14:paraId',321 },322 },323 PredicateList: [],324 } ],325 Right: [ {326 Literal: '604A9B26',327 } ],328 Operator: '=',329 },330 } ],331 ],332 },333 ]);334 });335 it('Should parse a following sibling axis and name test', () => {336 const parsedPathExpr = PathExpr.parse('//w:p[1]/w:pPr/following-sibling::w:bookmarkStart');337 expect(parsedPathExpr).toEqual([338 {339 PrimaryExpr: [ {340 Function: 'root',341 Arguments: [342 [ {343 Step: {344 ForwardAxis: 'self',345 NodeTest: {346 AnyKindTest: [347 '*',348 ],349 },350 },351 PredicateList: [],352 } ],353 ],354 PredicateList: [],355 } ],356 PredicateList: [],357 },358 {359 Step: {360 ForwardAxis: ForwardAxis['descendant-or-self'],361 NodeTest: {362 AnyKindTest: [363 '*',364 ],365 },366 },367 PredicateList: [],368 },369 {370 Step: {371 ForwardAxis: ForwardAxis.child,372 NodeTest: {373 NameTest: 'w:p',374 },375 },376 PredicateList: [377 [ {378 Literal: 1,379 } ],380 ],381 },382 {383 Step: {384 ForwardAxis: ForwardAxis.child,385 NodeTest: {386 NameTest: 'w:pPr',387 },388 },389 PredicateList: [],390 },391 {392 Step: {393 ForwardAxis: ForwardAxis['following-sibling'],394 NodeTest: {395 NameTest: 'w:bookmarkStart',396 },397 },398 PredicateList: [],399 },400 ]);401 });402 it('Should error', () => {403 expect(() => PathExpr.parse('')).toThrow('A path expression is required.');404 expect(() => PathExpr.parse('/w:p=')).toThrow('/w:p= is an invalid path expression.');405 expect(() => PathExpr.parse('/1')).toThrow('1 is an invalid name.');406 expect(() => PathExpr.parse('/w:p(')).toThrow('w:p( is an invalid name.');407 expect(() => PathExpr.parse('/w:p[')).toThrow('No closing ] found.');408 });409});410describe('Evaluating', () => {411 describe('Functions', () => {412 describe('Boolean', () => {413 it('Should return false if its operand is an empty sequence', () => {414 expect(Fn.boolean([])).toBe(false);415 });416 it('Should return true if its operand is a sequence whose first item is a node', () => {417 expect(Fn.boolean([ {} ])).toBe(true);418 });419 it('Should return the operand unchanged if its operand is a boolean', () => {420 expect(Fn.boolean(true)).toBe(true);421 expect(Fn.boolean(false)).toBe(false);422 });423 it('Should return false if its operand is a string and has 0 length', () => {424 expect(Fn.boolean('')).toBe(false);425 });426 it('Should return true if its operand is a string and has > 0 length', () => {427 expect(Fn.boolean(' ')).toBe(true);428 });429 it('Should return false if its operand is a number and is NaN or equal to 0', () => {430 expect(Fn.boolean(0)).toBe(false);431 });432 it('Should return true if its operand is a number and is not NaN or 0', () => {433 expect(Fn.boolean(-0.1)).toBe(true);434 });435 it('Should raise a type error in all other cases', () => {436 expect(() => Fn.boolean({})).toThrow('Invalid argument type');437 });438 });439 });440 describe('Predicates', () => {441 it('Should evaluate to a boolean', () => {442 const Context = {443 Item: undefined,444 Position: 1,445 Size: 1,446 };447 const truthy = Predicate.evaluate({448 Context,449 PathExpr: [ { Literal: 1.2 } ],450 });451 expect(truthy).toBe(true);452 const falsy = Predicate.evaluate({453 Context,454 PathExpr: [ { Literal: '' } ],455 });456 expect(falsy).toBe(false);457 });458 });459 describe('Path expressions', () => {460 let document;461 beforeAll(() => {462 const documentXml = fs.readFileSync('./fixtures/document.xml', 'utf8');463 document = new DOMParser().parseFromString(documentXml);464 });465 describe('That are already parsed', () => {466 it('Should evaluate a child axis and name test', () => {467 const ItemSequence = PathExpr.evaluate({468 Context: {469 Item: document,470 Size: undefined,471 Position: undefined,472 },473 PathExpr: [474 {475 PrimaryExpr: [ {476 Function: 'root',477 Arguments: [478 [ {479 Step: {480 ForwardAxis: 'self',481 NodeTest: {482 AnyKindTest: [483 '*',484 ],485 },486 },487 PredicateList: [],488 } ],489 ],490 PredicateList: [],491 } ],492 PredicateList: [],493 },494 {495 Step: {496 ForwardAxis: ForwardAxis.child,497 NodeTest: {498 NameTest: 'w:document',499 },500 },501 PredicateList: [],502 },503 {504 Step: {505 ForwardAxis: ForwardAxis.child,506 NodeTest: {507 NameTest: 'w:body',508 },509 },510 PredicateList: [],511 },512 {513 Step: {514 ForwardAxis: ForwardAxis.child,515 NodeTest: {516 NameTest: 'w:p',517 },518 },519 PredicateList: [],520 },521 {522 Step: {523 ForwardAxis: ForwardAxis.child,524 NodeTest: {525 NameTest: 'w:bookmarkStart',526 },527 },528 PredicateList: [],529 },530 ],531 });532 expect(ItemSequence).toHaveLength(1);533 expect(ItemSequence[0]).toEqualXML(`534 <w:bookmarkStart535 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"536 w:name="_GoBack"537 w:id="0"538 />539 `);540 });541 it('Should evaluate a descendant axis and name test', () => {542 const ItemSequence = PathExpr.evaluate({543 Context: {544 Item: document,545 Size: undefined,546 Position: undefined,547 },548 PathExpr: [549 {550 PrimaryExpr: [ {551 Function: 'root',552 Arguments: [553 [ {554 Step: {555 ForwardAxis: 'self',556 NodeTest: {557 AnyKindTest: [558 '*',559 ],560 },561 },562 PredicateList: [],563 } ],564 ],565 PredicateList: [],566 } ],567 PredicateList: [],568 },569 {570 Step: {571 ForwardAxis: ForwardAxis['descendant-or-self'],572 NodeTest: {573 AnyKindTest: [574 '*',575 ],576 },577 },578 PredicateList: [],579 },580 {581 Step: {582 ForwardAxis: ForwardAxis.child,583 NodeTest: {584 NameTest: 'w:bookmarkStart',585 },586 },587 PredicateList: [],588 },589 ],590 });591 expect(ItemSequence).toHaveLength(1);592 expect(ItemSequence[0]).toEqualXML(`593 <w:bookmarkStart594 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"595 w:name="_GoBack"596 w:id="0"597 />598 `);599 });600 it('Should evaluate a position predicate', () => {601 const ItemSequence = PathExpr.evaluate({602 Context: {603 Item: document,604 Size: undefined,605 Position: undefined,606 },607 PathExpr: [608 {609 PrimaryExpr: [ {610 Function: 'root',611 Arguments: [612 [ {613 Step: {614 ForwardAxis: 'self',615 NodeTest: {616 AnyKindTest: [617 '*',618 ],619 },620 },621 PredicateList: [],622 } ],623 ],624 PredicateList: [],625 } ],626 PredicateList: [],627 },628 {629 Step: {630 ForwardAxis: ForwardAxis['descendant-or-self'],631 NodeTest: {632 AnyKindTest: [633 '*',634 ],635 },636 },637 PredicateList: [],638 },639 {640 Step: {641 ForwardAxis: ForwardAxis.child,642 NodeTest: {643 NameTest: 'w:p',644 },645 },646 PredicateList: [647 [ {648 ComparisonExpr: {649 Left: [ {650 Function: 'position',651 Arguments: [],652 PredicateList: [],653 } ],654 Right: [ {655 Literal: 1,656 } ],657 Operator: '=',658 },659 } ],660 ],661 },662 {663 Step: {664 ForwardAxis: ForwardAxis.child,665 NodeTest: {666 NameTest: 'w:bookmarkStart',667 },668 },669 PredicateList: [],670 },671 ],672 });673 expect(ItemSequence).toHaveLength(1);674 expect(ItemSequence[0]).toEqualXML(`675 <w:bookmarkStart676 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"677 w:name="_GoBack"678 w:id="0"679 />680 `);681 });682 it('Should evaluate an attribute axis', () => {683 const ItemSequence = PathExpr.evaluate({684 Context: {685 Item: document,686 Size: undefined,687 Position: undefined,688 },689 PathExpr: [690 {691 PrimaryExpr: [ {692 Function: 'root',693 Arguments: [694 [ {695 Step: {696 ForwardAxis: 'self',697 NodeTest: {698 AnyKindTest: [699 '*',700 ],701 },702 },703 PredicateList: [],704 } ],705 ],706 PredicateList: [],707 } ],708 PredicateList: [],709 },710 {711 Step: {712 ForwardAxis: ForwardAxis['descendant-or-self'],713 NodeTest: {714 AnyKindTest: [715 '*',716 ],717 },718 },719 PredicateList: [],720 },721 {722 Step: {723 ForwardAxis: ForwardAxis.child,724 NodeTest: {725 NameTest: 'w:p',726 },727 },728 PredicateList: [729 [ {730 ComparisonExpr: {731 Left: [ {732 Function: 'position',733 Arguments: [],734 PredicateList: [],735 } ],736 Right: [ {737 Literal: 1,738 } ],739 Operator: '=',740 },741 } ],742 ],743 },744 {745 Step: {746 ForwardAxis: ForwardAxis.child,747 NodeTest: {748 NameTest: 'w:bookmarkStart',749 },750 },751 PredicateList: [],752 },753 {754 Step: {755 ForwardAxis: ForwardAxis.attribute,756 NodeTest: {757 NameTest: '*',758 },759 },760 PredicateList: [],761 },762 ],763 });764 expect(ItemSequence).toHaveLength(2);765 expect(ItemSequence.map(n => n.value)).toEqual([ '_GoBack', '0' ]);766 });767 it('Should evaluate an attribute predicate', () => {768 const ItemSequence = PathExpr.evaluate({769 Context: {770 Item: document,771 Size: undefined,772 Position: undefined,773 },774 PathExpr: [775 {776 PrimaryExpr: [ {777 Function: 'root',778 Arguments: [779 [ {780 Step: {781 ForwardAxis: 'self',782 NodeTest: {783 AnyKindTest: [784 '*',785 ],786 },787 },788 PredicateList: [],789 } ],790 ],791 PredicateList: [],792 } ],793 PredicateList: [],794 },795 {796 Step: {797 ForwardAxis: ForwardAxis['descendant-or-self'],798 NodeTest: {799 AnyKindTest: [800 '*',801 ],802 },803 },804 PredicateList: [],805 },806 {807 Step: {808 ForwardAxis: ForwardAxis.child,809 NodeTest: {810 NameTest: 'w:p',811 },812 },813 PredicateList: [814 [ {815 ComparisonExpr: {816 Left: [ {817 Step: {818 ForwardAxis: ForwardAxis.attribute,819 NodeTest: {820 NameTest: 'w14:paraId',821 },822 },823 PredicateList: [],824 } ],825 Right: [ {826 Literal: '604A9B26',827 } ],828 Operator: '=',829 },830 } ],831 ],832 },833 ],834 });835 expect(ItemSequence).toHaveLength(1);836 expect(ItemSequence[0]).toEqualXML(`837 <w:p838 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"839 w:rsidR="1065A7B4"840 w:rsidP="1065A7B4"841 w:rsidRDefault="1065A7B4"842 xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"843 w14:paraId="604A9B26"844 w14:textId="7505C1CD"845 >846 <w:pPr>847 <w:pStyle w:val="Normal"/>848 </w:pPr>849 </w:p>850 `);851 });852 it('Should evaluate a following sibling axis and name test', () => {853 const ItemSequence = PathExpr.evaluate({854 Context: {855 Item: document,856 Size: undefined,857 Position: undefined,858 },859 PathExpr: [860 {861 PrimaryExpr: [ {862 Function: 'root',863 Arguments: [864 [ {865 Step: {866 ForwardAxis: 'self',867 NodeTest: {868 AnyKindTest: [869 '*',870 ],871 },872 },873 PredicateList: [],874 } ],875 ],876 PredicateList: [],877 } ],878 PredicateList: [],879 },880 {881 Step: {882 ForwardAxis: ForwardAxis['descendant-or-self'],883 NodeTest: {884 AnyKindTest: [885 '*',886 ],887 },888 },889 PredicateList: [],890 },891 {892 Step: {893 ForwardAxis: ForwardAxis.child,894 NodeTest: {895 NameTest: 'w:p',896 },897 },898 PredicateList: [899 [ {900 ComparisonExpr: {901 Left: [ {902 Function: 'position',903 Arguments: [],904 PredicateList: [],905 } ],906 Right: [ {907 Literal: 1,908 } ],909 Operator: '=',910 },911 } ],912 ],913 },914 {915 Step: {916 ForwardAxis: ForwardAxis.child,917 NodeTest: {918 NameTest: 'w:pPr',919 },920 },921 PredicateList: [],922 },923 {924 Step: {925 ForwardAxis: ForwardAxis['following-sibling'],926 NodeTest: {927 NameTest: 'w:bookmarkStart',928 },929 },930 PredicateList: [],931 },932 ],933 });934 expect(ItemSequence).toHaveLength(1);935 expect(ItemSequence[0]).toEqualXML(`936 <w:bookmarkStart937 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"938 w:name="_GoBack"939 w:id="0"940 />941 `);942 });943 });944 describe('That require parsing', () => {945 it('Should evaluate a child axis and name test', () => {946 const ItemSequence = evaluate(document, '/w:document/w:body/w:p/w:bookmarkStart');947 expect(ItemSequence).toHaveLength(1);948 expect(ItemSequence[0]).toEqualXML(`949 <w:bookmarkStart950 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"951 w:name="_GoBack"952 w:id="0"953 />954 `);955 });956 it('Should evaluate a descendant axis and name test', () => {957 const ItemSequence = evaluate(document, '//w:bookmarkStart');958 expect(ItemSequence).toHaveLength(1);959 expect(ItemSequence[0]).toEqualXML(`960 <w:bookmarkStart961 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"962 w:name="_GoBack"963 w:id="0"964 />965 `);966 });967 it('Should evaluate a position predicate', () => {968 const ItemSequence = evaluate(document, '//w:p[1]/w:bookmarkStart');969 expect(ItemSequence).toHaveLength(1);970 expect(ItemSequence[0]).toEqualXML(`971 <w:bookmarkStart972 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"973 w:name="_GoBack"974 w:id="0"975 />976 `);977 });978 it('Should evaluate an attribute axis', () => {979 const ItemSequence = evaluate(document, '//w:p[1]/w:bookmarkStart/attribute::*');980 expect(ItemSequence).toHaveLength(2);981 expect(ItemSequence.map(n => n.value)).toEqual([ '_GoBack', '0' ]);982 });983 it('Should evaluate an attribute predicate', () => {984 const ItemSequence = evaluate(document, '//w:p[@w14:paraId="604A9B26"]');985 expect(ItemSequence).toHaveLength(1);986 expect(ItemSequence[0]).toEqualXML(`987 <w:p988 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"989 w:rsidR="1065A7B4"990 w:rsidP="1065A7B4"991 w:rsidRDefault="1065A7B4"992 xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"993 w14:paraId="604A9B26"994 w14:textId="7505C1CD"995 >996 <w:pPr>997 <w:pStyle w:val="Normal"/>998 </w:pPr>999 </w:p>1000 `);1001 });1002 it('Should evaluate a following sibling axis and name test', () => {1003 const ItemSequence = evaluate(1004 document, '//w:p[1]/w:pPr/following-sibling::w:bookmarkStart'1005 );1006 expect(ItemSequence).toHaveLength(1);1007 expect(ItemSequence[0]).toEqualXML(`1008 <w:bookmarkStart1009 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1010 w:name="_GoBack"1011 w:id="0"1012 />1013 `);1014 });1015 it('Should evaluate a relative path', () => {1016 const ItemSequenceAbsolute = evaluate(1017 document, '/w:document/w:body/w:p/w:bookmarkStart'1018 );1019 expect(ItemSequenceAbsolute).toHaveLength(1);1020 expect(ItemSequenceAbsolute[0]).toEqualXML(`1021 <w:bookmarkStart1022 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1023 w:name="_GoBack"1024 w:id="0"1025 />1026 `);1027 const ItemSequenceRelative = evaluate(1028 ItemSequenceAbsolute[0], './following-sibling::w:r'1029 );1030 expect(ItemSequenceRelative).toHaveLength(1);1031 expect(ItemSequenceRelative[0]).toEqualXML(`1032 <w:r1033 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1034 w:rsidRPr="1065A7B4"1035 w:rsidR="1065A7B4"1036 >1037 <w:rPr>1038 <w:b w:val="1"/>1039 <w:bCs w:val="1"/>1040 </w:rPr>1041 <w:t>Adoration of the Magi</w:t>1042 </w:r>1043 `);1044 });1045 it('Should evaluate a parent axis', () => {1046 const ItemSequenceAbsolute = evaluate(1047 document, '/w:document/w:body/w:p/w:bookmarkStart'1048 );1049 expect(ItemSequenceAbsolute).toHaveLength(1);1050 expect(ItemSequenceAbsolute[0]).toEqualXML(`1051 <w:bookmarkStart1052 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1053 w:name="_GoBack"1054 w:id="0"1055 />1056 `);1057 const ItemSequenceRelative = evaluate(1058 ItemSequenceAbsolute[0], '../following-sibling::w:p[1]'1059 );1060 expect(ItemSequenceRelative).toHaveLength(1);1061 expect(ItemSequenceRelative[0]).toEqualXML(`1062 <w:p1063 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1064 w:rsidR="1065A7B4"1065 w:rsidP="1065A7B4"1066 w:rsidRDefault="1065A7B4"1067 xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"1068 w14:paraId="604A9B26"1069 w14:textId="7505C1CD"1070 >1071 <w:pPr>1072 <w:pStyle w:val="Normal"/>1073 </w:pPr>1074 </w:p>1075 `);1076 });1077 it('Should evaluate an ancestor axis', () => {1078 const ItemSequenceAbsolute = evaluate(1079 document, '/w:document/w:body/w:p/w:bookmarkStart'1080 );1081 expect(ItemSequenceAbsolute).toHaveLength(1);1082 expect(ItemSequenceAbsolute[0]).toEqualXML(`1083 <w:bookmarkStart1084 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1085 w:name="_GoBack"1086 w:id="0"1087 />1088 `);1089 const ItemSequenceRelative = evaluate(1090 ItemSequenceAbsolute[0], './ancestor::w:body/*[2]'1091 );1092 expect(ItemSequenceRelative).toHaveLength(1);1093 expect(ItemSequenceRelative[0]).toEqualXML(`1094 <w:p1095 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1096 w:rsidR="1065A7B4"1097 w:rsidP="1065A7B4"1098 w:rsidRDefault="1065A7B4"1099 xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"1100 w14:paraId="604A9B26"1101 w14:textId="7505C1CD"1102 >1103 <w:pPr>1104 <w:pStyle w:val="Normal"/>1105 </w:pPr>1106 </w:p>1107 `);1108 });1109 it('Should evaluate a following axis', () => {1110 const ItemSequenceAbsolute = evaluate(1111 document, '/w:document/w:body/w:p/w:bookmarkStart'1112 );1113 expect(ItemSequenceAbsolute).toHaveLength(1);1114 expect(ItemSequenceAbsolute[0]).toEqualXML(`1115 <w:bookmarkStart1116 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1117 w:name="_GoBack"1118 w:id="0"1119 />1120 `);1121 const ItemSequenceRelative = evaluate(1122 ItemSequenceAbsolute[0], './following::w:t[../..[@w14:paraId="0DE9EC43"]]'1123 );1124 expect(ItemSequenceRelative).toHaveLength(1);1125 expect(ItemSequenceRelative[0]).toEqualXML(`1126 <w:t1127 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1128 >On sharp objects in large pockets</w:t>1129 `);1130 });1131 it('Should evaluate a preceding axis', () => {1132 const ItemSequenceAbsolute = evaluate(1133 document, '/w:document/w:body/w:p[@w14:paraId="604A9B26"]'1134 );1135 expect(ItemSequenceAbsolute).toHaveLength(1);1136 expect(ItemSequenceAbsolute[0]).toEqualXML(`1137 <w:p1138 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1139 w:rsidR="1065A7B4"1140 w:rsidP="1065A7B4"1141 w:rsidRDefault="1065A7B4"1142 xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"1143 w14:paraId="604A9B26"1144 w14:textId="7505C1CD"1145 >1146 <w:pPr>1147 <w:pStyle w:val="Normal"/>1148 </w:pPr>1149 </w:p>1150 `);1151 const ItemSequenceRelative = evaluate(1152 ItemSequenceAbsolute[0], './preceding::w:pPr'1153 );1154 expect(ItemSequenceRelative).toHaveLength(1);1155 expect(ItemSequenceRelative[0]).toEqualXML(`1156 <w:pPr1157 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1158 >1159 <w:rPr>1160 <w:b w:val="1"/>1161 <w:bCs w:val="1"/>1162 </w:rPr>1163 </w:pPr>1164 `);1165 });1166 it('Should evaluate an any kind test', () => {1167 const ItemSequence = evaluate(1168 document, '/w:document/w:body/w:p[1]/(w:pPr|w:bookmarkStart|w:bookmarkEnd)'1169 );1170 expect(ItemSequence).toHaveLength(3);1171 expect(ItemSequence[0]).toEqualXML(`1172 <w:pPr1173 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1174 >1175 <w:rPr>1176 <w:b w:val="1"/>1177 <w:bCs w:val="1"/>1178 </w:rPr>1179 </w:pPr>1180 `);1181 expect(ItemSequence[1]).toEqualXML(`1182 <w:bookmarkStart1183 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1184 w:name="_GoBack"1185 w:id="0"1186 />1187 `);1188 expect(ItemSequence[2]).toEqualXML(`1189 <w:bookmarkEnd1190 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1191 w:id="0"1192 />1193 `);1194 });1195 it('Should evaluate an absolute path expression', () => {1196 const ItemSequence = evaluate(1197 document, '//w:p[1]/w:r[1]/w:t[1]'1198 );1199 expect(ItemSequence).toHaveLength(1);1200 expect(ItemSequence[0]).toEqualXML(`1201 <w:t1202 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1203 >Adoration of the Magi</w:t>1204 `);1205 const ItemSequenceAbsolute = evaluate(1206 ItemSequence[0], '//w:bookmarkStart'1207 );1208 expect(ItemSequenceAbsolute).toHaveLength(1);1209 expect(ItemSequenceAbsolute[0]).toEqualXML(`1210 <w:bookmarkStart1211 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1212 w:name="_GoBack"1213 w:id="0"1214 />1215 `);1216 });1217 it('Should evaluate a path expression within parentheses', () => {1218 const ItemSequence = evaluate(1219 document, '(//w:p)[1]/w:r[1]/w:t[1]'1220 );1221 expect(ItemSequence).toHaveLength(1);1222 expect(ItemSequence[0]).toEqualXML(`1223 <w:t1224 xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"1225 >Adoration of the Magi</w:t>1226 `);1227 });1228 });1229 });...

Full Screen

Full Screen

BaseLiteralsEditCreateViewTestSpec.js

Source:BaseLiteralsEditCreateViewTestSpec.js Github

copy

Full Screen

...67 go: jasmine.createSpy()68 }69 };70 var sut = exerciseCreateView();71 sut._goBack();72 expect($window.history.go).toHaveBeenCalledWith(-1);73 });74 });75 describe('isNew', function(){76 it("should call events's isNew", function () {77 spyOn(BaseLiteralsEditCreateView.prototype, "configureProperties");// avoid throwing78 var sut = exerciseCreateView();79 spyOn(sut.event, "isNew").and.returnValue(true);80 sut.data.literal = "some literal";81 var isNew = sut.isNew();82 expect(sut.event.isNew).toHaveBeenCalledWith("some literal");83 expect(isNew).toBe(true);84 });85 });...

Full Screen

Full Screen

NavThreeScreens.js

Source:NavThreeScreens.js Github

copy

Full Screen

...71 this._goBack = this._navigate.bind(this, {type:'pop'})72 if (Platform.OS === 'android') {73 BackAndroid.addEventListener('hardwareBackPress', () => {74 if (this.state.navigation.index > 0) {75 this._goBack()76 return true77 } else {78 return false79 }80 })81 }82 }83 render() {84 return (85 <NavCardStack86 renderScene={this._renderScene}87 renderOverlay={this._renderHeader}88 navigationState={this.state.navigation}89 onNavigateBack={this._goBack}...

Full Screen

Full Screen

navigator.js

Source:navigator.js Github

copy

Full Screen

...39 }40 the.setState({check: true})41 });42 }43 _goBack() {44 return naviGoBack(tempNavigator);45 }46 _configureScene(route) {47 return route.sceneConfigs || Navigator.SceneConfigs.FloatFromRight;48 }49 _renderScene(route, navigator) {50 let Component = route.component;51 tempNavigator = navigator;52 if (route.name === 'Home') {53 DeviceEventEmitter.emit('newView', true);54 DeviceEventEmitter.emit('newBuy', true);55 }56 return (57 <Component {...route.params} navigator={navigator} route={route}/>...

Full Screen

Full Screen

AppbarScreen.js

Source:AppbarScreen.js Github

copy

Full Screen

1import * as React from 'react';2import { StyleSheet, View } from 'react-native';3import { Appbar } from 'react-native-paper';4import {useRoute,useNavigation,DrawerActions} from '@react-navigation/native';5const AppbarScreen = ({navigation,searchcard,visibleform,...rest}) => {6 // const _goBack = () => navigation.goBack();7 8 const _handleSearch = () => console.log('Searching');9 const route = useRoute();10 11 const profilenavigation = useNavigation();12 const _goBack = () => {13 try{14 if(navigation.canGoBack()){15 navigation.goBack()16 }else{17 navigation.navigate('Explore')18 // console.log(navigation.canGoBack())19 }20 21 }catch(e){22 navigation.navigate('Explore')23 }24 25 26 };27 28 29 30 // const _handleMore = () => {31 32 33 // profilenavigation.navigate('Videos');34 35 36 // };37 // const _handleMore1 = () => {38 39 // profilenavigation.navigate('Articles') 40 41 42 43 44 45 46 // };47 return (48 <>49 <Appbar.Header style={styles.header}>50 <View style={{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'space-between',color:'white'}}>51 52 {navigation.canGoBack() && route.name!="Explore" ?53 <Appbar.BackAction color="white" onPress={_goBack} />: null}54 {profilenavigation.canGoBack() ? 55 <Appbar.Content {...rest} onPress={_goBack} />: <Appbar.Content {...rest} />56 }57 58 {searchcard &&59 <Appbar.Action color="white" icon={visibleform?'close':'magnify'} onPress={()=>searchcard()} />}60 61 {/* <Appbar.Action color="white" icon="view-headline" onPress={_handleMore1} /> */}62 {/* {route.name !== "Home" &&63 <Appbar.Action icon="cog-outline" onPress={_handleMore1} />} */}64 </View>65 </Appbar.Header>66 67 </>68 );69};70export default AppbarScreen;71const styles = StyleSheet.create({72 header: {73 position: 'relative',74 left: 0,75 right: 0,76 // top: 0,77 height:50,78 backgroundColor:"rgba(3, 13, 81, 0.9)"79 },...

Full Screen

Full Screen

WebViewComp.js

Source:WebViewComp.js Github

copy

Full Screen

1'use strict';2import React, { Component } from 'react';3import {4 StyleSheet,5 View,6 WebView,7 Image,8 Text,9 TouchableOpacity,10} from 'react-native';11let btn_back = require('./images/btn_back.png');12let url = 'http://www.baidu.com';13class WebViewComp extends Component {14 constructor(props) {15 super(props);16 17 this.state = {};18 this._goback = this._goback.bind(this);19 }20 _goback(){21 this.props.navigator.pop();22 }23 render() {24 // if(!this.props.url){25 // this._goback();26 // }27 let loadURL = this.props.params.url?this.props.params.url:url;28 let title = this.props.params.title?this.props.params.title:'圣诞的平安果1块抢';29 return (30 <View style={{flex:1, backgroundColor:'#FFFFFF', flexDirection:'column'}}>31 <View style={{flexDirection:'row', alignItems:'center', paddingLeft:10, paddingRight:10, paddingTop:5, paddingBottom:5}}>32 <TouchableOpacity activeOpacity={0.8} onPress={this._goback}>33 <Image style={{height:25, width:25}} source={btn_back}/>34 </TouchableOpacity>35 <View style={{flex:1, margin:5, flexDirection:'row', padding:5, alignItems:'center', justifyContent: 'center',}}>36 <Text textAlign='center' style={{fontSize:16, color:'#666666'}}>{title}</Text>37 </View>38 <Text style={{width:25}}></Text>39 </View>40 <View style={{flex:1}}>41 <WebView42 ref="webview"43 source={{uri:loadURL}}44 javaScriptEnabled={true}45 domStorageEnabled={true}46 startInLoadingState={true}47 scalesPageToFit={true}/>48 </View>49 </View>50 );51 }52}53const styles = StyleSheet.create({54});...

Full Screen

Full Screen

LoginContainer.js

Source:LoginContainer.js Github

copy

Full Screen

1import React, { useEffect } from 'react';2import { View, Text, } from 'react-native';3import {NavigationActions } from 'react-navigation';4import { connect } from 'react-redux';5import { Tab, Tabs } from 'native-base';6import _ from 'lodash';7import LoginView from './LoginView'8import SignUp from './SignUp'9import { loginAction, registerAction } from '../../redux/action'10function LoginContainer(props) {11 let { user } = props.globalReducer12 useEffect(() => {13 if(!_.isEmpty(user)){14 const navigateAction = NavigationActions.navigate({15 routeName: 'Home'16 });17 props.navigation.dispatch(navigateAction);18 }19 return () => {}20 }, [user])21 _goBack = (nav) => {22 props.navigation.goBack()23 }24 triggerLogin = (params) => {25 props.loginAction(params)26 }27 28 triggerRegister = (params) => {29 props.registerAction(params)30 }31 32 return(33 <View style={{ flex: 1 }}>34 <Tabs>35 <Tab heading='Login'>36 <LoginView _goBack={_goBack} triggerLogin={triggerLogin}/>37 </Tab>38 <Tab heading='Signup'>39 <SignUp _goBack={_goBack} triggerRegister={triggerRegister}/>40 </Tab>41 </Tabs>42 </View>43 );44}45const mapStateToProps = store => {46 return {47 globalReducer: store.globalReducer,48 };49};50const mapActionToProps = {51 loginAction,52 registerAction53};54 ...

Full Screen

Full Screen

BackNavigationButton.js

Source:BackNavigationButton.js Github

copy

Full Screen

...12 constructor(props) {13 super(props);14 this._goBack = this._goBack.bind(this);15 }16 _goBack() {17 if (this.props.navigator) {18 this.props.navigator.pop();19 } else {20 this.props.onPress();21 }22 }23 render() {24 return (25 <TouchableOpacity style={{backgroundColor: 'transparent'}} onPress={this._goBack}>26 <Icon name='chevron-left' size={40} style={styles.leftNavIcon} >27 </Icon>28 </TouchableOpacity>29 );30 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.goBack();7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.goBack();15 await page.goForward();16 await browser.close();17})();18const { chromium } = require('playwright');19(async () => {20 const browser = await chromium.launch();21 const context = await browser.newContext();22 const page = await context.newPage();23 await page.reload();24 await browser.close();25})();26const { chromium } = require('playwright');27(async () => {28 const browser = await chromium.launch();29 const context = await browser.newContext();30 const page = await context.newPage();31 await page.setViewportSize({ width: 100, height: 100 });32 await browser.close();33})();34const { chromium } = require('playwright');35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 const page = await context.newPage();39 await page.bringToFront();40 await browser.close();41})();42const { chromium } = require('playwright');43(async () => {44 const browser = await chromium.launch();45 const context = await browser.newContext();46 const page = await context.newPage();47 await page.emulateMedia({ media: 'print' });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _goBack } = require('playwright/lib/server/chromium/crPage');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await _goBack(page);8 await page.screenshot({ path: 'example.png' });9 await browser.close();10})();11const { helper } = require('../helper');12const { assert } = require('../helper');13const { Page } = require('../page');14const { Events: PageEvents } = require('../pageEvents');15 * @type {Page}16let _page;17Page.prototype._goBack = async function() {18 await _goBack(this);19};20module.exports = { _goBack };21const { helper } = require('../helper');22const { assert } = require('../helper');23const { Page } = require('../page');24const { Events: PageEvents } = require('../pageEvents');25 * @type {Page}26let _page;27Page.prototype._goBack = async function() {28 await _goBack(this);29};30module.exports = { _goBack };31const { helper } = require('../helper');32const { assert } = require('../helper');33const { Page } = require('../page');34const { Events: PageEvents } = require('../pageEvents');35 * @type {Page}36let _page;37Page.prototype._goBack = async function() {38 await _goBack(this);39};40module.exports = { _goBack };41const { helper } = require('../helper');42const { assert } = require('../helper');43const { Page } = require('../page');44const { Events: PageEvents } = require('../pageEvents');45 * @type {Page}46let _page;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _goBack } = require('playwright/lib/server/chromium/crPage');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('text=Docs');8 await _goBack(page);9 await page.screenshot({ path: 'example.png' });10 await browser.close();11})();12const tableRows = await page.$$('table tr');13console.log(tableRows.length);14const tableRows = await page.$$('table tr');15console.log(tableRows.length);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _goBack } = require('playwright/lib/server/page');2const { createTestState } = require('playwright/lib/server/test');3const testState = createTestState();4const page = testState.browserContexts[0].pages[0];5_goBack(page);6const { _goBack } = require('playwright/lib/server/page');7const { createTestState } = require('playwright/lib/server/test');8const testState = createTestState();9const page = testState.browserContexts[0].pages[0];10_goBack(page);11const { _goBack } = require('playwright/lib/server/page');12const { createTestState } = require('playwright/lib/server/test');13const testState = createTestState();14const page = testState.browserContexts[0].pages[0];15_goBack(page);16const { _goBack } = require('playwright/lib/server/page');17const { createTestState } = require('playwright/lib/server/test');18const testState = createTestState();19const page = testState.browserContexts[0].pages[0];20_goBack(page);21const { _goBack } = require('playwright/lib/server/page');22const { createTestState } = require('playwright/lib/server/test');23const testState = createTestState();24const page = testState.browserContexts[0].pages[0];25_goBack(page);26const { _goBack } = require('playwright/lib/server/page');27const { createTestState } = require('playwright/lib/server/test');28const testState = createTestState();29const page = testState.browserContexts[0].pages[0];30_goBack(page);31const { _goBack } = require('playwright/lib/server/page');32const { createTestState } = require('playwright/lib/server/test');33const testState = createTestState();34const page = testState.browserContexts[0].pages[0];35_goBack(page);

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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