Best JavaScript code snippet using taiko
sanity.spec.js
Source:sanity.spec.js
...12 });13 it('area', function (done) {14 driver.get('file://' + path.join(__dirname + '../../../examples/area/areaTest.html'));15 driver.findElement(By.id('graphArea0')).then(function (graph) {16 graph.findElements(By.tagName('svg')).then(function (graphs) {17 expect(graphs.length).toBe(2);18 graphs[0].findElements(By.className('chart-area')).then(function (charts) {19 expect(charts.length).toBe(6);20 });21 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {22 graphs[0].findElements(By.className('cell')).then(function (cells) {23 expect(cells.length).toBe(6);24 cells[0].findElement(By.tagName('text')).then(function (text) {25 text.getText().then(function (value) {26 expect(value).toBe('data-0')27 });28 });29 cells[1].findElement(By.tagName('text')).then(function (text) {30 text.getText().then(function (value) {31 expect(value).toBe('data-1')32 });33 });34 cells[2].findElement(By.tagName('text')).then(function (text) {35 text.getText().then(function (value) {36 expect(value).toBe('data-2')37 });38 });39 cells[3].findElement(By.tagName('text')).then(function (text) {40 text.getText().then(function (value) {41 expect(value).toBe('data-3')42 });43 });44 cells[4].findElement(By.tagName('text')).then(function (text) {45 text.getText().then(function (value) {46 expect(value).toBe('data-4')47 });48 });49 cells[5].findElement(By.tagName('text')).then(function (text) {50 text.getText().then(function (value) {51 expect(value).toBe('data-5')52 });53 });54 });55 });56 graphs[0].findElements(By.className('axis')).then(function (axes) {57 expect(axes.length).toBe(2);58 });59 graphs[0].findElement(By.className('lane-title')).then(function (title) {60 title.getText().then(function (text) {61 expect(text).toBe('Alpha Area');62 });63 });64 })65 })66 driver.findElement(By.id('graphArea1')).then(function (graph) {67 graph.findElements(By.tagName('svg')).then(function (graphs) {68 expect(graphs.length).toBe(2);69 graphs[0].findElements(By.className('chart-area')).then(function (charts) {70 expect(charts.length).toBe(6);71 });72 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {73 graphs[0].findElements(By.className('cell')).then(function (cells) {74 expect(cells.length).toBe(12);75 cells[0].findElement(By.tagName('text')).then(function (text) {76 text.getText().then(function (value) {77 expect(value).toBe('data-0')78 });79 });80 cells[1].findElement(By.tagName('text')).then(function (text) {81 text.getText().then(function (value) {82 expect(value).toBe('data-1')83 });84 });85 cells[2].findElement(By.tagName('text')).then(function (text) {86 text.getText().then(function (value) {87 expect(value).toBe('data-2')88 });89 });90 cells[3].findElement(By.tagName('text')).then(function (text) {91 text.getText().then(function (value) {92 expect(value).toBe('data-3')93 });94 });95 cells[4].findElement(By.tagName('text')).then(function (text) {96 text.getText().then(function (value) {97 expect(value).toBe('data-4')98 });99 });100 cells[5].findElement(By.tagName('text')).then(function (text) {101 text.getText().then(function (value) {102 expect(value).toBe('data-5')103 });104 });105 cells[6].findElement(By.tagName('text')).then(function (text) {106 text.getText().then(function (value) {107 expect(value).toBe('data-0')108 });109 });110 cells[7].findElement(By.tagName('text')).then(function (text) {111 text.getText().then(function (value) {112 expect(value).toBe('data-1')113 });114 });115 cells[8].findElement(By.tagName('text')).then(function (text) {116 text.getText().then(function (value) {117 expect(value).toBe('data-2')118 });119 });120 cells[9].findElement(By.tagName('text')).then(function (text) {121 text.getText().then(function (value) {122 expect(value).toBe('data-3')123 });124 });125 cells[10].findElement(By.tagName('text')).then(function (text) {126 text.getText().then(function (value) {127 expect(value).toBe('data-4')128 });129 });130 cells[11].findElement(By.tagName('text')).then(function (text) {131 text.getText().then(function (value) {132 expect(value).toBe('data-5')133 });134 });135 });136 });137 graphs[0].findElements(By.className('axis')).then(function (axes) {138 expect(axes.length).toBe(2);139 });140 graphs[0].findElement(By.className('lane-title')).then(function (title) {141 title.getText().then(function (text) {142 expect(text).toBe('Stacked Area');143 });144 });145 })146 })147 driver.findElement(By.id('graphArea2')).then(function (graph) {148 graph.findElements(By.tagName('svg')).then(function (graphs) {149 expect(graphs.length).toBe(2);150 graphs[0].findElements(By.className('chart-area')).then(function (charts) {151 expect(charts.length).toBe(6);152 });153 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {154 graphs[0].findElements(By.className('cell')).then(function (cells) {155 expect(cells.length).toBe(6);156 });157 });158 graphs[0].findElements(By.className('axis')).then(function (axes) {159 expect(axes.length).toBe(2);160 });161 graphs[0].findElement(By.className('lane-title')).then(function (title) {162 title.getText().then(function (text) {163 expect(text).toBe('Computed Residency');164 done();165 });166 });167 });168 });169 }, 10000);170 it('bar', function (done) {171 driver.get('file://' + path.join(__dirname + '../../../examples/bar/barTest.html'));172 driver.findElement(By.id('graphArea0')).then(function (graph) {173 driver.wait(until.elementLocated(By.className('legendCells')), 1000).then(function () {174 graph.findElements(By.className('legendCells')).then(function (legend) {175 expect(legend.length).toBe(1);176 legend[0].findElements(By.className('cell')).then(function (cells) {177 expect(cells.length).toBe(4);178 cells[0].findElement(By.tagName('text')).then(function (text) {179 text.getText().then(function (value) {180 expect(value).toBe('data-0')181 });182 });183 cells[1].findElement(By.tagName('text')).then(function (text) {184 text.getText().then(function (value) {185 expect(value).toBe('data-1')186 });187 });188 cells[2].findElement(By.tagName('text')).then(function (text) {189 text.getText().then(function (value) {190 expect(value).toBe('data-2')191 });192 });193 cells[3].findElement(By.tagName('text')).then(function (text) {194 text.getText().then(function (value) {195 expect(value).toBe('Data1')196 });197 });198 });199 });200 });201 graph.findElement(By.className('lane-title')).then(function (title) {202 title.getText().then(function (text) {203 expect(text).toBe('Basic Bar');204 });205 });206 graph.findElements(By.className('chart-bar')).then(function (bars) {207 expect(bars.length).toBe(3);208 });209 graph.findElements(By.className('chart-line')).then(function (line) {210 expect(line.length).toBe(1);211 });212 graph.findElements(By.className('axis')).then(function (axes) {213 expect(axes.length).toBe(2);214 });215 });216 driver.findElement(By.id('graphArea1')).then(function (graph) {217 driver.wait(until.elementLocated(By.className('legendCells')), 1000).then(function () {218 graph.findElements(By.className('legendCells')).then(function (legend) {219 expect(legend.length).toBe(1);220 legend[0].findElements(By.className('cell')).then(function (cells) {221 expect(cells.length).toBe(4);222 cells[0].findElement(By.tagName('text')).then(function (text) {223 text.getText().then(function (value) {224 expect(value).toBe('tony')225 });226 });227 cells[1].findElement(By.tagName('text')).then(function (text) {228 text.getText().then(function (value) {229 expect(value).toBe('jak')230 });231 });232 cells[2].findElement(By.tagName('text')).then(function (text) {233 text.getText().then(function (value) {234 expect(value).toBe('michelle')235 });236 });237 cells[3].findElement(By.tagName('text')).then(function (text) {238 text.getText().then(function (value) {239 expect(value).toBe('Data1')240 });241 });242 });243 });244 });245 graph.findElement(By.className('lane-title')).then(function (title) {246 title.getText().then(function (text) {247 expect(text).toBe('Multi Bar');248 });249 });250 graph.findElements(By.className('chart-bar')).then(function (bars) {251 expect(bars.length).toBe(9);252 });253 graph.findElements(By.className('chart-line')).then(function (line) {254 expect(line.length).toBe(1);255 });256 graph.findElements(By.className('axis')).then(function (axes) {257 expect(axes.length).toBe(2);258 });259 });260 driver.findElement(By.id('graphArea2')).then(function (graph) {261 driver.wait(until.elementLocated(By.className('legendCells')), 1000).then(function () {262 graph.findElements(By.className('legendCells')).then(function (legend) {263 expect(legend.length).toBe(1);264 legend[0].findElements(By.className('cell')).then(function (cells) {265 expect(cells.length).toBe(4);266 cells[0].findElement(By.tagName('text')).then(function (text) {267 text.getText().then(function (value) {268 expect(value).toBe('tony')269 });270 });271 cells[1].findElement(By.tagName('text')).then(function (text) {272 text.getText().then(function (value) {273 expect(value).toBe('jak')274 });275 });276 cells[2].findElement(By.tagName('text')).then(function (text) {277 text.getText().then(function (value) {278 expect(value).toBe('michelle')279 });280 });281 cells[3].findElement(By.tagName('text')).then(function (text) {282 text.getText().then(function (value) {283 expect(value).toBe('Data1')284 });285 });286 });287 });288 });289 graph.findElement(By.className('lane-title')).then(function (title) {290 title.getText().then(function (text) {291 expect(text).toBe('Stacked Bar');292 });293 });294 graph.findElements(By.className('chart-bar')).then(function (bars) {295 expect(bars.length).toBe(9);296 });297 graph.findElements(By.className('chart-line')).then(function (line) {298 expect(line.length).toBe(1);299 });300 graph.findElements(By.className('axis')).then(function (axes) {301 expect(axes.length).toBe(2);302 });303 });304 driver.findElement(By.id('graphArea3')).then(function (graph) {305 graph.findElements(By.className('nested-axis')).then(function (nested) {306 expect(nested.length).toBe(16);307 });308 graph.findElements(By.className('chart-bar')).then(function (bars) {309 expect(bars.length).toBe(96);310 });311 graph.findElements(By.className('cell')).then(function (cells) {312 expect(cells.length).toBe(4);313 cells[0].findElement(By.tagName('text')).then(function (text) {314 text.getText().then(function (value) {315 expect(value).toBe('Failing')316 });317 });318 cells[1].findElement(By.tagName('text')).then(function (text) {319 text.getText().then(function (value) {320 expect(value).toBe('Workaround')321 });322 });323 cells[2].findElement(By.tagName('text')).then(function (text) {324 text.getText().then(function (value) {325 expect(value).toBe('Passing')326 });327 });328 cells[3].findElement(By.tagName('text')).then(function (text) {329 text.getText().then(function (value) {330 expect(value).toBe('Not Yet Tested/WIP')331 });332 });333 });334 graph.findElements(By.className('axis')).then(function (axes) {335 expect(axes.length).toBe(2);336 });337 });338 driver.findElement(By.id('graphArea4')).then(function (graph) {339 graph.findElements(By.className('chart-bar')).then(function (bars) {340 expect(bars.length).toBe(20);341 });342 graph.findElements(By.className('axis')).then(function (axes) {343 expect(axes.length).toBe(2);344 done();345 });346 });347 driver.findElement(By.id('graphArea5')).then(function (graph) {348 graph.findElements(By.className('chart-bar')).then(function (bars) {349 expect(bars.length).toBe(3);350 });351 graph.findElements(By.className('axis')).then(function (axes) {352 expect(axes.length).toBe(2);353 done();354 });355 });356 driver.findElement(By.id('graphArea6')).then(function (graph) {357 graph.findElements(By.className('chart-bar')).then(function (bars) {358 expect(bars.length).toBe(9);359 });360 graph.findElements(By.className('axis')).then(function (axes) {361 expect(axes.length).toBe(2);362 done();363 });364 });365 driver.findElement(By.id('graphArea7')).then(function (graph) {366 graph.findElements(By.className('chart-bar')).then(function (bars) {367 expect(bars.length).toBe(1);368 });369 graph.findElements(By.className('axis')).then(function (axes) {370 expect(axes.length).toBe(2);371 done();372 });373 });374 }, 10000);375 it('connected-graph', function (done) {376 driver.get('file://' + path.join(__dirname + '../../../examples/connectedGraph/connectedGraphTest.html'));377 driver.findElement(By.id('graphArea0')).then(function (graph) {378 graph.findElements(By.className('link')).then(function (links) {379 expect(links.length).toBe(7);380 });381 graph.findElements(By.className('node')).then(function (nodes) {382 expect(nodes.length).toBe(5);383 });384 graph.findElements(By.className('cell')).then(function (legendCells) {385 expect(legendCells.length).toBe(4);386 });387 });388 driver.findElement(By.id('graphArea1')).then(function (graph) {389 graph.findElements(By.className('link')).then(function (links) {390 expect(links.length).toBe(7);391 });392 graph.findElements(By.className('node')).then(function (nodes) {393 expect(nodes.length).toBe(5);394 });395 graph.findElements(By.className('cell')).then(function (legendCells) {396 expect(legendCells.length).toBe(5);397 done();398 });399 });400 }, 10000);401 it('flame-sunburst', function (done) {402 driver.get('file://' + path.join(__dirname + '../../../examples/flameSunburst/flameSunburstTest.html'));403 driver.findElement(By.id('graphArea0')).then(function (graph) {404 graph.findElement(By.className('segments')).then(function (segment) {405 segment.findElements(By.tagName('rect')).then(function (rects) {406 expect(rects.length).toBe(10);407 });408 });409 graph.findElement(By.className('labels')).then(function (labels) {410 labels.findElements(By.tagName('text')).then(function (text) {411 expect(text.length > 3);412 });413 });414 graph.findElement(By.className('background')).then(function (background) {415 background.getAttribute('d').then(function (attr) {416 expect(attr.length).toBeGreaterThan(0);417 })418 });419 graph.findElement(By.className('lane-title')).then(function (title) {420 title.getText().then(function (text) {421 expect(text).toBe('Flame Chart');422 });423 });424 graph.findElements(By.className('axis')).then(function (axes) {425 expect(axes.length).toBe(2);426 });427 });428 driver.findElement(By.id('graphArea1')).then(function (graph) {429 graph.findElements(By.tagName('path')).then(function (segments) {430 expect(segments.length).toBe(392);431 });432 });433 driver.findElement(By.id('graphArea2')).then(function (graph) {434 graph.findElement(By.className('segments')).then(function (segment) {435 segment.findElements(By.tagName('rect')).then(function (rects) {436 expect(rects.length > 100);437 });438 });439 graph.findElement(By.className('background')).then(function (background) {440 background.getAttribute('d').then(function (attr) {441 expect(attr).toBeNull();442 })443 });444 graph.findElement(By.className('lane-title')).then(function (title) {445 title.getText().then(function (text) {446 expect(text).toBe('Trace Data');447 });448 });449 graph.findElements(By.className('axis')).then(function (axes) {450 expect(axes.length).toBe(2);451 });452 });453 driver.findElement(By.id('graphArea3')).then(function (graph) {454 graph.findElements(By.className('chart-area')).then(function (area) {455 expect(area.length).toBe(19);456 });457 graph.findElement(By.className('lane-title')).then(function (title) {458 title.getText().then(function (text) {459 expect(text).toBe('Trace Residency');460 });461 });462 graph.findElements(By.className('axis')).then(function (axes) {463 expect(axes.length).toBe(2);464 });465 });466 driver.findElement(By.id('graphArea4')).then(function (graph) {467 graph.findElements(By.className('chart-line')).then(function (line) {468 expect(line.length).toBe(1);469 });470 graph.findElement(By.className('lane-title')).then(function (title) {471 title.getText().then(function (text) {472 expect(text).toBe('Trace State');473 });474 });475 graph.findElements(By.className('axis')).then(function (axes) {476 expect(axes.length).toBe(2);477 });478 });479 driver.findElement(By.id('graphArea5')).then(function (graph) {480 graph.findElements(By.tagName('canvas')).then(function (canvas) {481 expect(canvas.length).toBe(1);482 });483 graph.findElement(By.className('lane-title')).then(function (title) {484 title.getText().then(function (text) {485 expect(text).toBe('Trace Sparse');486 });487 });488 graph.findElements(By.className('axis')).then(function (axes) {489 expect(axes.length).toBe(2);490 });491 });492 driver.findElement(By.id('graphArea6')).then(function (graph) {493 graph.findElements(By.className('chart-line')).then(function (line) {494 expect(line.length).toBe(1);495 });496 graph.findElement(By.className('lane-title')).then(function (title) {497 title.getText().then(function (text) {498 expect(text).toBe('Trace Sparse Line');499 });500 });501 graph.findElements(By.className('axis')).then(function (axes) {502 expect(axes.length).toBe(2);503 });504 });505 driver.findElement(By.id('graphArea7')).then(function (graph) {506 graph.findElements(By.className('chart-area')).then(function (area) {507 expect(area.length).toBe(2);508 });509 graph.findElement(By.className('lane-title')).then(function (title) {510 title.getText().then(function (text) {511 expect(text).toBe('Trace Sparse Area');512 });513 });514 graph.findElements(By.className('axis')).then(function (axes) {515 expect(axes.length).toBe(2);516 });517 });518 driver.findElement(By.id('graphArea8')).then(function (graph) {519 graph.findElements(By.tagName('canvas')).then(function (canvas) {520 expect(canvas.length).toBe(1);521 });522 graph.findElement(By.className('background')).then(function (background) {523 background.getAttribute('d').then(function (attr) {524 expect(attr).toBeDefined();525 done();526 })527 });528 });529 driver.findElement(By.id('graphArea9')).then(function (graph) {530 graph.findElements(By.tagName('canvas')).then(function (canvas) {531 expect(canvas.length).toBe(1);532 });533 graph.findElement(By.className('background')).then(function (background) {534 background.getAttribute('d').then(function (attr) {535 expect(attr).toBeDefined();536 done();537 })538 });539 });540 }, 10000);541 it('hierarchy-graph', function (done) {542 driver.get('file://' + path.join(__dirname + '../../../examples/hierarchyGraph/hierarchyGraphTest.html'));543 const element = By.className('link');544 driver.wait(until.elementLocated(element));545 driver.findElement(By.id('graphArea0')).then(function (graph) {546 graph.findElements(By.className('node')).then(function (nodes) {547 expect(nodes.length).toBe(329);548 });549 graph.findElements(By.className('link')).then(function (links) {550 expect(links.length).toBe(32);551 });552 });553 driver.findElement(By.id('graphArea1')).then(function (graph) {554 graph.findElements(By.className('node')).then(function (nodes) {555 expect(nodes.length).toBe(9);556 });557 graph.findElements(By.className('link')).then(function (links) {558 expect(links.length).toBe(7);559 });560 });561 driver.findElement(By.id('graphArea2')).then(function (graph) {562 graph.findElements(By.className('node')).then(function (nodes) {563 expect(nodes.length).toBe(47);564 });565 graph.findElements(By.className('link')).then(function (links) {566 expect(links.length).toBe(8);567 });568 });569 driver.findElement(By.id('graphArea3')).then(function (graph) {570 graph.findElements(By.className('node')).then(function (nodes) {571 expect(nodes.length).toBe(43);572 });573 graph.findElements(By.className('link')).then(function (links) {574 expect(links.length).toBe(8);575 });576 });577 driver.findElement(By.id('graphArea4')).then(function (graph) {578 graph.findElements(By.className('node')).then(function (nodes) {579 expect(nodes.length).toBe(191);580 });581 graph.findElements(By.className('link')).then(function (links) {582 expect(links.length).toBe(20);583 done();584 });585 });586 }, 10000);587 it('line', function (done) {588 driver.get('file://' + path.join(__dirname + '../../../examples/line/lineTest.html'));589 driver.findElement(By.id('graphArea0')).then(function (graph) {590 graph.findElements(By.className('chart-line')).then(function (lines) {591 expect(lines.length).toBe(1);592 });593 graph.findElement(By.className('lane-title')).then(function (title) {594 title.getText().then(function (text) {595 expect(text).toBe('Step Graph');596 });597 });598 graph.findElements(By.className('axis')).then(function (axes) {599 expect(axes.length).toBe(2);600 axes[0].getAttribute('transform').then(function (transform) {601 expect(transform).toBe('translate(177.03125, 55)');602 });603 });604 });605 driver.findElement(By.id('graphArea1')).then(function (graph) {606 graph.findElements(By.className('chart-line')).then(function (lines) {607 expect(lines.length).toBe(1);608 });609 graph.findElement(By.className('lane-title')).then(function (title) {610 title.getText().then(function (text) {611 expect(text).toBe('Sync Data');612 });613 });614 graph.findElements(By.className('axis')).then(function (axes) {615 expect(axes.length).toBe(2);616 });617 });618 driver.findElement(By.id('graphArea2')).then(function (graph) {619 graph.findElements(By.className('chart-line')).then(function (lines) {620 expect(lines.length).toBe(6);621 });622 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {623 graph.findElements(By.className('cell')).then(function (cells) {624 expect(cells.length).toBe(12);625 cells[0].findElement(By.tagName('text')).then(function (text) {626 text.getText().then(function (value) {627 expect(value).toBe('data-0')628 });629 });630 cells[1].findElement(By.tagName('text')).then(function (text) {631 text.getText().then(function (value) {632 expect(value).toBe('data-1')633 });634 });635 cells[2].findElement(By.tagName('text')).then(function (text) {636 text.getText().then(function (value) {637 expect(value).toBe('data-2')638 });639 });640 cells[3].findElement(By.tagName('text')).then(function (text) {641 text.getText().then(function (value) {642 expect(value).toBe('data-3')643 });644 });645 cells[4].findElement(By.tagName('text')).then(function (text) {646 text.getText().then(function (value) {647 expect(value).toBe('data-4')648 });649 });650 cells[5].findElement(By.tagName('text')).then(function (text) {651 text.getText().then(function (value) {652 expect(value).toBe('data-5')653 });654 });655 cells[6].findElement(By.tagName('text')).then(function (text) {656 text.getText().then(function (value) {657 expect(value).toBe('data-0')658 });659 });660 cells[7].findElement(By.tagName('text')).then(function (text) {661 text.getText().then(function (value) {662 expect(value).toBe('data-1')663 });664 });665 cells[8].findElement(By.tagName('text')).then(function (text) {666 text.getText().then(function (value) {667 expect(value).toBe('data-2')668 });669 });670 cells[9].findElement(By.tagName('text')).then(function (text) {671 text.getText().then(function (value) {672 expect(value).toBe('data-3')673 });674 });675 cells[10].findElement(By.tagName('text')).then(function (text) {676 text.getText().then(function (value) {677 expect(value).toBe('data-4')678 });679 });680 cells[11].findElement(By.tagName('text')).then(function (text) {681 text.getText().then(function (value) {682 expect(value).toBe('data-5')683 });684 });685 });686 });687 graph.findElement(By.className('lane-title')).then(function (title) {688 title.getText().then(function (text) {689 expect(text).toBe('Stacked Line');690 });691 });692 graph.findElements(By.className('axis')).then(function (axes) {693 expect(axes.length).toBe(2);694 });695 });696 driver.findElement(By.id('graphArea3')).then(function (graph) {697 graph.findElements(By.className('chart-line')).then(function (lines) {698 expect(lines.length).toBe(1);699 });700 graph.findElement(By.className('lane-title')).then(function (title) {701 title.getText().then(function (text) {702 expect(text).toBe('Logarithmic Y');703 });704 });705 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {706 graph.findElements(By.className('cell')).then(function (cells) {707 expect(cells.length).toBe(1);708 cells[0].findElement(By.tagName('text')).then(function (text) {709 text.getText().then(function (value) {710 expect(value).toBe('data-0')711 });712 });713 });714 });715 graph.findElements(By.className('axis')).then(function (axes) {716 expect(axes.length).toBe(2);717 });718 });719 driver.findElement(By.id('graphArea4')).then(function (graph) {720 graph.findElements(By.className('chart-line')).then(function (lines) {721 expect(lines.length).toBe(1);722 });723 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {724 graph.findElements(By.className('cell')).then(function (cells) {725 expect(cells.length).toBe(1);726 cells[0].findElement(By.tagName('text')).then(function (text) {727 text.getText().then(function (value) {728 expect(value).toBe('data-0')729 });730 });731 });732 });733 graph.findElement(By.className('lane-title')).then(function (title) {734 title.getText().then(function (text) {735 expect(text).toBe('Y');736 });737 });738 graph.findElements(By.className('axis')).then(function (axes) {739 expect(axes.length).toBe(2);740 });741 });742 driver.findElement(By.id('graphArea5')).then(function (graph) {743 graph.findElements(By.className('chart-line')).then(function (lines) {744 expect(lines.length).toBe(2);745 });746 graph.findElements(By.className('cell')).then(function (cells) {747 expect(cells.length).toBe(1);748 });749 graph.findElement(By.className('lane-title')).then(function (title) {750 title.getText().then(function (text) {751 expect(text).toBe('Ordinal X');752 });753 });754 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {755 graph.findElements(By.className('cell')).then(function (cells) {756 expect(cells.length).toBe(1);757 cells[0].findElement(By.tagName('text')).then(function (text) {758 text.getText().then(function (value) {759 expect(value).toBe('Data1')760 });761 });762 });763 });764 graph.findElements(By.className('axis')).then(function (axes) {765 expect(axes.length).toBe(2);766 });767 });768 driver.findElement(By.id('graphArea6')).then(function (graph) {769 graph.findElements(By.className('chart-line')).then(function (lines) {770 expect(lines.length).toBe(2);771 });772 graph.findElements(By.className('axis')).then(function (axes) {773 expect(axes.length).toBe(2);774 });775 });776 driver.findElement(By.id('graphArea7')).then(function (graph) {777 graph.findElements(By.className('chart-line')).then(function (lines) {778 expect(lines.length).toBe(1);779 });780 graph.findElements(By.className('axis')).then(function (axes) {781 expect(axes.length).toBe(2);782 });783 });784 driver.findElement(By.id('graphArea8')).then(function (graph) {785 graph.findElements(By.className('chart-line')).then(function (lines) {786 expect(lines.length).toBe(3);787 });788 graph.findElement(By.className('lane-title')).then(function (title) {789 title.getText().then(function (text) {790 expect(text).toBe('merged');791 });792 });793 graph.findElements(By.className('axis')).then(function (axes) {794 expect(axes.length).toBe(2);795 done();796 });797 });798 }, 10000);799 it('pie', function (done) {800 driver.get('file://' + path.join(__dirname + '../../../examples/pie/pieTest.html'));801 driver.findElement(By.id('graphArea0')).then(function (graph) {802 graph.findElements(By.className('arc')).then(function (arcs) {803 expect(arcs.length).toBe(3);804 });805 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {806 graph.findElements(By.className('cell')).then(function (cells) {807 expect(cells.length).toBe(3);808 cells[0].findElement(By.tagName('text')).then(function (text) {809 text.getText().then(function (value) {810 expect(value).toBe('data@-0')811 });812 });813 cells[1].findElement(By.tagName('text')).then(function (text) {814 text.getText().then(function (value) {815 expect(value).toBe('data-%1')816 });817 });818 cells[2].findElement(By.tagName('text')).then(function (text) {819 text.getText().then(function (value) {820 expect(value).toBe('data-2')821 });822 });823 });824 });825 });826 driver.findElement(By.id('graphArea1')).then(function (graph) {827 graph.findElements(By.className('arc')).then(function (arcs) {828 expect(arcs.length).toBe(3);829 });830 driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {831 graph.findElements(By.className('cell')).then(function (cells) {832 expect(cells.length).toBe(3);833 cells[0].findElement(By.tagName('text')).then(function (text) {834 text.getText().then(function (value) {835 expect(value).toBe('data@-0')836 });837 });838 cells[1].findElement(By.tagName('text')).then(function (text) {839 text.getText().then(function (value) {840 expect(value).toBe('data-%1')841 });842 });843 cells[2].findElement(By.tagName('text')).then(function (text) {844 text.getText().then(function (value) {845 expect(value).toBe('data-2')846 done();847 });848 });849 });850 });851 });852 }, 10000);853 it('rect', function (done) {854 driver.get('file://' + path.join(__dirname + '../../../examples/rect/rectTest.html'));855 driver.findElements(By.tagName('svg')).then(function (graphs) {856 graphs[0].findElements(By.className('chart-rect')).then(function (rects) {857 expect(rects.length).toBe(2);858 });859 graphs[0].findElements(By.className('axis')).then(function (axes) {860 expect(axes.length).toBe(2);861 });862 graphs[2].findElements(By.className('chart-rect')).then(function (rects) {863 expect(rects.length).toBe(2);864 });865 graphs[2].findElements(By.className('axis')).then(function (axes) {866 expect(axes.length).toBe(2);867 });868 graphs[4].findElements(By.className('chart-rect')).then(function (rects) {869 expect(rects.length).toBe(4);870 });871 graphs[4].findElements(By.className('axis')).then(function (axes) {872 expect(axes.length).toBe(2);873 });874 graphs[5].findElements(By.tagName('text')).then(function (text) {875 expect(text.length).toBe(2);876 });877 graphs[6].findElements(By.className('chart-rect')).then(function (rects) {878 expect(rects.length).toBe(4);879 });880 graphs[6].findElements(By.className('axis')).then(function (axes) {881 expect(axes.length).toBe(2);882 });883 graphs[7].findElements(By.tagName('text')).then(function (text) {884 expect(text.length).toBe(2);885 done();886 });887 });888 }, 10000);889 it('scatter', function (done) {890 driver.get('file://' + path.join(__dirname + '../../../examples/scatter/scatterTest.html'));891 driver.findElements(By.tagName('svg')).then(function (graphs) {892 graphs[0].findElement(By.className('lane-title')).then(function (title) {893 title.getText().then(function (text) {894 expect(text).toBe('Ordinal Y');895 });896 });897 graphs[0].findElements(By.className('axis')).then(function (axes) {898 expect(axes.length).toBe(2);899 });900 graphs[2].findElement(By.className('lane-title')).then(function (title) {901 title.getText().then(function (text) {902 expect(text).toBe('Scatter+Line');903 });904 });905 graphs[2].findElements(By.className('axis')).then(function (axes) {906 expect(axes.length).toBe(3);907 });908 graphs[4].findElement(By.className('lane-title')).then(function (title) {909 title.getText().then(function (text) {910 expect(text).toBe('Same Scatter/Line');911 });912 });913 graphs[4].findElements(By.className('axis')).then(function (axes) {914 expect(axes.length).toBe(2);915 });916 graphs[6].findElement(By.className('lane-title')).then(function (title) {917 title.getText().then(function (text) {918 expect(text).toBe('One Data, Many Decimators');919 });920 });921 graphs[6].findElements(By.className('axis')).then(function (axes) {922 expect(axes.length).toBe(2);923 });924 graphs[6].findElements(By.className('cell')).then(function (cells) {925 expect(cells.length).toBe(3);926 cells[0].findElement(By.tagName('text')).then(function (text) {927 text.getText().then(function (value) {928 expect(value).toBe('data-0 Min')929 });930 });931 cells[1].findElement(By.tagName('text')).then(function (text) {932 text.getText().then(function (value) {933 expect(value).toBe('data-0 Avg')934 });935 });936 cells[2].findElement(By.tagName('text')).then(function (text) {937 text.getText().then(function (value) {938 expect(value).toBe('data-0 Max')939 done();940 });941 });942 });943 graphs[9].findElements(By.tagName('circle')).then(function (circles) {944 expect(circles.length).toBe(3);945 });946 graphs[9].findElements(By.tagName('text')).then(function (text) {947 expect(text.length).toBe(3);948 });949 graphs[11].findElements(By.tagName('circle')).then(function (circles) {950 expect(circles.length).toBe(6);951 });952 graphs[11].findElements(By.tagName('text')).then(function (text) {953 expect(text.length).toBe(6);954 });955 });956 }, 10000);957 it('min-max', function (done) {958 driver.get('file://' + path.join(__dirname + '../../../examples/minMaxValue/minMaxValueTest.html'));959 driver.findElements(By.tagName('svg')).then(function (graphs) {960 expect(graphs.length).toBe(6);961 graphs[1].findElements(By.tagName('circle')).then(function (circles) {962 expect(circles.length).toBe(3);963 });964 graphs[1].findElements(By.className('chart-min-max-value-line')).then(function (lines) {965 expect(lines.length).toBe(3);966 });967 graphs[0].findElements(By.className('axis')).then(function (axes) {968 expect(axes.length).toBe(2);969 });970 graphs[3].findElements(By.tagName('circle')).then(function (circles) {971 expect(circles.length).toBe(3);972 });973 graphs[3].findElements(By.className('chart-min-max-value-line')).then(function (lines) {974 expect(lines.length).toBe(3);975 });976 graphs[2].findElements(By.className('axis')).then(function (axes) {977 expect(axes.length).toBe(2);978 });979 graphs[5].findElements(By.tagName('circle')).then(function (circles) {980 expect(circles.length).toBe(3);981 });982 graphs[5].findElements(By.className('chart-min-max-value-line')).then(function (lines) {983 expect(lines.length).toBe(3);984 });985 graphs[4].findElements(By.className('axis')).then(function (axes) {986 expect(axes.length).toBe(2);987 done();988 });989 });990 }, 10000);991 it('box-plot', function (done) {992 driver.get('file://' + path.join(__dirname + '../../../examples/boxPlot/boxPlotTest.html'));993 driver.findElements(By.tagName('svg')).then(function (graphs) {994 expect(graphs.length).toBe(6);995 graphs[1].findElements(By.tagName('rect')).then(function (rect) {996 expect(rect.length).toBe(3);997 });998 graphs[1].findElements(By.className('chart-box-plot-line')).then(function (lines) {999 expect(lines.length).toBe(12);1000 });1001 graphs[0].findElements(By.className('axis')).then(function (axes) {1002 expect(axes.length).toBe(2);1003 });1004 graphs[3].findElements(By.tagName('rect')).then(function (rect) {1005 expect(rect.length).toBe(3);1006 });1007 graphs[3].findElements(By.className('chart-box-plot-line')).then(function (lines) {1008 expect(lines.length).toBe(12);1009 });1010 graphs[2].findElements(By.className('axis')).then(function (axes) {1011 expect(axes.length).toBe(2);1012 });1013 graphs[5].findElements(By.tagName('rect')).then(function (rect) {1014 expect(rect.length).toBe(3);1015 });1016 graphs[5].findElements(By.className('chart-box-plot-line')).then(function (lines) {1017 expect(lines.length).toBe(12);1018 });1019 graphs[4].findElements(By.className('axis')).then(function (axes) {1020 expect(axes.length).toBe(2);1021 done();1022 });1023 });1024 }, 10000);1025 it('polygon', function (done) {1026 driver.get('file://' + path.join(__dirname + '../../../examples/polygon/polygonTest.html'));1027 driver.findElements(By.tagName('svg')).then(function (svgs) {1028 expect(svgs.length).toBe(6);1029 svgs[1].findElements(By.className('chart-line')).then(function (lines) {1030 expect(lines.length).toBe(1);1031 });1032 svgs[0].findElements(By.className('axis')).then(function (axes) {1033 expect(axes.length).toBe(2);1034 });1035 svgs[3].findElements(By.tagName('path')).then(function (lines) {1036 expect(lines.length).toBe(2);1037 });1038 svgs[3].findElements(By.tagName('text')).then(function (text) {1039 expect(text.length).toBe(1);1040 });1041 svgs[2].findElements(By.className('axis')).then(function (axes) {1042 expect(axes.length).toBe(2);1043 });1044 svgs[5].findElements(By.className('chart-line')).then(function (lines) {1045 expect(lines.length).toBe(1);1046 });1047 svgs[4].findElements(By.className('axis')).then(function (axes) {1048 expect(axes.length).toBe(2);1049 done();1050 });1051 });1052 }, 10000);1053 it('radar', function (done) {1054 driver.get('file://' + path.join(__dirname + '../../../examples/radar/radarTest.html'));1055 driver.findElements(By.tagName('svg')).then(function (svgs) {1056 expect(svgs.length).toBe(3);1057 svgs[0].findElements(By.className('axis-circle')).then(function (axisCircles) {1058 expect(axisCircles.length).toBe(5);1059 });1060 svgs[0].findElements(By.className('axis-line')).then(function (axisLines) {1061 expect(axisLines.length).toBe(5);1062 });1063 svgs[0].findElements(By.className('radar-blob')).then(function (blobs) {1064 expect(blobs.length).toBe(2);1065 blobs[0].findElements(By.className('radar-area')).then(function (areas) {1066 expect(areas.length).toBe(2);1067 });1068 blobs[0].findElements(By.className('radar-circle')).then(function (circles) {1069 expect(circles.length).toBe(5);1070 });1071 blobs[1].findElements(By.className('radar-area')).then(function (areas) {1072 expect(areas.length).toBe(2);1073 });1074 blobs[1].findElements(By.className('radar-circle')).then(function (circles) {1075 expect(circles.length).toBe(5);1076 });1077 });1078 svgs[1].findElements(By.className('axis-circle')).then(function (axisCircles) {1079 expect(axisCircles.length).toBe(5);1080 });1081 svgs[1].findElements(By.className('axis-line')).then(function (axisLines) {1082 expect(axisLines.length).toBe(6);1083 });1084 svgs[1].findElements(By.className('radar-blob')).then(function (blobs) {1085 expect(blobs.length).toBe(2);1086 blobs[0].findElements(By.className('radar-area')).then(function (areas) {1087 expect(areas.length).toBe(2);1088 });1089 blobs[0].findElements(By.className('radar-circle')).then(function (circles) {1090 expect(circles.length).toBe(6);1091 });1092 blobs[1].findElements(By.className('radar-area')).then(function (areas) {1093 expect(areas.length).toBe(2);1094 });1095 blobs[1].findElements(By.className('radar-circle')).then(function (circles) {1096 expect(circles.length).toBe(6);1097 });1098 });1099 svgs[2].findElements(By.className('axis-circle')).then(function (axisCircles) {1100 expect(axisCircles.length).toBe(5);1101 });1102 svgs[2].findElements(By.className('axis-line')).then(function (axisLines) {1103 expect(axisLines.length).toBe(6);1104 });1105 svgs[2].findElements(By.className('radar-blob')).then(function (blobs) {1106 expect(blobs.length).toBe(2);1107 blobs[0].findElements(By.className('radar-area')).then(function (areas) {1108 expect(areas.length).toBe(1);1109 });1110 blobs[0].findElements(By.className('radar-circle')).then(function (circles) {1111 expect(circles.length).toBe(6);1112 });1113 blobs[1].findElements(By.className('radar-area')).then(function (areas) {1114 expect(areas.length).toBe(1);1115 });1116 blobs[1].findElements(By.className('radar-circle')).then(function (circles) {1117 expect(circles.length).toBe(6);1118 done();1119 });1120 });1121 });1122 }, 10000);1123 it('gradient-legend', function (done) {1124 driver.get('file://' + path.join(__dirname + '../../../examples/gradientLegend/gradientLegendTest.html'));1125 driver.findElements(By.tagName('svg')).then(function (graphs) {1126 expect(graphs.length).toBe(2);1127 graphs[0].findElements(By.className('gradient')).then(function (rect) {1128 expect(rect.length).toBe(4);1129 done();1130 });1131 });1132 }, 10000);1133 it('heat-map', function (done) {1134 driver.get('file://' + path.join(__dirname + '../../../examples/heatMap/heatMapTest.html'));1135 driver.findElements(By.tagName('canvas')).then(function (canvas) {1136 expect(canvas.length).toBe(3);1137 done();1138 });1139 }, 10000);1140 it('port-diagram', function (done) {1141 driver.get('file://' + path.join(__dirname + '../../../examples/portDiagram/portDiagramTest.html'));1142 driver.findElements(By.tagName('svg')).then(function (graphs) {1143 expect(graphs.length).toBe(3);1144 graphs[0].findElements(By.className('node')).then(function (nodes) {1145 expect(nodes.length).toBe(8);1146 });1147 graphs[0].findElements(By.className('port')).then(function (ports) {1148 expect(ports.length).toBe(17);1149 });1150 graphs[0].findElements(By.className('link')).then(function (links) {1151 expect(links.length).toBe(9);1152 });1153 graphs[1].findElements(By.className('border')).then(function (nodes) {1154 expect(nodes.length).toBe(7);1155 });1156 graphs[1].findElements(By.className('title-box')).then(function (nodes) {1157 expect(nodes.length).toBe(7);1158 });1159 graphs[1].findElements(By.className('port')).then(function (ports) {1160 expect(ports.length).toBe(17);1161 });1162 graphs[1].findElements(By.className('link')).then(function (links) {1163 expect(links.length).toBe(9);1164 });1165 graphs[2].findElements(By.className('border')).then(function (nodes) {1166 expect(nodes.length).toBe(7);1167 });1168 graphs[2].findElements(By.className('title-box')).then(function (nodes) {1169 expect(nodes.length).toBe(7);1170 });1171 graphs[2].findElements(By.className('port')).then(function (ports) {1172 expect(ports.length).toBe(17);1173 });1174 graphs[2].findElements(By.className('link')).then(function (links) {1175 expect(links.length).toBe(9);1176 });1177 });1178 driver.findElements(By.tagName('canvas')).then(function (graphs) {1179 expect(graphs.length).toBe(3);1180 done();1181 });1182 }, 10000);1183 it('vue', function (done) {1184 driver.get('file://' + path.join(__dirname + '../../../examples-frameworks/vue/vue.html'));1185 driver.findElements(By.tagName('canvas')).then(function (canvas) {1186 expect(canvas.length).toBe(1);1187 });1188 driver.findElements(By.tagName('svg')).then(function (svg) {1189 expect(svg.length).toBe(19);1190 });1191 driver.findElements(By.className('ag-root')).then(function (grid) {1192 expect(grid.length).toBe(1);1193 });1194 driver.findElements(By.className('node-row')).then(function (nodes) {1195 expect(nodes.length).toBe(3);1196 done();1197 });1198 }, 10000);1199 it('angular1', function (done) {1200 driver.get('file://' + path.join(__dirname + '../../../examples-frameworks/angular1/angular1Test.html'));1201 driver.findElements(By.tagName('canvas')).then(function (canvas) {1202 expect(canvas.length).toBe(1);1203 });1204 driver.findElements(By.tagName('svg')).then(function (svg) {1205 expect(svg.length).toBe(19);1206 });1207 driver.findElements(By.className('ag-root')).then(function (grid) {1208 expect(grid.length).toBe(1);1209 done();1210 });1211 }, 10000);1212 it('angular2', function (done) {1213 driver.get('file://' + path.join(__dirname + '../../../examples-frameworks/angular2/angular2Test.html'));1214 driver.findElements(By.tagName('canvas')).then(function (canvas) {1215 expect(canvas.length).toBe(1);1216 });1217 driver.findElements(By.tagName('svg')).then(function (svg) {1218 expect(svg.length).toBe(23);1219 });1220 driver.findElements(By.className('ag-root')).then(function (grid) {1221 expect(grid.length).toBe(1);1222 });1223 driver.findElements(By.className('node-row')).then(function (nodes) {1224 expect(nodes.length).toBe(7);1225 done();1226 });1227 }, 10000);1228 it('react', function (done) {1229 driver.get('file://' + path.join(__dirname + '../../../examples-frameworks/react/react.html'));1230 driver.findElements(By.tagName('canvas')).then(function (canvas) {1231 expect(canvas.length).toBe(1);1232 });1233 driver.findElements(By.tagName('svg')).then(function (svg) {1234 expect(svg.length).toBe(27);1235 });1236 driver.findElements(By.className('ag-root')).then(function (grid) {1237 expect(grid.length).toBe(1);1238 });1239 driver.findElements(By.className('node-row')).then(function (nodes) {1240 expect(nodes.length).toBe(6);1241 done();1242 });1243 }, 10000);...
Smaugbudget.test.js
Source:Smaugbudget.test.js
...47 48 // PoÄakaj doloÄeno Å¡tevilo sekund na zahtevani element na strani49 let waitPageLoaded = async (browser, timeVS, xpath) => {50 await browser.wait(() => {51 return browser.findElements(By.xpath(xpath)).then(elementi => {52 return elementi[0];53 });54 }, timeVS * 1000, `Page did not load in ${timeVS} s.`);55 };56 57 try {58 59 before(() => {60 browser = new Builder()61 .forBrowser("chrome")62 .setChromeOptions(new chrome.Options()63 .addArguments("start-maximized")64 .addArguments("disable-infobars")65 .addArguments("allow-insecure-localhost")66 .addArguments("allow-running-insecure-content")67 )68 .usingServer(seleniumServerUrl)69 .build();70 });71 //Finished72 /*describe("Register", function() {73 this.timeout(30 * 1000);74 before(() => { browser.get(applicationUrl); });75 context("Register new user", function() {76 it("Open modal", async () => {77 await waitPageLoaded(browser, 10, "//h4");78 await new Promise(r => setTimeout(r, 2000));79 let registerButton = await browser.findElements(By.xpath("//a[contains(@href, '#registration')]"));80 expect(registerButton).to.not.be.empty;81 await registerButton[1].click();82 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));83 expect(opened).to.not.be.empty;84 await new Promise(r => setTimeout(r, 1000));85 });86 87 it("Enter data", async () => {88 let nameField = await browser.findElements(By.xpath("//input[contains(@id, 'nameup')]"));89 expect(nameField).to.not.be.empty;90 nameField[0].sendKeys("Bodza");91 console.log(await browser.findElements(By.xpath("//input[contains(@id, 'nameup')]")));92 let surnameField = await browser.findElements(By.xpath("//input[contains(@id, 'surnameup')]"));93 expect(surnameField).to.not.be.empty;94 surnameField[0].sendKeys("Reciever");95 let email1Field = await browser.findElements(By.xpath("//input[contains(@id, 'email1up')]"));96 expect(email1Field).to.not.be.empty;97 email1Field[0].sendKeys("BodzaGolman@gmail.com");98 let email2Field = await browser.findElements(By.xpath("//input[contains(@id, 'email2up')]"));99 expect(email2Field).to.not.be.empty;100 email2Field[0].sendKeys("BodzaGolman@gmail.com");101 let password1Field = await browser.findElements(By.xpath("//input[contains(@id, 'password1up')]"));102 expect(password1Field).to.not.be.empty;103 password1Field[0].sendKeys("VelikaZoga1!");104 let password2Field = await browser.findElements(By.xpath("//input[contains(@id, 'password2up')]"));105 expect(password2Field).to.not.be.empty;106 password2Field[0].sendKeys("VelikaZoga1!");107 await new Promise(r => setTimeout(r, 1000));108 });109 it("Register", async () => {110 let registerButton = await browser.findElements(By.xpath("//input[contains(@id, 'buttonid')]"));111 expect(registerButton).to.not.be.empty;112 await registerButton[0].click();113 114 await new Promise(r => setTimeout(r, 1000));115 116 takeScreenshot(browser, 'test/porocilo/data3.png')117 118 await new Promise(r => setTimeout(r, 3000));119 120 var url = await browser.getCurrentUrl();121 console.log(url)122 expect(url).to.include('confirm');123 });124 });125 });*/126 127 128 //Finished129 130 describe("Login", function() {131 context("Fail login", function() {132 this.timeout(60 * 1000);133 before(() => { browser.get(applicationUrl); });134 135 it("Open modal", async () => {136 await waitPageLoaded(browser, 10, "//h4");137 let loginButton = await browser.findElements(By.xpath("//a[contains(text(), 'SIGN IN')]"));138 expect(loginButton).to.not.be.empty;139 await loginButton[0].click();140 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));141 expect(opened).to.not.be.empty;142 await new Promise(r => setTimeout(r, 1000));143 });144 it("Enter data", async () => {145 let emailField = await browser.findElements(By.xpath("//input[contains(@id, 'emailin')]"));146 expect(emailField).to.not.be.empty;147 emailField[0].sendKeys("nonexisting@smaug.com");148 let passwordField = await browser.findElements(By.xpath("//input[contains(@id, 'passwordin')]"));149 expect(passwordField).to.not.be.empty;150 passwordField[0].sendKeys("Somethingrandom");151 152 await new Promise(r => setTimeout(r, 1000));153 });154 it("Login", async () => {155 let loginButton = await browser.findElements(By.xpath("//input[contains(@value, 'Login')]"));156 expect(loginButton).to.not.be.empty;157 loginButton[0].click();158 await new Promise(r => setTimeout(r, 1000));159 var url = await browser.getCurrentUrl();160 expect(url).to.not.include('dashboard');161 });162 it("Close modal", async() => {163 let closeButton = await browser.findElements(By.xpath("//button[contains(@class, 'close')]"));164 expect(closeButton).to.not.be.empty;165 closeButton[0].click();166 await new Promise(r => setTimeout(r, 1000));167 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));168 expect(opened).to.be.empty;169 });170 });171 context("Successfully login Gold User", function() {172 this.timeout(30 * 1000);173 before(() => { browser.get(applicationUrl); });174 175 it("Open modal", async () => {176 await waitPageLoaded(browser, 10, "//h4");177 let loginButton = await browser.findElements(By.xpath("//a[contains(text(), 'SIGN IN')]"));178 expect(loginButton).to.not.be.empty;179 await loginButton[0].click();180 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));181 expect(opened).to.not.be.empty;182 await new Promise(r => setTimeout(r, 5000));183 });184 it("Enter data", async () => {185 let emailField = await browser.findElements(By.xpath("//input[contains(@id, 'emailin')]"));186 expect(emailField).to.not.be.empty;187 emailField[0].sendKeys("gold@smaug.com");188 let passwordField = await browser.findElements(By.xpath("//input[contains(@id, 'passwordin')]"));189 expect(passwordField).to.not.be.empty;190 passwordField[0].sendKeys("Goldpass1");191 192 await new Promise(r => setTimeout(r, 1000));193 });194 it("Login", async () => {195 let loginButton = await browser.findElements(By.xpath("//input[contains(@value, 'Login')]"));196 expect(loginButton).to.not.be.empty;197 loginButton[0].click();198 await new Promise(r => setTimeout(r, 20000));199 var url = await browser.getCurrentUrl();200 expect(url).to.include('dashboard');201 await new Promise(r => setTimeout(r, 2000));202 });203 });204 });205 /*206 describe("Envelope", function() {207 this.timeout(30 * 1000);208 context("Fail saving existing envelope", async () => {209 this.timeout(30 * 1000);210 211 it("Open envelopes tab", async () => {212 let envelopesButton = await browser.findElements(By.xpath("//a[contains(@routerlink, '../envelopes')]"));213 expect(envelopesButton).to.not.be.empty;214 envelopesButton[0].click();215 await new Promise(r => setTimeout(r, 5000));216 217 var url = await browser.getCurrentUrl();218 expect(url).to.include('envelopes');219 });220 it("Open modal", async () => {221 let addEnvelopesButton = await browser.findElements(By.xpath("//button[contains(@href, '#addEnvelopeForm')]"));222 expect(addEnvelopesButton).to.not.be.empty;223 addEnvelopesButton[0].click();224 await new Promise(r => setTimeout(r, 1000));225 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));226 expect(opened).to.not.be.empty;227 });228 it("Enter data", async () => {229 let categoryField = await browser.findElements(By.xpath("//select[contains(@name, 'chooseCategoryEnvelope')]"));230 expect(categoryField).to.not.be.empty;231 categoryField[0].click();232 await new Promise(r => setTimeout(r, 1000));233 let categoryOptionField = await browser.findElements(By.xpath("//option[contains(@value, 'Car')]"));234 expect(categoryOptionField).to.not.be.empty;235 categoryOptionField[0].click();236 await new Promise(r => setTimeout(r, 1000));237 let ammountField = await browser.findElements(By.xpath("//input[contains(@name, 'inputAmount')]"));238 expect(ammountField).to.not.be.empty;239 ammountField[0].click();240 await new Promise(r => setTimeout(r, 1000));241 ammountField[0].sendKeys("250");242 await new Promise(r => setTimeout(r, 1000));243 });244 it("Save envelope", async () => {245 let addEnvelopesButton = await browser.findElements(By.xpath("//button[contains(@id, 'buttonAddEnvelopes')]"));246 expect(addEnvelopesButton).to.not.be.empty;247 addEnvelopesButton[0].click();248 await new Promise(r => setTimeout(r, 1000));249 await new Promise(r => setTimeout(r, 1000));250 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));251 expect(opened).to.not.be.empty;252 await new Promise(r => setTimeout(r, 1000));253 });254 });255 context("Delete envelope", async () => {256 this.timeout(30 * 1000);257 before(() => { browser.get(applicationUrl); }); 258 it("Open envelopes tab", async () => {259 let envelopesButton = await browser.findElements(By.xpath("//a[contains(@routerlink, '../envelopes')]"));260 expect(envelopesButton).to.not.be.empty;261 envelopesButton[0].click();262 await new Promise(r => setTimeout(r, 1000));263 envelopesButton[0].click();264 await new Promise(r => setTimeout(r, 5000));265 var url = await browser.getCurrentUrl();266 expect(url).to.include('envelopes');267 await new Promise(r => setTimeout(r, 2000));268 });269 it("Delete envelope", async () => {270 let deleteButton = await browser.findElements(By.xpath("//button[contains(@class, 'btn edit-btn')]"));271 expect(deleteButton).to.not.be.empty;272 deleteButton[0].click();273 await new Promise(r => setTimeout(r, 2000));274 await browser.switchTo().alert().accept();275 await new Promise(r => setTimeout(r, 2000));276 });277 });278 context("Save new envelope", async () => {279 this.timeout(30 * 1000);280 /*before(() => { browser.get(applicationUrl); });281 282 it("Open envelopes tab", async () => {283 let envelopesButton = await browser.findElements(By.xpath("//a[contains(@routerlink, '../envelopes')]"));284 expect(envelopesButton).to.not.be.empty;285 envelopesButton[0].click();286 await new Promise(r => setTimeout(r, 2000));287 288 var url = await browser.getCurrentUrl();289 expect(url).to.include('envelopes');290 });291 it("Open modal", async () => {292 let addEnvelopesButton = await browser.findElements(By.xpath("//button[contains(@href, '#addEnvelopeForm')]"));293 expect(addEnvelopesButton).to.not.be.empty;294 addEnvelopesButton[0].click();295 await new Promise(r => setTimeout(r, 1000));296 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));297 expect(opened).to.not.be.empty;298 });299 it("Enter data", async () => {300 let categoryField = await browser.findElements(By.xpath("//select[contains(@name, 'chooseCategoryEnvelope')]"));301 expect(categoryField).to.not.be.empty;302 categoryField[0].click();303 await new Promise(r => setTimeout(r, 1000));304 let categoryOptionField = await browser.findElements(By.xpath("//option[contains(@value, 'Car')]"));305 expect(categoryOptionField).to.not.be.empty;306 categoryOptionField[0].click();307 await new Promise(r => setTimeout(r, 1000));308 let ammountField = await browser.findElements(By.xpath("//input[contains(@name, 'inputAmount')]"));309 expect(ammountField).to.not.be.empty;310 ammountField[0].click();311 await new Promise(r => setTimeout(r, 1000));312 ammountField[0].sendKeys("100");313 await new Promise(r => setTimeout(r, 1000));314 });315 it("Save envelope", async () => {316 let addEnvelopesButton = await browser.findElements(By.xpath("//button[contains(@id, 'buttonAddEnvelopes')]"));317 expect(addEnvelopesButton).to.not.be.empty;318 addEnvelopesButton[0].click();319 await new Promise(r => setTimeout(r, 2000));320 addEnvelopesButton[0].click();321 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));322 expect(opened).to.not.be.empty;323 await new Promise(r => setTimeout(r, 5000));324 });325 });326 });327 */328 describe("Add new goal", function() {329 context("Failed to create new goal", function() {330 this.timeout(60 * 1000);331 it("Redirect to goal tab", async () => {332 let goalLink = await browser.findElements(By.xpath("//a[contains(@routerlink, '../goals')]"));333 await new Promise(r => setTimeout(r, 1000));334 expect(goalLink).to.not.be.empty;335 goalLink[0].click();336 337 await new Promise(r => setTimeout(r, 11000));338 var url = await browser.getCurrentUrl();339 expect(url).to.include('goals');340 });341 342 it("Open modal", async () => {343 let addGoalButton = await browser.findElements(By.xpath("//button[contains(@href, '#addGoalForm')]"));344 await new Promise(r => setTimeout(r, 1000));345 expect(addGoalButton).to.not.be.empty;346 addGoalButton[0].click();347 await new Promise(r => setTimeout(r, 1000));348 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));349 expect(opened).to.not.be.empty;350 });351 352 it("Enter data", async () => {353 let goalName = await browser.findElements(By.xpath("//input[contains(@id, 'Goal')]"));354 expect(goalName).to.not.be.empty;355 goalName[0].sendKeys("House");356 await new Promise(r => setTimeout(r, 5000));357 358 let categoryField = await browser.findElements(By.xpath("//select[contains(@name, 'inputCategory')]"));359 expect(categoryField).to.not.be.empty;360 categoryField[0].click();361 await new Promise(r => setTimeout(r, 1000));362 let categoryOptionField = await browser.findElements(By.xpath("//option[contains(text(), 'Home')]"));363 expect(categoryOptionField).to.not.be.empty;364 categoryOptionField[0].click();365 await new Promise(r => setTimeout(r, 1000));366 367 let amount = await browser.findElements(By.xpath("//input[contains(@id, 'Amount')]"));368 expect(amount).to.not.be.empty;369 amount[0].sendKeys("30000");370 await new Promise(r => setTimeout(r, 1000));371 372 let buttonAdd = await browser.findElements(By.xpath("//button[contains(@id, 'buttonAddGoal')]"));373 expect(buttonAdd).to.not.be.empty;374 buttonAdd[0].click();375 await new Promise(r => setTimeout(r, 2000));376 });377 });378 context("Successful new goal", function() {379 this.timeout(30 * 1000);380 before(() => { browser.get(applicationUrl); });381 it("Redirect to goal tab", async () => {382 await new Promise(r => setTimeout(r, 1000));383 let goalLink = await browser.findElements(By.xpath("//a[contains(@routerlink, '../goals')]"));384 await new Promise(r => setTimeout(r, 1000));385 expect(goalLink).to.not.be.empty;386 goalLink[0].click();387 388 await new Promise(r => setTimeout(r, 5000));389 var url = await browser.getCurrentUrl();390 expect(url).to.include('goals');391 });392 393 it("Open add modal", async () => {394 let addGoalButton = await browser.findElements(By.xpath("//button[contains(@href, '#addGoalForm')]"));395 await new Promise(r => setTimeout(r, 1000));396 expect(addGoalButton).to.not.be.empty;397 addGoalButton[0].click();398 await new Promise(r => setTimeout(r, 1000));399 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));400 expect(opened).to.not.be.empty;401 });402 403 it("Enter data", async () => {404 let goalName = await browser.findElements(By.xpath("//input[contains(@id, 'Goal')]"));405 expect(goalName).to.not.be.empty;406 goalName[0].sendKeys("House");407 await new Promise(r => setTimeout(r, 1000));408 409 let categoryField = await browser.findElements(By.xpath("//select[contains(@name, 'inputCategory')]"));410 expect(categoryField).to.not.be.empty;411 categoryField[0].click();412 await new Promise(r => setTimeout(r, 1000));413 let categoryOptionField = await browser.findElements(By.xpath("//option[contains(text(), 'Home')]"));414 expect(categoryOptionField).to.not.be.empty;415 categoryOptionField[0].click();416 await new Promise(r => setTimeout(r, 1000));417 418 let amount = await browser.findElements(By.xpath("//input[contains(@id, 'Amount')]"));419 expect(amount).to.not.be.empty;420 amount[0].sendKeys("30000");421 await new Promise(r => setTimeout(r, 1000));422 423 let date = await browser.findElements(By.xpath("//input[contains(@id, 'inputDateAddGoal')]"));424 expect(date).to.not.be.empty;425 date[0].sendKeys("01/01/2026");426 await new Promise(r => setTimeout(r, 1000));427 let buttonAdd = await browser.findElements(By.xpath("//button[contains(@id, 'buttonAddGoal')]"));428 expect(buttonAdd).to.not.be.empty;429 buttonAdd[0].click();430 await new Promise(r => setTimeout(r, 5000));431 });432 });433 context("Edit goal", function() {434 this.timeout(30 * 1000);435 //before(() => { browser.get(applicationUrl); });436 it("Open edit modal", async () => {437 let editGoalButton = await browser.findElements(By.xpath("//button[contains(@class, 'edit-btn')]"));438 await new Promise(r => setTimeout(r, 1000));439 expect(editGoalButton).to.not.be.empty;440 editGoalButton[5].click();441 await new Promise(r => setTimeout(r, 1000));442 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));443 expect(opened).to.not.be.empty;444 });445 it("Enter data", async () => {446 let categoryField = await browser.findElements(By.xpath("//select[contains(@name, 'inputCategory')]"));447 expect(categoryField).to.not.be.empty;448 categoryField[3].click();449 await new Promise(r => setTimeout(r, 1000));450 let categoryOptionField = await browser.findElements(By.xpath("//option[contains(text(), 'Gifts')]"));451 expect(categoryOptionField).to.not.be.empty;452 categoryOptionField[3].click();453 await new Promise(r => setTimeout(r, 1000));454 let buttonAdd = await browser.findElements(By.xpath("//button[contains(@class, 'btn-primary')]"));455 expect(buttonAdd).to.not.be.empty;456 buttonAdd[5].click();457 await new Promise(r => setTimeout(r, 5000));458 });459 });460 context("Delete goal", function() {461 this.timeout(30 * 1000);462 //before(() => { browser.get(applicationUrl); });463 it("Click delete button", async () => {464 let deleteGoalButton = await browser.findElements(By.xpath("//button[contains(@class, 'edit-btn')]"));465 await new Promise(r => setTimeout(r, 1000));466 expect(deleteGoalButton).to.not.be.empty;467 deleteGoalButton[4].click();468 await new Promise(r => setTimeout(r, 2000));469 await browser.switchTo().alert().accept();470 await new Promise(r => setTimeout(r, 2000));471 });472 });473 });474 describe("History filter", function() {475 context("Find expense", function() {476 this.timeout(30 * 1000);477 it("Redirect to history tab", async () => {478 let historyLink = await browser.findElements(By.xpath("//a[contains(@routerlink, 'history')]"));479 await new Promise(r => setTimeout(r, 1000));480 expect(historyLink).to.not.be.empty;481 historyLink[0].click();482 483 await new Promise(r => setTimeout(r, 11000));484 var url = await browser.getCurrentUrl();485 expect(url).to.include('history');486 await new Promise(r => setTimeout(r, 1000));487 });488 it("Input search", async () => {489 let input = await browser.findElements(By.xpath("//input[contains(@id, 'filter')]"));490 await new Promise(r => setTimeout(r, 1000));491 expect(input).to.not.be.empty;492 input[0].sendKeys('Lidl', Key.ENTER);493 await new Promise(r => setTimeout(r, 2000));494 let tr = await browser.findElements(By.xpath("//td"));495 await new Promise(r => setTimeout(r, 1000));496 expect(tr).to.not.be.empty;497 await new Promise(r => setTimeout(r, 1000));498 let outputVal = await tr[2].getAttribute("innerText");499 await new Promise(r => setTimeout(r, 1000));500 expect(outputVal).to.include('Lidl');501 await new Promise(r => setTimeout(r, 1000));502 });503 });504 });505 506 describe("Money converter", function() {507 context("Successful converting", function() {508 this.timeout(30 * 1000);509 510 it("Redirect to goal tab", async () => {511 let utilitiesLink = await browser.findElements(By.xpath("//a[contains(@routerlink, 'utilities')]"));512 await new Promise(r => setTimeout(r, 1000));513 expect(utilitiesLink).to.not.be.empty;514 utilitiesLink[0].click();515 516 await new Promise(r => setTimeout(r, 11000));517 var url = await browser.getCurrentUrl();518 expect(url).to.include('utilities');519 });520 it("Check if field is empty", async () => {521 let output = await browser.findElements(By.xpath("//output[contains(@id, 'Amount2')]"));522 expect(output).to.not.be.empty;523 await new Promise(r => setTimeout(r, 1000));524 let outputVal = await output[0].getAttribute("value");525 expect(outputVal).to.be.empty;526 await new Promise(r => setTimeout(r, 1000));527 });528 it("Insert data and call", async () => {529 let amount = await browser.findElements(By.xpath("//input[contains(@id, 'Amount')]"));530 expect(amount).to.not.be.empty;531 amount[0].sendKeys("100");532 await new Promise(r => setTimeout(r, 1000));533 let convertButton = await browser.findElements(By.xpath("//button[contains(text(), 'Convert')]"));534 await new Promise(r => setTimeout(r, 1000));535 expect(convertButton).to.not.be.empty;536 convertButton[0].click();537 await new Promise(r => setTimeout(r, 2000));538 convertButton[0].click();539 await new Promise(r => setTimeout(r, 5000));540 });541 it("Check if field has value", async () => {542 let output = await browser.findElements(By.xpath("//output[contains(@id, 'Amount2')]"));543 expect(output).to.not.be.empty;544 await new Promise(r => setTimeout(r, 1000));545 let outputVal = await output[0].getAttribute("value");546 expect(outputVal).to.not.be.empty;547 await new Promise(r => setTimeout(r, 1000));548 });549 });550 });551 552 describe("Logout", function() {553 context("Successful logout", function() {554 before(() => { browser.get(applicationUrl); });555 this.timeout(30 * 1000);556 557 it("Open dropdown", async () => {558 await new Promise(r => setTimeout(r, 5000));559 await waitPageLoaded(browser, 10, "//h4");560 let dropdown = await browser.findElements(By.xpath("//div[contains(@id, 'navbarDropdownMenuLink-4')]"));561 expect(dropdown).to.not.be.empty;562 await dropdown[0].click();563 await new Promise(r => setTimeout(r, 1000));564 let openedDropdown = await browser.findElements(By.xpath("//div[contains(@aria-expanded, 'true')]"));565 expect(openedDropdown).to.not.be.empty;566 });567 it("Logout", async () => {568 await waitPageLoaded(browser, 10, "//h4");569 let logoutButton = await browser.findElements(By.xpath("//a[contains(text(), ' Logout')]"));570 await new Promise(r => setTimeout(r, 1000));571 expect(logoutButton).to.not.be.empty;572 await logoutButton[0].click();573 await new Promise(r => setTimeout(r, 1000));574 var url = await browser.getCurrentUrl();575 expect(url).to.equals('https://smaugbudget.herokuapp.com/');576 });577 });578 });579 580 describe("Reset database with admin account", function() {581 context("Successfully login Admin User", function() {582 this.timeout(30 * 1000);583 before(() => { browser.get(applicationUrl); });584 585 it("Open modal", async () => {586 await waitPageLoaded(browser, 10, "//h4");587 let loginButton = await browser.findElements(By.xpath("//a[contains(text(), 'SIGN IN')]"));588 expect(loginButton).to.not.be.empty;589 await loginButton[0].click();590 let opened = await browser.findElements(By.xpath("//div[contains(@class, 'modal-backdrop fade show')]"));591 expect(opened).to.not.be.empty;592 await new Promise(r => setTimeout(r, 5000));593 });594 it("Enter data", async () => {595 let emailField = await browser.findElements(By.xpath("//input[contains(@id, 'emailin')]"));596 expect(emailField).to.not.be.empty;597 emailField[0].sendKeys("admin@smaug.com");598 let passwordField = await browser.findElements(By.xpath("//input[contains(@id, 'passwordin')]"));599 expect(passwordField).to.not.be.empty;600 passwordField[0].sendKeys("Adminpass1");601 602 await new Promise(r => setTimeout(r, 1000));603 });604 it("Login", async () => {605 let loginButton = await browser.findElements(By.xpath("//input[contains(@value, 'Login')]"));606 expect(loginButton).to.not.be.empty;607 loginButton[0].click();608 await new Promise(r => setTimeout(r, 20000));609 610 var url = await browser.getCurrentUrl();611 expect(url).to.include('dashboard');612 await new Promise(r => setTimeout(r, 2000));613 });614 context("Navigate to administration panel", function() {615 it("Open dropdown", async () => {616 await waitPageLoaded(browser, 10, "//h4");617 let dropdown = await browser.findElements(By.xpath("//div[contains(@id, 'navbarDropdownMenuLink-4')]"));618 expect(dropdown).to.not.be.empty;619 await dropdown[0].click();620 await new Promise(r => setTimeout(r, 1000));621 let openedDropdown = await browser.findElements(By.xpath("//div[contains(@aria-expanded, 'true')]"));622 expect(openedDropdown).to.not.be.empty;623 });624 it("Click on administartion panel", async () => {625 await waitPageLoaded(browser, 10, "//h4");626 let adminButton = await browser.findElements(By.xpath("//a[contains(text(), ' Administration panel')]"));627 await new Promise(r => setTimeout(r, 1000));628 expect(adminButton).to.not.be.empty;629 await adminButton[0].click();630 await new Promise(r => setTimeout(r, 1000));631 632 var url = await browser.getCurrentUrl();633 expect(url).to.equals('https://smaugbudget.herokuapp.com/db');634 });635 });636 context("Reset database", function() {637 it("Click on delete all data", async () => {638 let deleteDataButton = await browser.findElements(By.xpath("//button[contains(@class, 'btn btn-danger')]"));639 await new Promise(r => setTimeout(r, 1000));640 expect(deleteDataButton).to.not.be.empty;641 deleteDataButton[0].click();642 await new Promise(r => setTimeout(r, 1000));643 await browser.switchTo().alert().accept();644 });645 it("Click on add test data", async () => {646 let addDataButton = await browser.findElements(By.xpath("//button[contains(@class, 'btn btn-success')]"));647 await new Promise(r => setTimeout(r, 1000));648 expect(addDataButton).to.not.be.empty;649 addDataButton[0].click();650 await new Promise(r => setTimeout(r, 1000));651 await browser.switchTo().alert().accept();652 });653 });654 });655 });656 after(async () => {657 browser.quit();658 });659 660 } catch (error) {...
stepdefs.js
Source:stepdefs.js
...4let driver = require("chromedriver");5driver = new Builder().forBrowser("chrome").build();6Given('I am on the login page', async function () {7 await driver.get("http://localhost:3000/");8 let text = await driver.findElements(By.className("entry-text"))9 assert.equal(text != null, true)10})11Given('I am on the catalog page', async function () {12 await driver.get("http://localhost:3000/catalog");13 setTimeout(async function () {14 let filters = await driver.findElements(By.className("FilterTitle"))15 assert.equal(await filters[0].getText(), "Price")16 assert.equal(await filters[1].getText(), "Rating")17 }, 5000);18})19Given('I am on the catalog page with an item in my cart', async function () {20 setTimeout(async function () {21 await driver.get("http://localhost:3000/catalog");22 let filters = await driver.findElements(By.className("FilterTitle"))23 assert.equal(await filters[0].getText(), "Price")24 assert.equal(await filters[1].getText(), "Rating")25 let add_buttons = await driver.findElements(By.className("CartIcon"))26 add_buttons = await driver.findElements(By.className("CartIcon"))27 add_buttons[0].click()28 }, 6000);29})30Given('I am on the product details page', async function () {31 setTimeout(async function () {32 await driver.get("http://localhost:3000/productdetails");33 let shirts = await driver.findElements(By.className("ProductImage"))34 assert.equal(await shirts.length == 1, true)35 }, 3000);36})37When('I go to the website link', async function () {38 await driver.get("http://localhost:3000/");39})40When('I go to the auth link', async function () {41 await driver.get("http://localhost:3000/auth");42})43When('I go to the catalog', async function () {44 await driver.get("http://localhost:3000/catalog");45 let buttons = await driver.findElements(By.className("firebaseui-idp-button mdl-button mdl-js-button mdl-button--raised firebaseui-idp-google firebaseui-id-idp-button"))46 //buttons[0].click()47})48Then('I should see the welcome text', async function () {49 let text = await driver.findElements(By.className("entry-text"))50 assert.equal(text != null, true)51})52Then("I Login", async function () {53 let buttons = await driver.findElements(By.className("firebaseui-idp-button mdl-button mdl-js-button mdl-button--raised firebaseui-idp-google firebaseui-id-idp-button"))54 assert.equal(buttons != null, true)55})56Then('I should see the filters', async function () {57 let filters = await driver.findElements(By.className("FilterTitle"))58 assert.equal(await filters[0].getText(), "Price")59 assert.equal(await filters[1].getText(), "Rating")60})61Then('I should see all the shirts', async function () {62 setTimeout(async function () {63 let shirts = await driver.findElements(By.className("Item"))64 assert.equal(await shirts.length > 3, true)65 }, 3000);66})67Then('I should have an empty cart', async function () {68 assert.equal(await driver.findElement(By.className("CartCountText")).getText(), "0")69})70When('I add an item to the cart', async function () {71 setTimeout(async function () {72 let add_buttons = await driver.findElements(By.className("CartIcon"))73 add_buttons = await driver.findElements(By.className("CartIcon"))74 try {75 add_buttons[1].click()76 } catch (e) {77 add_buttons[0].click()78 }79 }, 7000);80})81When('I remove an item from the cart', async function () {82 setTimeout(async function () {83 let add_buttons = await driver.findElements(By.className("CartIcon"))84 add_buttons[0].click()85 }, 5000);86})87When('I filter by price', async function () {88 let filter_buttons = await driver.findElements(By.className("Check"))89 filter_buttons[0].click()90})91When('I filter by rating', async function () {92 let filter_buttons = await driver.findElements(By.className("Check"))93 filter_buttons[6].click()94})95When('I search for the brand Generic', async function () {96 setTimeout(async function () {97 let filter_buttons = await driver.findElements(By.className("SearchBar"))98 filter_buttons[1].sendKeys("Generic")99 let search_button = await driver.findElements(By.className("SearchIcon"))100 search_button[0].click()101 }, 3000);102})103When('I click on product image', async function () {104 setTimeout(async function () {105 let products = await driver.findElements(By.className("ProductImage"))106 products[1].click()107 }, 3000);108})109Then('I should have 1 item in the cart', async function () {110 setTimeout(async function () {111 let el = await driver.findElement(By.className("CartCountText"))112 assert.equal(el.getText(), "1")113 }, 5000);114})115Then('I should have results filtered by price', async function () {116 let shirts = await driver.findElements(By.className("Item"))117 assert.equal(await shirts.length < 20, true)118})119Then('I should have results filtered by rating', async function () {120 let shirts = await driver.findElements(By.className("Item"))121 assert.equal(await shirts.length < 15, true)122})123Then('I should see Generic shirts', async function () {124 setTimeout(async function () {125 let shirts = await driver.findElements(By.className("ProductName"))126 assert.equal(await shirts.length < 15, true)127 }, 5000);128})129Then('I should be on product details page', async function () {130 setTimeout(async function () {131 let shirts = await driver.findElements(By.className("ProductImage"))132 assert.equal(await shirts == null, true)133 }, 5000);134})135Then('I should see environmental details', async function () {136 setTimeout(async function () {137 let details = await driver.findElements(By.className("EcoStatsText"))138 assert.equal(details != null, true)139 }, 3000);140})141Then('I should see product description', async function () {142 setTimeout(async function () {143 let details = await driver.findElements(By.className("ProductDescription"))144 assert.equal(details != null, true)145 }, 3000);...
script.js
Source:script.js
...16 await browser.get("https://www.thesparksfoundationsingapore.org/")17 browser.manage().window().maximize();1819 await browser.wait(wd.until.elementLocated(wd.By.css(".dropdown-toggle.menu__link")))20 let pages = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))21 await pages[0].click();2223 await browser.wait(wd.until.elementLocated(wd.By.css(".dropdown-menu li")))24 let pagesCount =await browser.findElements(wd.By.css(".dropdown-menu li"))25 await pagesCount[0].click()2627 page1()2829 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-toggle.menu__link")))30 let pagess = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))31 await pagess[1].click();3233 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-menu li")))34 let pagesCount2 = await browser.findElements(wd.By.css(".dropdown-menu li"))35 await pagesCount2[8].click()3637 page2()3839 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-toggle.menu__link")))40 let page = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))41 await page[2].click();42 43 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-menu li")))44 let pagesCount3 = await browser.findElements(wd.By.css(".dropdown-menu li"))45 await pagesCount3[12].click()46 page3()4748 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-toggle.menu__link")))49 let pagesss = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))50 await pagesss[3].click();51 52 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-menu li")))53 let pagesCount4 = await browser.findElements(wd.By.css(".dropdown-menu li"))54 await pagesCount4[19].click()55 page4()565758 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-toggle.menu__link")))59 let pageL = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))60 await pageL[4].click();61 62 await browser.wait(wd.until.elementsLocated(wd.By.css(".dropdown-menu li")))63 let pagesCount5 = await browser.findElements(wd.By.css(".dropdown-menu li"))64 await pagesCount5[20].click()65 page5()6667 await browser.wait(wd.until.elementLocated(wd.By.css(".dropdown-toggle.menu__link")))68 let pagesL = await browser.findElements(wd.By.css(".dropdown-toggle.menu__link"))69 await pagesL[0].click();7071 await browser.wait(wd.until.elementLocated(wd.By.css(".col-md-6.navbar-brand")))72 let pagesCountN =await browser.findElements(wd.By.css(".dropdown-menu li"))73 await pagesCountN[6].click()7475 console.log(pageContent)7677}7879async function page1(){80 let check = await browser.wait(wd.until.elementLocated(wd.By.css(".nav.navbar-nav")))81 if(check) navBar = "nav bar exsists"8283 await browser.wait(wd.until.elementsLocated(wd.By.css(".tittle-agileits-w3layouts span")))8485 let topicName =await browser.findElements(wd.By.css(".tittle-agileits-w3layouts span"))8687 for(let i=0; i < topicName.length;i++){88 statemt = await topicName[i].getAttribute("innerText")89 mission.push(statemt)90 }9192 pageContent.push({"Page No ": "page1-Vision, Mission And Values", "NavBar exsists on this page ?" : navBar, "statements" :mission})9394}9596async function page2(){9798 let logoCheck = await browser.wait(wd.until.elementLocated(wd.By.css(".col-md-6.navbar-brand img")))99100 if(logoCheck){101 logo = "logo exsists on this page"102 } 103104 let undertitle = await browser.findElement(wd.By.css(".col-md-6.navbar-brand span"))105 let text = await undertitle.getAttribute("innerText")106107 pageContent.push({"Page No ": "page2-Code Of Ethics And Conduct", "logo exsists on this page ?" : logo, "quoto below the title" :text})108109}110111async function page3(){112113 await browser.wait(wd.until.elementLocated(wd.By.css(".scroll")))114 let scroll = await browser.findElement(wd.By.css(".scroll"))115 await scroll.click()116117 await browser.wait(wd.until.elementsLocated(wd.By.css(".button-w3layouts.hvr-rectangle-out.tsf-button")))118 let noCol = await browser.findElements(wd.By.css(".button-w3layouts.hvr-rectangle-out.tsf-button"))119120 pageContent.push({"Page No ": "page3-Student Scholarship Program", "is scroller working ?" : "yes", "Total No. Of Programs" :noCol.length})121 122}123124async function page4(){125126 await browser.wait(wd.until.elementLocated(wd.By.css(".fa.fa-medium")))127 let copyRights = await browser.findElement(wd.By.css(".fa.fa-medium"))128 if(copyRights){129 mailIcon = "it has mail icon"130 } 131132 let footerName = await browser.findElements(wd.By.css(".col-md-3.footer-grids.w3l-agileits a"))133 let footerText = await footerName[0].getAttribute("innerText")134135 pageContent.push({"Page No ": "page4-AI In Education", "is mail Icon present ?" : mailIcon, "THE SPARKS FOUNDATION = " :footerText})136}137138async function page5(){139 140 await browser.wait(wd.until.elementLocated(wd.By.css(".form-bg-w3ls")))141 let submitBox = await browser.findElement(wd.By.css(".form-bg-w3ls"))142 if(submitBox) join ="Joining Box is there"143144 let rolOption = await browser.findElements(wd.By.css(".form-control option"))145146 pageContent.push({"Page No ": "page5-Join Us", "is Joining Box there ?" : join, "total no. of role options available are" :rolOption.length})147}148
...
profile-spec.js
Source:profile-spec.js
...4 beforeAll(function() {5 browser.get('/ant-eater');6 browser.driver.sleep(100);7 elem = browser.driver.findElement(by.css('.login-form'))8 elem.findElements(by.tagName('input')).then(function(inputs){9 inputs[0].sendKeys("my_1_own_email@exemple.com");10 inputs[1].sendKeys("Truepass1");11 });12 browser.driver.findElement(by.css('.login-form > button')).click()13 browser.driver.sleep(2000);14 });15 it('create post', function() {16 expect(browser.getCurrentUrl()).toBe(url);17 $('.new-post').click();18 browser.driver.findElement(by.css('.post-forms > form > textarea')).sendKeys("New posts test");19 browser.driver.findElement(by.css('.post-forms > form > button')).click();20 browser.driver.sleep(500);21 browser.driver.findElements(by.css('.post')).then(function(posts){22 expect(posts[0].findElement(by.css('.post-text')).getText()).toEqual("New posts test");23 });24 browser.driver.sleep(500);25 });26 it('create comment', function() {27 browser.driver.findElements(by.css('.new-comment')).then(function(buttons){28 buttons[0].click();29 });30 browser.driver.findElement(by.css('.comment-forms > form > textarea')).sendKeys("New comment test");31 browser.driver.findElement(by.css('.comment-forms > form > button')).click();32 browser.driver.sleep(500);33 browser.driver.findElements(by.css('.comment')).then(function(comments){34 expect(comments[0].findElement(by.css('.comment-text')).getText()).toEqual("New comment test");35 });36 });37 it('add rating to post', function() {38 browser.driver.findElements(by.css('.like')).then(function(buttons){39 buttons[0].click();40 });41 browser.driver.sleep(100);42 browser.driver.findElements(by.css('.like')).then(function(ratings){43 expect(ratings[0].getText()).toEqual("1");44 });45 browser.driver.findElements(by.css('.like')).then(function(buttons){46 buttons[0].click();47 });48 browser.driver.findElements(by.css('.dislike')).then(function(buttons){49 buttons[0].click();50 });51 browser.driver.sleep(100);52 browser.driver.findElements(by.css('.like')).then(function(ratings){53 expect(ratings[0].getText()).toEqual("1");54 });55 browser.driver.findElements(by.css('.dislike')).then(function(ratings){56 expect(ratings[0].getText()).toEqual("0");57 });58 });59 it('delete comment', function() {60 browser.driver.findElements(by.css('.edit-comment')).then(function(buttons){61 buttons[0].click();62 });63 browser.driver.sleep(500);64 elem = $('.comment')65 expect(elem).toEqual(0);66 });67 it('delete post', function() {68 browser.driver.findElements(by.css('.edit-post')).then(function(buttons){69 buttons[0].click();70 });71 browser.driver.sleep(500);72 browser.driver.findElements(by.css('.post')).then(function(posts){73 expect(posts[0].getText()).not.toEqual("New posts test");74 });75 });76 it('show full size avatar', function() {77 browser.driver.findElements(by.css('.large-image')).then(function(images){78 expect(images[0].isDisplayed()).toEqual(false);79 $('.avatar').click();80 expect(images[0].isDisplayed()).toEqual(true);81 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){82 buttons[0].click();83 });84 expect(images[0].isDisplayed()).toEqual(false);85 });86 });87 afterAll(function() {88 browser.get('/ant-eater');89 browser.driver.sleep(500);90 browser.actions().mouseMove($('.dropdown')).perform();91 browser.driver.findElements(by.css('.dropdown-menu > a')).then(function(nav){92 nav[1].click();93 });94 browser.driver.sleep(500);95 });...
index.js
Source:index.js
...20 description: ""21 };22 const title = xpath23 .fromPageSource(html)24 .findElements("//title");25 response.title = title[0] ? title[0].getText() : "";26 const name = xpath27 .fromPageSource(html)28 .findElements("//meta[@name='name']");29 response.name = getContentAttribute(name);30 const description = xpath31 .fromPageSource(html)32 .findElements("//meta[@name='description']");33 response.description = getContentAttribute(description);34 return response;35}36const getOGTags = (html) => {37 const og = {38 title: "",39 image: "",40 description: "",41 url: "",42 site_name: ""43 };44 const title = xpath45 .fromPageSource(html)46 .findElements("//meta[@property='og:title']");47 og.title = getContentAttribute(title);48 let image = xpath49 .fromPageSource(html)50 .findElements("//meta[@property='og:image']");51 image = getContentAttribute(image);52 og.image = createAbsolutePathForImage(image);53 const description = xpath54 .fromPageSource(html)55 .findElements("//meta[@property='og:description']");56 og.description = getContentAttribute(description);57 const url = xpath58 .fromPageSource(html)59 .findElements("//meta[@property='og:url']");60 og.url = getContentAttribute(url);61 const site_name = xpath62 .fromPageSource(html)63 .findElements("//meta[@property='og:site_name']");64 og.site_name = getContentAttribute(site_name);65 return og;66}67const getTwitterTags = (html) => {68 const twitter = {69 title: "",70 image: "",71 description: "",72 url: ""73 };74 const title = xpath75 .fromPageSource(html)76 .findElements("//meta[@property='twitter:title']");77 twitter.title = getContentAttribute(title);78 let image = xpath79 .fromPageSource(html)80 .findElements("//meta[@property='twitter:image']");81 image = getContentAttribute(image);82 twitter.image = createAbsolutePathForImage(image);83 const description = xpath84 .fromPageSource(html)85 .findElements("//meta[@property='twitter:description']");86 twitter.description = getContentAttribute(description);87 const url = xpath88 .fromPageSource(html)89 .findElements("//meta[@property='twitter:url']");90 twitter.url = getContentAttribute(url);91 return twitter;92}93const getContentAttribute = (elements) => {94 let content = "";95 const element = elements[0];96 if (element && element.attributes) {97 for (var key in element.attributes) {98 if (element.attributes[key].name == 'content')99 content = element.attributes[key].value;100 }101 }102 return content;103}...
1261.find-elements-in-a-contaminated-binary-tree.js
Source:1261.find-elements-in-a-contaminated-binary-tree.js
1/*2 * @lc app=leetcode id=1261 lang=javascript3 *4 * [1261] Find Elements in a Contaminated Binary Tree5 *6 * https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/description/7 *8 * algorithms9 * Medium (74.39%)10 * Total Accepted: 21.1K11 * Total Submissions: 28.4K12 * Testcase Example: '["FindElements","find","find"]\r\n[[[-1,null,-1]],[1],[2]]\r'13 *14 * Given a binary tree with the following rules:15 * 16 * 17 * root.val == 018 * If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 219 * * x + 120 * If treeNode.val == x and treeNode.right != null, then treeNode.right.val ==21 * 2 * x + 222 * 23 * 24 * Now the binary tree is contaminated, which means all treeNode.val have been25 * changed to -1.26 * 27 * You need to first recover the binary tree and then implement the28 * FindElements class:29 * 30 * 31 * FindElements(TreeNode* root) Initializes the object with a contamined binary32 * tree, you need to recover it first.33 * bool find(int target) Return if the target value exists in the recovered34 * binary tree.35 * 36 * 37 * 38 * Example 1:39 * 40 * 41 * 42 * 43 * Input44 * ["FindElements","find","find"]45 * [[[-1,null,-1]],[1],[2]]46 * Output47 * [null,false,true]48 * Explanation49 * FindElements findElements = new FindElements([-1,null,-1]); 50 * findElements.find(1); // return False 51 * findElements.find(2); // return True 52 * 53 * Example 2:54 * 55 * 56 * 57 * 58 * Input59 * ["FindElements","find","find","find"]60 * [[[-1,-1,-1,-1,-1]],[1],[3],[5]]61 * Output62 * [null,true,true,false]63 * Explanation64 * FindElements findElements = new FindElements([-1,-1,-1,-1,-1]);65 * findElements.find(1); // return True66 * findElements.find(3); // return True67 * findElements.find(5); // return False68 * 69 * Example 3:70 * 71 * 72 * 73 * 74 * Input75 * ["FindElements","find","find","find","find"]76 * [[[-1,null,-1,-1,null,-1]],[2],[3],[4],[5]]77 * Output78 * [null,true,false,false,true]79 * Explanation80 * FindElements findElements = new FindElements([-1,null,-1,-1,null,-1]);81 * findElements.find(2); // return True82 * findElements.find(3); // return False83 * findElements.find(4); // return False84 * findElements.find(5); // return True85 * 86 * 87 * 88 * Constraints:89 * 90 * 91 * TreeNode.val == -192 * The height of the binary tree is less than or equal to 2093 * The total number of nodes is between [1, 10^4]94 * Total calls of find() is between [1, 10^4]95 * 0 <= target <= 10^696 * 97 * 98 */99/**100 * Definition for a binary tree node.101 * function TreeNode(val, left, right) {102 * this.val = (val===undefined ? 0 : val)103 * this.left = (left===undefined ? null : left)104 * this.right = (right===undefined ? null : right)105 * }106 */107/**108 * @param {TreeNode} root109 */110var FindElements = function(root) {111 112};113/** 114 * @param {number} target115 * @return {boolean}116 */117FindElements.prototype.find = function(target) {118 119};120/** 121 * Your FindElements object will be instantiated and called as such:122 * var obj = new FindElements(root)123 * var param_1 = obj.find(target)...
gallery-spec.js
Source:gallery-spec.js
...4 beforeAll(function() {5 browser.get('/ant-eater');6 browser.driver.sleep(100);7 elem = browser.driver.findElement(by.css('.login-form'))8 elem.findElements(by.tagName('input')).then(function(inputs){9 inputs[0].sendKeys("my_1_own_email@exemple.com");10 inputs[1].sendKeys("Truepass1");11 });12 browser.driver.findElement(by.css('.login-form > button')).click()13 browser.driver.sleep(1000);14 browser.driver.findElements(by.css('.main-menu > ul > a')).then(function(nav){15 nav[5].click()16 });17 browser.driver.sleep(500);18 });19 it('images count', function() {20 expect(browser.getCurrentUrl()).toBe(url);21 elem = $('.one-img')22 expect(elem).toEqual(9);23 });24 it('show full size image', function() {25 browser.driver.findElements(by.css('.large-image')).then(function(images){26 expect(images[0].isDisplayed()).toEqual(false);27 browser.driver.findElements(by.css('.icon > p > img')).then(function(imgs){28 imgs[3].click();29 elem = imgs[3];30 });31 expect(images[0].isDisplayed()).toEqual(true);32 images[0].findElements(by.tagName('img')).then(function(e) {33 expect(e[0].getAttribute('src')).toEqual(elem.getAttribute('src'));34 });35 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){36 buttons[0].click();37 });38 expect(images[0].isDisplayed()).toEqual(false);39 });40 });41 it('nav next', function() {42 browser.driver.findElements(by.css('.large-image')).then(function(images){43 expect(images[0].isDisplayed()).toEqual(false);44 browser.driver.findElements(by.css('.icon > p > img')).then(function(imgs){45 imgs[3].click();46 elem = imgs[4];47 });48 expect(images[0].isDisplayed()).toEqual(true);49 browser.driver.findElements(by.css('.img-nav > .next')).then(function(nav){50 nav[0].click();51 });52 images[0].findElements(by.tagName('img')).then(function(e) {53 expect(e[0].getAttribute('src')).toEqual(elem.getAttribute('src'));54 });55 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){56 buttons[0].click();57 });58 expect(images[0].isDisplayed()).toEqual(false);59 });60 });61 afterAll(function() {62 browser.get('/ant-eater');63 browser.driver.sleep(500);64 browser.actions().mouseMove($('.dropdown')).perform();65 browser.driver.findElements(by.css('.dropdown-menu > a')).then(function(nav){66 nav[1].click();67 });68 browser.driver.sleep(500);69 });...
Using AI Code Generation
1const { openBrowser, goto, write, click, closeBrowser, findElements } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko");6 await click("Google Search");7 let elements = await findElements({id: "resultStats"});8 console.log(elements);9 } catch (error) {10 console.error(error);11 } finally {12 await closeBrowser();13 }14})();15[ { id: 'resultStats',16 description: 'Element({id: "resultStats"})',17 runtimeHandler: RuntimeHandler {} } ]18let elements = await findElements({className: "r"});19let elements = await findElements({tagName: "a"});20findElement(selector, options)21const { openBrowser, goto, write, click, closeBrowser, findElement } = require('taiko');22(async () => {23 try {24 await openBrowser();25 await write("Taiko");26 await click("Google Search");27 let element = await findElement({id: "resultStats"});28 console.log(element);29 } catch (error) {30 console.error(error);31 } finally {
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, findElements } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 let elements = await findElements('input[name="q"]');6 console.log(elements.length);7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();
Using AI Code Generation
1const { openBrowser, goto, findElements, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 let elements = await findElements("a");6 console.log(elements.length);7 await closeBrowser();8 } catch (e) {9 console.error(e);10 } finally {11 }12})();13const { openBrowser, goto, findElements, closeBrowser } = require('taiko');14(async () => {15 try {16 await openBrowser();17 console.log(elements.length);18 await closeBrowser();19 } catch (e) {20 console.error(e);21 } finally {22 }23})();24const { openBrowser, goto, findElements, closeBrowser } = require('taiko');25(async () => {26 try {27 await openBrowser();28 let elements = await findElements("a");29 console.log(elements.length);30 await closeBrowser();31 } catch (e) {32 console.error(e);33 } finally {34 }35})();
Using AI Code Generation
1let elements = findElements("div");2elements[0].click();3let element = findElement("div");4element.click();5find("div").click();6click("div");7click("div", {scroll: true});8click("div", {scroll: false});9click("div", {scroll: true, clickCount: 2});10click("div", {scroll: false, clickCount: 2});11click("div", {scroll: true, waitForEvents: ["load", "DOMContentLoaded"]});12click("div", {scroll: false, waitForEvents: ["load", "DOMContentLoaded"]});13click("div", {scroll: true, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2});14click("div", {scroll: false, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2});15click("div", {scroll: true, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2, button: "right"});16click("div", {scroll: false, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2, button: "right"});17click("div", {scroll: true, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2, button: "middle"});18click("div", {scroll: false, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2, button: "middle"});19click("div", {scroll: true, waitForEvents: ["load", "DOMContentLoaded"], clickCount: 2, button: "left"});20click("div", {scroll: false
Using AI Code Generation
1const { findElements, openBrowser, goto, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser({headless:false});5 let elements = await findElements("a");6 console.log(elements.length);7 } catch (error) {8 console.error(error);9 } finally {10 await closeBrowser();11 }12})();
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, write, click, $, toRightOf, toLeftOf, below, above, link, button, image, listItem, dropDown, checkBox, radioButton, textField, textArea, fileField, webTable, password, clear, focus, evaluate, screenshot, scrollDown, scrollUp, scrollTo, near, into, accept, dismiss, toRightOf, toLeftOf, below, above, waitFor, press, highlight, hover, textBox, to, into, doubleClick, rightClick, dragAndDrop, reload, emulate, intercept, setConfig, openTab, closeTab, switchTo, attach, detach, currentURL, currentTab, browserName, browserVersion, cookies, deleteCookies, setCookie, title, enableRequestInterception, disableRequestInterception, emulateNetwork, emulateMedia, setViewPort, setViewPortSize, setViewPortWidth, setViewPortHeight, setViewPortDeviceScaleFactor, setViewPortMobile, setViewPortHasTouch, setViewPortIsLandscape } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko");6 await click("Google Search");7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, closeBrowser, write, click, $, toRightOf, toLeftOf, below, above, link, button, image, listItem, dropDown, checkBox, radioButton, textField, textArea, fileField, webTable, password, clear, focus, evaluate, screenshot, scrollDown, scrollUp, scrollTo, near, into, accept, dismiss, toRightOf, toLeftOf, below, above, waitFor, press, highlight, hover, textBox, to, into, doubleClick, rightClick, dragAndDrop, reload, emulate, intercept, setConfig, openTab, closeTab, switchTo, attach, detach, currentURL, currentTab, browserName, browserVersion, cookies, deleteCookies, setCookie, title, enableRequestInterception, disableRequestInterception, emulateNetwork, emulateMedia, setViewPort, setViewPortSize, setViewPortWidth,
Using AI Code Generation
1var { openBrowser, write, closeBrowser, goto, textBox, button, dropDown, click, toRightOf, toLeftOf, below, above, link, image, to, text, near, $, $$, evaluate, focus, into, clear, attach, toLeftOf, toRightOf, waitFor, highlight, scrollTo, scrollRight, scrollLeft, scrollUp, scrollDown, accept, dismiss, currentURL, checkBox, radioButton, password, fileField, browserConsole, browserLogs, reload, intercept, emulate, setConfig, setViewPort, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko", into(textBox({ id: "lst-ib" })));6 await click(button({ id: "sblsbb" }));7 await click(link("Taiko - A Node.js library to automate Google Chrome"), below("Taiko is a Node.js library to automate Google Chrome. It is designed to be a simple and easy to use tool for testing modern web applications. Taiko works on top of Chrome's DevTools Protocol and allows you to control the browser using simple JavaScript/TypeScript API."));8 await click("Get Started");9 await click($("a", toRightOf("Get Started")));10 await click($("a", toLeftOf("Get Started")));11 await click($("a", below("Get Started")));12 await click($("a", above("Get Started")));13 await click($("a", near("Get Started")));14 await click($("a", toLeftOf("Get Started")));15 await click($("a", toRightOf("Get Started")));16 await click($("a", below("Get Started")));17 await click($("a", above("Get Started")));18 await click($("a", near("Get Started")));19 await click($("a", toLeftOf("Get Started")));20 await click($("a", toRightOf("Get Started")));21 await click($("a", below("Get Started")));22 await click($("a", above("Get Started")));23 await click($("a", near("Get Started")));24 await click($("a", toLeftOf("Get Started")));25 await click($("a", toRightOf("Get Started")));26 await click($("a", below("Get
Using AI Code Generation
1const { openBrowser, goto, button, closeBrowser, write, click, textBox, dropDown, toLeftOf, toRightOf, image, link, listItem, $, $$, into, text, focus, evaluate, below, above, near, toLeftOf, toRightOf, toRight, toLeft, toBottom, toTop, scrollDown, scrollUp, scrollRight, scrollLeft, scrollTo, accept, dismiss, hover, clear, attach, screenshot, emulateDevice, highlight, intercept, setConfig, reload, waitFor, waitForNavigation, press, textArea, radioButton, checkBox, focusElement, link, currentURL, currentTab, within, dragAndDrop, accept, dismiss, to } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false, args: ['--start-fullscreen'] });5 await write("taiko", into(textBox(toRightOf('Google Search'))));6 await click("Google Search");7 await click("Taiko - A Node.js library for automating end-to-end ...");8 await click("Getting Started");9 await click("Install Taiko");10 await click("Install Node.js");11 await click("Install Node.js");12 await click("Next");13 await click("Next");14 await click("I accept the terms in the License Agreement");15 await click("Next");16 await click("Next");17 await click("Install");18 await click("Finish");19 await click("Next");20 await click("Next");21 await click("
Using AI Code Generation
1const { openBrowser, goto, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await screenshot({path:'google.png'});6 } catch (error) {7 console.error(error);8 } finally {9 await closeBrowser();10 }11})();12const { openBrowser, goto, screenshot, click, closeBrowser, $ } = require('taiko');13(async () => {14 try {15 await openBrowser();16 await screenshot({path:'gmail.png'});17 } catch (error) {18 console.error(error);19 } finally {20 await closeBrowser();21 }22})();23const { openBrowser, goto, screenshot, click, closeBrowser, $ } = require('taiko');24(async () => {25 try {26 await openBrowser();27 await screenshot({path:'gmail.png'});28 } catch (error) {29 console.error(error);30 } finally {31 await closeBrowser();32 }33})();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!