How to use d.findElements method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

sanity.spec.js

Source:sanity.spec.js Github

copy

Full Screen

1const { Builder, By, Key, assert, until } = require('selenium-webdriver');2const path = require('path');3describe('sanity', function () {4 let driver;5 beforeEach(function () {6 driver = new Builder()7 .forBrowser('chrome')8 .build();9 });10 afterEach(function () {11 driver.quit();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);...

Full Screen

Full Screen

lpAppPage.js

Source:lpAppPage.js Github

copy

Full Screen

1import BasePageObject from '../../../base/basePageObject';2const { By } = require('selenium-webDriver');3export default class LPAppPage extends BasePageObject {4 constructor(webDriver) {5 super(webDriver);6 // Xpath7 this.loadTarget = By.xpath('//h1[contains(text(), "Get approved now")]');8 // INPUT ELEMENTS9 this.input = {10 systemCost: By.xpath('//label[contains(text(),"Estimated System Cost")]/following-sibling::input'),11 referenceNumber: By.xpath('//label[contains(text(), "Reference")]//following-sibling::input'),12 // Primary Borrower13 firstName: By.xpath('//input[@id="firstName"]'),14 lastName: By.xpath('//input[@id="lastName"]'),15 addressStreet: By.xpath('//input[@id="addressStreet"]'),16 addressCity: By.xpath('//input[@id="addressCity"]'),17 addressZip: By.xpath('//input[@id="addressZip"]'),18 mobilePhone: {19 prefix1: By.xpath('//input[@id="mobilePhonePrefix1"]'),20 prefix2: By.xpath('//input[@id="mobilePhonePrefix2"]'),21 prefix3: By.xpath('//input[@id="mobilePhonePrefix3"]')22 },23 homePhone: {24 prefix1: By.xpath('//input[@id="phonePrefix1"]'),25 prefix2: By.xpath('//input[@id="phonePrefix2"]'),26 prefix3: By.xpath('//input[@id="phonePrefix3"]')27 },28 ssn: {29 prefix1: By.xpath('//input[@id="ssnPrefix1"]'),30 prefix2: By.xpath('//input[@id="ssnPrefix2"]'),31 prefix3: By.xpath('//input[@id="ssnPrefix3"]')32 },33 email: By.xpath('//input[@id="email"]'),34 annualIncome: By.xpath('//input[@id="annualIncome"]'),35 citizenship: {36 us: By.xpath('(//input[@value="US Citizen"])[1]'),37 alien: By.xpath('(//input[@value="Lawful Permanent Resident Alien"])[1]'),38 other: By.xpath('(//input[@value="Other"])[1]')39 },40 // Secondary Borrower41 coFirstName: By.xpath('//input[@id="firstName2"]'),42 coLastName: By.xpath('//input[@id="lastName2"]'),43 coAddressStreet: By.xpath('//input[@id="addressStreet2"]'),44 coAddressCity: By.xpath('//input[@id="addressCity2"]'),45 coAddressZip: By.xpath('//input[@id="addressZip2"]'),46 coMobilePhone: {47 prefix1: By.xpath('//input[@id="mobilePhonePrefix12"]'),48 prefix2: By.xpath('//input[@id="mobilePhonePrefix22"]'),49 prefix3: By.xpath('//input[@id="mobilePhonePrefix32"]')50 },51 coHomePhone: {52 prefix1: By.xpath('//input[@id="phonePrefix12"]'),53 prefix2: By.xpath('//input[@id="phonePrefix22"]'),54 prefix3: By.xpath('//input[@id="phonePrefix32"]')55 },56 coSSN: {57 prefix1: By.xpath('//input[@id="ssnPrefix12"]'),58 prefix2: By.xpath('//input[@id="ssnPrefix22"]'),59 prefix3: By.xpath('//input[@id="ssnPrefix32"]')60 },61 coEmail: By.xpath('//input[@id="email2"]'),62 coAnnualIncome: By.xpath('//input[@id="annualIncome2"]'),63 coCitizenship: {64 us: By.xpath('(//input[@value="US Citizen"])[2]'),65 alien: By.xpath('(//input[@value="Lawful Permanent Resident Alien"])[2]'),66 other: By.xpath('(//input[@value="Other"])[2]')67 },68 // Sales Rep69 srFirstName: By.xpath('//label[contains(text(),"Sales Rep First Name")]/following-sibling::input'),70 srLastName: By.xpath('//label[contains(text(),"Sales Rep Last Name")]/following-sibling::input'),71 srEmail: By.xpath('//label[contains(text(),"Sales Rep Email")]/following-sibling::input'),72 srMobilePhone: {73 prefix1: By.xpath('//input[@id="mobilePhonePrefix13"]'),74 prefix2: By.xpath('//input[@id="mobilePhonePrefix23"]'),75 prefix3: By.xpath('//input[@id="mobilePhonePrefix33"]')76 },77 srCompanyName: By.xpath('//label[contains(text(),"Company")]/following-sibling::input')78 };79 // SELECT ELEMENTS80 this.select = {81 language: value => By.xpath(`//label[contains(text(), "Preferred Language / Idioma Preferido")]/following-sibling::select//option[@value="${value}"]`),82 loanTerm: value => By.xpath(`//select[option[contains(text(), "Select Loan Term")]]//option[@value="${value}"]`),83 loanTermDefault: By.xpath('//select/option[contains(text(),"Select Loan Term")]/following-sibling::option'),84 // Primary Borrower85 addressState: value => By.xpath(`//select[@id="addressState"]//option[@value="${value}"]`),86 addressStateDefault: By.xpath('//select[@id="addressState"]/option[2]'),87 dateOfBirth: {88 month: value => By.xpath(`//select[@id="birthdayMonth"]/option[@value="${value}"]`),89 day: value => By.xpath(`//select[@id="birthdayDay"]/option[@value="${value}"]`),90 year: value => By.xpath(`//select[@id="birthdayYear"]/option[@value="${value}"]`)91 },92 employmentStatus: value => By.xpath(`//select[@name="employmentStatus"]//option[@value="${value}"]`),93 // Secondary Borrower94 coAddressState: value => By.xpath(`//select[@id="addressState2"]//option[@value="${value}"]`),95 coAddressStateDefault: By.xpath('//select[@id="addressState2"]/option[2]'),96 coDateOfBirth: {97 month: value => By.xpath(`//select[@id="birthdayMonth2"]/option[@value="${value}"]`),98 day: value => By.xpath(`//select[@id="birthdayDay2"]/option[@value="${value}"]`),99 year: value => By.xpath(`//select[@id="birthdayYear2"]/option[@value="${value}"]`)100 },101 coEmploymentStatus: value => By.xpath(`//select[@name="coborrowerEmploymentStatus"]//option[@value="${value}"]`)102 };103 // BUTTON ELEMENTS104 this.button = {105 addCoBorrower: By.xpath('//a[contains(text(), "Add Co-borrower")]'),106 removeCoBorrower: By.xpath('//a[contains(text(), "Remove Co-borrower")]'),107 clearSignature: By.xpath('//button[contains(text(), "Clear")]'),108 approveSignature: By.xpath('//button[contains(text(), "Approve")]'),109 submitApplication: By.xpath('//button[contains(text(), "Submit")]'),110 origAddress: By.xpath('//button[@value="Original Address"]'),111 applyNow: By.xpath('//button[contains(text(),"Apply Now")]')112 };113 // CHECKBOX ELEMENTS114 this.checkbox = {115 sameAddress: By.xpath('//label[contains(text(), "Same address")]/../preceding-sibling::input[@type="checkbox"]'),116 verifyOwner: By.xpath('//label[contains(text(), "owner")]/../preceding-sibling::input[@type="checkbox"]'),117 verifyOccupy: By.xpath('//label[contains(text(), "occupy")]/../preceding-sibling::input[@type="checkbox"]'),118 verifyESign: By.xpath('//label[contains(text(), "E-Sign")]/../preceding-sibling::input[@type="checkbox"]'),119 verifyCredit: By.xpath('//label[contains(text(), "credit")]/../preceding-sibling::input[@type="checkbox"]')120 };121 // SIGNATURE ELEMENT122 this.signature = By.xpath('//canvas');123 // Approval Page124 this.header = {125 keyLoanTerms: By.xpath('//*[text()="Key Loan Terms"]'),126 loanID: By.xpath('//*[text()="Loan ID"]/following-sibling::*'),127 referenceNumber: By.xpath('//*[text()="Reference Number"]/following-sibling::*'),128 loanAmount: By.xpath('//*[contains(text(),"Loan Amount")]/preceding-sibling::*'),129 loanTerm: By.xpath('//span[text()="Loan Term"]/preceding-sibling::*'),130 loanRate: By.xpath('//*[text()="Loan Rate"]/preceding-sibling::*')131 };132 this.link = {133 srEmail: By.xpath('//*[contains(text(),"Sales Rep Email")]/following-sibling::a')134 };135 }136 async goToPage(url) {137 await this.fullScreen();138 await this.openUrl(url);139 await this.waitForTarget(this.loadTarget);140 }141 async coborrowerData(record) {142 console.log('Adding CoBorrower');143 const [addCoBorrower] = await this.findElements(this.button.addCoBorrower);144 if (addCoBorrower) await addCoBorrower.click();145 await this.sleep(1000);146 // Cobo data147 const [coFirstname] = await this.findElements(this.input.coFirstName);148 if (coFirstname) await this.enterText(coFirstname, record.firstName);149 const [coLastName] = await this.findElements(this.input.coLastName);150 if (coLastName) await this.enterText(coLastName, record.lastName);151 // Address152 if (record.coAddressStreet) {153 const [secondaryStreet] = await this.findElements(this.input.coAddressStreet);154 if (secondaryStreet) await this.enterText(secondaryStreet, record.coAddressStreet);155 const [secondaryCity] = await this.findElements(this.input.coAddressCity);156 if (secondaryCity) await this.enterText(secondaryCity, record.coAddressCity);157 const [secondaryState] = await this.findElements(this.select.coAddressState(record.coAddressState || Object.keys(record.loanOptionsMap)[0]));158 if (secondaryState) await secondaryState.click();159 else await this.findElement(this.select.coAddressStateDefault).then(e => e.click());160 const [secondaryZip] = await this.findElements(this.input.coAddressZip);161 if (secondaryZip) await this.enterText(secondaryZip, record.coAddressZip);162 } else {163 const [sameAddress] = await this.findElements(this.checkbox.sameAddress);164 if (sameAddress) await sameAddress.click();165 }166 // Secondary Mobile Phone167 const [secondaryMobilePrefix1] = await this.findElements(this.input.coMobilePhone.prefix1);168 if (secondaryMobilePrefix1) await this.enterText(secondaryMobilePrefix1, record.coMobilePhone.substr(0, 3));169 const [secondaryMobilePrefix2] = await this.findElements(this.input.coMobilePhone.prefix2);170 if (secondaryMobilePrefix2) await this.enterText(secondaryMobilePrefix2, record.coMobilePhone.substr(3, 3));171 const [secondaryMobilePrefix3] = await this.findElements(this.input.coMobilePhone.prefix3);172 if (secondaryMobilePrefix3) await this.enterText(secondaryMobilePrefix3, record.coMobilePhone.substr(6, 4));173 // secondary Home Phone174 const [secondaryHomePrefix1] = await this.findElements(this.input.coHomePhone.prefix1);175 if (secondaryHomePrefix1) await this.enterText(secondaryHomePrefix1, record.coHomePhone.substr(0, 3));176 const [secondaryHomePrefix2] = await this.findElements(this.input.coHomePhone.prefix2);177 if (secondaryHomePrefix2) await this.enterText(secondaryHomePrefix2, record.coHomePhone.substr(3, 3));178 const [secondaryHomePrefix3] = await this.findElements(this.input.coHomePhone.prefix3);179 if (secondaryHomePrefix3) await this.enterText(secondaryHomePrefix3, record.coHomePhone.substr(6, 4));180 // secondary DOB181 const [secondaryBirthMonth] = await this.findElements(this.select.coDateOfBirth.month(record.coDateOfBirth.split('-')[1]));182 if (secondaryBirthMonth) await secondaryBirthMonth.click();183 const [secondaryBirthDay] = await this.findElements(this.select.coDateOfBirth.day(record.coDateOfBirth.split('-')[2]));184 if (secondaryBirthDay) await secondaryBirthDay.click();185 const [secondaryBirthYear] = await this.findElements(this.select.coDateOfBirth.year(record.coDateOfBirth.split('-')[0]));186 if (secondaryBirthYear) await secondaryBirthYear.click();187 // secondary SSN188 const [secondarySSN1] = await this.findElements(this.input.coSSN.prefix1);189 if (secondarySSN1) await this.enterText(secondarySSN1, record.coSSN.substr(0, 3));190 const [secondarySSN2] = await this.findElements(this.input.coSSN.prefix2);191 if (secondarySSN2) await this.enterText(secondarySSN2, record.coSSN.substr(3, 2));192 const [secondarySSN3] = await this.findElements(this.input.coSSN.prefix3);193 if (secondarySSN3) await this.enterText(secondarySSN3, record.coSSN.substr(5, 4));194 // secondary Email195 const [secondaryEmail] = await this.findElements(this.input.coEmail);196 if (secondaryEmail) await this.enterText(secondaryEmail, record.coEmail);197 // secondary Income198 const [secondaryIncome] = await this.findElements(this.input.coAnnualIncome);199 if (secondaryIncome) await this.enterText(secondaryIncome, record.coAnnualIncome);200 // secondary Employment201 const [secondaryEmployment] = await this.findElements(this.select.coEmploymentStatus(record.coEmploymentStatus || 'Employed'));202 if (secondaryEmployment) await secondaryEmployment.click();203 // secondary Citizenship204 const [secondaryCitizenship] = await this.findElements(this.input.coCitizenship[record.coCitizenship || 'us']);205 if (secondaryCitizenship) await secondaryCitizenship.click();206 }207 async fillOutForm(record) {208 // Primary applicant personal data209 const [primaryFirstname] = await this.findElements(this.input.firstName);210 if (primaryFirstname) await this.enterText(primaryFirstname, record.firstName);211 const [primaryLastName] = await this.findElements(this.input.lastName);212 if (primaryLastName) await this.enterText(primaryLastName, record.lastName);213 const [primaryStreet] = await this.findElements(this.input.addressStreet);214 if (primaryStreet) await this.enterText(primaryStreet, record.addressStreet);215 const [primaryCity] = await this.findElements(this.input.addressCity);216 if (primaryCity) await this.enterText(primaryCity, record.addressCity);217 const [primaryState] = await this.findElements(this.select.addressState(record.addressState || Object.keys(record.loanOptionsMap)[0]));218 if (primaryState) await primaryState.click();219 else await this.findElement(this.select.addressStateDefault).then(e => e.click());220 const [primaryZip] = await this.findElements(this.input.addressZip);221 if (primaryZip) await this.enterText(primaryZip, record.addressZip);222 // Primary Mobile Phone223 const [primaryMobilePrefix1] = await this.findElements(this.input.mobilePhone.prefix1);224 if (primaryMobilePrefix1) await this.enterText(primaryMobilePrefix1, record.mobilePhone.substr(0, 3));225 const [primaryMobilePrefix2] = await this.findElements(this.input.mobilePhone.prefix2);226 if (primaryMobilePrefix2) await this.enterText(primaryMobilePrefix2, record.mobilePhone.substr(3, 3));227 const [primaryMobilePrefix3] = await this.findElements(this.input.mobilePhone.prefix3);228 if (primaryMobilePrefix3) await this.enterText(primaryMobilePrefix3, record.mobilePhone.substr(6, 4));229 // Primary Home Phone230 const [primaryHomePrefix1] = await this.findElements(this.input.homePhone.prefix1);231 if (primaryHomePrefix1) await this.enterText(primaryHomePrefix1, record.homePhone.substr(0, 3));232 const [primaryHomePrefix2] = await this.findElements(this.input.homePhone.prefix2);233 if (primaryHomePrefix2) await this.enterText(primaryHomePrefix2, record.homePhone.substr(3, 3));234 const [primaryHomePrefix3] = await this.findElements(this.input.homePhone.prefix3);235 if (primaryHomePrefix3) await this.enterText(primaryHomePrefix3, record.homePhone.substr(6, 4));236 // Primary DOB237 const [primaryBirthMonth] = await this.findElements(this.select.dateOfBirth.month(record.dateOfBirth.split('-')[1]));238 if (primaryBirthMonth) await primaryBirthMonth.click();239 const [primaryBirthDay] = await this.findElements(this.select.dateOfBirth.day(record.dateOfBirth.split('-')[2]));240 if (primaryBirthDay) await primaryBirthDay.click();241 const [primaryBirthYear] = await this.findElements(this.select.dateOfBirth.year(record.dateOfBirth.split('-')[0]));242 if (primaryBirthYear) await primaryBirthYear.click();243 // Primary SSN244 const [primarySSN1] = await this.findElements(this.input.ssn.prefix1);245 if (primarySSN1) await this.enterText(primarySSN1, record.ssn.substr(0, 3));246 const [primarySSN2] = await this.findElements(this.input.ssn.prefix2);247 if (primarySSN2) await this.enterText(primarySSN2, record.ssn.substr(3, 2));248 const [primarySSN3] = await this.findElements(this.input.ssn.prefix3);249 if (primarySSN3) await this.enterText(primarySSN3, record.ssn.substr(5, 4));250 // Primary Email251 const [primaryEmail] = await this.findElements(this.input.email);252 if (primaryEmail) await this.enterText(primaryEmail, record.email);253 // Primary Income254 const [primaryIncome] = await this.findElements(this.input.annualIncome);255 if (primaryIncome) await this.enterText(primaryIncome, record.annualIncome);256 // Primary Employment257 const [primaryEmployment] = await this.findElements(this.select.employmentStatus(record.employmentStatus || 'Employed'));258 if (primaryEmployment) await primaryEmployment.click();259 // Primary Citizenship260 const [primaryCitizenship] = await this.findElements(this.input.citizenship[record.citizenship || 'us']);261 if (primaryCitizenship) await primaryCitizenship.click();262 // ADD A COBORROWER263 if (record.coFirstName) await this.coborrowerData(record);264 // Language265 const [preferredLanguage] = await this.findElements(this.select.language(record.language || 'english'));266 if (preferredLanguage) await preferredLanguage.click();267 // Sales rep data268 const [repFirstName] = await this.findElements(this.input.srFirstName);269 if (repFirstName) await this.enterText(repFirstName, record.srFirstName);270 const [repLastName] = await this.findElements(this.input.srLastName);271 if (repLastName) await this.enterText(repLastName, record.srLastName);272 const [repEmail] = await this.findElements(this.input.srEmail);273 if (repEmail) await this.enterText(repEmail, record.srEmail);274 // Sale Rep Mobile Phone275 const [repMobilePrefix1] = await this.findElements(this.input.srMobilePhone.prefix1);276 if (repMobilePrefix1) await this.enterText(repMobilePrefix1, record.srMobilePhone.substr(0, 3));277 const [repMobilePrefix2] = await this.findElements(this.input.srMobilePhone.prefix2);278 if (repMobilePrefix2) await this.enterText(repMobilePrefix2, record.srMobilePhone.substr(3, 3));279 const [repMobilePrefix3] = await this.findElements(this.input.srMobilePhone.prefix3);280 if (repMobilePrefix3) await this.enterText(repMobilePrefix3, record.srMobilePhone.substr(6, 4));281 // Sales Rep Company282 const [repCompany] = await this.findElements(this.input.srCompanyName);283 if (repCompany) await this.enterText(repCompany, record.srCompanyName);284 // Loan Term285 const [loanTerm] = await this.findElements(this.select.loanTerm(record.loanTerm || record.loanOptionsMap[Object.keys(record.loanOptionsMap)[0]][0]));286 if (loanTerm) await loanTerm.click();287 else await this.findElement(this.select.loanTermDefault).then(e => e.click());288 // Reference Number289 const [refNum] = await this.findElements(this.input.referenceNumber);290 if (refNum) await this.enterText(refNum, record.referenceNumber);291 // System Cost292 const [systemCost] = await this.findElements(this.input.systemCost);293 if (systemCost) await this.enterText(systemCost, record.systemCost);294 // Checkboxes295 const [verifyOwner] = await this.findElements(this.checkbox.verifyOwner);296 if (verifyOwner) await verifyOwner.click();297 const [verifyOccupy] = await this.findElements(this.checkbox.verifyOccupy);298 if (verifyOccupy) await verifyOccupy.click();299 const [verifyESign] = await this.findElements(this.checkbox.verifyESign);300 if (verifyESign) await verifyESign.click();301 const [verifyCredit] = await this.findElements(this.checkbox.verifyCredit);302 if (verifyCredit) await verifyCredit.click();303 // Signature304 const [sign] = await this.findElements(this.signature);305 if (sign) await sign.click();306 // Buttons307 const [approveBtn] = await this.findElements(this.button.approveSignature);308 if (approveBtn) await approveBtn.click();309 const [submitBtn] = await this.findElements(this.button.submitApplication);310 if (submitBtn) await submitBtn.click();311 }312 async reviewInfo() {313 await this.waitForTarget(this.button.applyNow);314 const [origAddress, origAddress2] = await this.findElements(this.button.origAddress);315 if (origAddress) await origAddress.click();316 if (origAddress2) await origAddress2.click();317 }318 async apply() {319 const [applyNowBtn] = await this.findElements(this.button.applyNow);320 if (applyNowBtn) await applyNowBtn.click();321 await this.waitForTarget(this.header.loanID, 0, 20);322 }323 async getLoanID() {324 const [loanId] = await this.findElements(this.header.loanID);325 const loanText = await loanId.getAttribute('textContent');326 console.log('Loan ID:', loanText);327 return loanText;328 }...

Full Screen

Full Screen

stepdefs.js

Source:stepdefs.js Github

copy

Full Screen

1const assert = require('assert');2const { Given, When, Then } = require('@cucumber/cucumber');3const { By, Key, Builder } = require("selenium-webdriver");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);...

Full Screen

Full Screen

No1261.find-elements-in-a-contaminated-binary-tree.js

Source:No1261.find-elements-in-a-contaminated-binary-tree.js Github

copy

Full Screen

1/**2 * Difficulty:3 * Medium4 *5 * Desc:6 * Given a binary tree with the following rules:7 * 1. root.val == 08 * 2. If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 2 * x + 19 * 3. If treeNode.val == x and treeNode.right != null, then treeNode.right.val == 2 * x + 210 *11 * Now the binary tree is contaminated, which means all treeNode.val have been changed to -1.12 * You need to first recover the binary tree and then implement the FindElements class:13 * 1. FindElements(TreeNode* root) Initializes the object with a contamined binary tree, you need to recover it first.14 * 2. bool find(int target) Return if the target value exists in the recovered binary tree.15 *16 * Example 1:17 * Input18 * ["FindElements","find","find"]19 * [[[-1,null,-1]],[1],[2]]20 * Output21 * [null,false,true]22 * Explanation23 * FindElements findElements = new FindElements([-1,null,-1]);24 * findElements.find(1); // return False25 * findElements.find(2); // return True26 *27 * Example 2:28 * Input29 * ["FindElements","find","find","find"]30 * [[[-1,-1,-1,-1,-1]],[1],[3],[5]]31 * Output32 * [null,true,true,false]33 * Explanation34 * FindElements findElements = new FindElements([-1,-1,-1,-1,-1]);35 * findElements.find(1); // return True36 * findElements.find(3); // return True37 * findElements.find(5); // return False38 *39 * Example 3:40 * Input41 * ["FindElements","find","find","find","find"]42 * [[[-1,null,-1,-1,null,-1]],[2],[3],[4],[5]]43 * Output44 * [null,true,false,false,true]45 * Explanation46 * FindElements findElements = new FindElements([-1,null,-1,-1,null,-1]);47 * findElements.find(2); // return True48 * findElements.find(3); // return False49 * findElements.find(4); // return False50 * findElements.find(5); // return True51 *52 * Constraints:53 * 1. TreeNode.val == -154 * 2. The height of the binary tree is less than or equal to 2055 * 3. The total number of nodes is between [1, 10^4]56 * 4. Total calls of find() is between [1, 10^4]57 * 5. 0 <= target <= 10^658 *59 * 给出一个满足下述规则的二叉树:60 * 1. root.val == 061 * 2. 如果 treeNode.val == x 且 treeNode.left != null,那么 treeNode.left.val == 2 * x + 162 * 3. 如果 treeNode.val == x 且 treeNode.right != null,那么 treeNode.right.val == 2 * x + 263 *64 * 现在这个二叉树受到「污染」,所有的 treeNode.val 都变成了 -1。65 * 请你先还原二叉树,然后实现 FindElements 类:66 * 1. FindElements(TreeNode* root) 用受污染的二叉树初始化对象,你需要先把它还原。67 * 2. bool find(int target) 判断目标值 target 是否存在于还原后的二叉树中并返回结果。68 */69/**70 * Definition for a binary tree node.71 * function TreeNode(val) {72 * this.val = val;73 * this.left = this.right = null;74 * }75 */76/**77 * @param {TreeNode} root78 */79var FindElements = function(root) {80 this.root = root81 this.cache = new Set()82 root.val = 083 const queue = [this.root]84 while (queue.length) {85 const node = queue.pop()86 this.cache.add(node.val)87 if (node.left) {88 node.left.val = 2 * node.val + 189 queue.push(node.left)90 }91 if (node.right) {92 node.right.val = 2 * node.val + 293 queue.push(node.right)94 }95 }96};97/**98* @param {number} target99* @return {boolean}100*/101FindElements.prototype.find = function(target) {102 return this.cache.has(target)103};104/**105* Your FindElements object will be instantiated and called as such:106* var obj = new FindElements(root)107* var param_1 = obj.find(target)...

Full Screen

Full Screen

profile-spec.js

Source:profile-spec.js Github

copy

Full Screen

1describe('profile page', function() {2 var elem;3 var url = "http://localhost:8080/ant-eater/profile";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 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1const requestPromise = require('request-promise');2const xpath = require("xpath-html");3const generatePreview = async (url) => {4 return requestPromise(url)5 .then(function (html) {6 let response = {};7 response = getHTMLTags(html);8 response.og = getOGTags(html,url);9 response.twitter = getTwitterTags(html,url);10 return response;11 })12 .catch(function (err) { 13 throw err;14 });15}16const getHTMLTags = (html) => {17 let response = {18 title: "",19 name: "",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}104const createAbsolutePathForImage = (imagelink,url) => {105 let imageUrl = imagelink;106 if((imagelink.indexOf('https')) != -1 || (imagelink.indexOf('http')) != -1){107 const baseUrl = getBaseUrl(url);108 imageUrl = baseUrl + imagelink;109 }110 return imageUrl;111}112const getBaseUrl = (url) => { 113 let urls = url.split('/');114 urls = urls.slice(0,3);115 const baseUrl = urls.join('/');116 return baseUrl;117}...

Full Screen

Full Screen

1261.find-elements-in-a-contaminated-binary-tree.js

Source:1261.find-elements-in-a-contaminated-binary-tree.js Github

copy

Full Screen

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.80%)10 * Likes: 49011 * Dislikes: 7512 * Total Accepted: 38.6K13 * Total Submissions: 51.1K14 * Testcase Example: '["FindElements","find","find"]\n[[[-1,null,-1]],[1],[2]]'15 *16 * Given a binary tree with the following rules:17 * 18 * 19 * root.val == 020 * If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 221 * * x + 122 * If treeNode.val == x and treeNode.right != null, then treeNode.right.val ==23 * 2 * x + 224 * 25 * 26 * Now the binary tree is contaminated, which means all treeNode.val have been27 * changed to -1.28 * 29 * Implement the FindElements class:30 * 31 * 32 * FindElements(TreeNode* root) Initializes the object with a contaminated33 * binary tree and recovers it.34 * bool find(int target) Returns true if the target value exists in the35 * recovered binary tree.36 * 37 * 38 * 39 * Example 1:40 * 41 * 42 * Input43 * ["FindElements","find","find"]44 * [[[-1,null,-1]],[1],[2]]45 * Output46 * [null,false,true]47 * Explanation48 * FindElements findElements = new FindElements([-1,null,-1]); 49 * findElements.find(1); // return False 50 * findElements.find(2); // return True 51 * 52 * Example 2:53 * 54 * 55 * Input56 * ["FindElements","find","find","find"]57 * [[[-1,-1,-1,-1,-1]],[1],[3],[5]]58 * Output59 * [null,true,true,false]60 * Explanation61 * FindElements findElements = new FindElements([-1,-1,-1,-1,-1]);62 * findElements.find(1); // return True63 * findElements.find(3); // return True64 * findElements.find(5); // return False65 * 66 * Example 3:67 * 68 * 69 * Input70 * ["FindElements","find","find","find","find"]71 * [[[-1,null,-1,-1,null,-1]],[2],[3],[4],[5]]72 * Output73 * [null,true,false,false,true]74 * Explanation75 * FindElements findElements = new FindElements([-1,null,-1,-1,null,-1]);76 * findElements.find(2); // return True77 * findElements.find(3); // return False78 * findElements.find(4); // return False79 * findElements.find(5); // return True80 * 81 * 82 * 83 * Constraints:84 * 85 * 86 * TreeNode.val == -187 * The height of the binary tree is less than or equal to 2088 * The total number of nodes is between [1, 10^4]89 * Total calls of find() is between [1, 10^4]90 * 0 <= target <= 10^691 * 92 * 93 */94// @lc code=start95/**96 * Definition for a binary tree node.97 * function TreeNode(val, left, right) {98 * this.val = (val===undefined ? 0 : val)99 * this.left = (left===undefined ? null : left)100 * this.right = (right===undefined ? null : right)101 * }102 */103/**104 * @param {TreeNode} root105 */106var FindElements = function(root) {107 108};109/** 110 * @param {number} target111 * @return {boolean}112 */113FindElements.prototype.find = function(target) {114 115};116/** 117 * Your FindElements object will be instantiated and called as such:118 * var obj = new FindElements(root)119 * var param_1 = obj.find(target)120 */...

Full Screen

Full Screen

gallery-spec.js

Source:gallery-spec.js Github

copy

Full Screen

1describe('gallery page', function() {2 var elem;3 var url = "http://localhost:8080/ant-eater/users/2/images";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 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');3driver.findElement(webdriver.By.name('btnG')).click();4driver.wait(function() {5return driver.getTitle().then(function(title) {6return title === 'webdriver - Google Search';7});8}, 1000);9driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = new webdriver.Builder()2 .forBrowser('chrome')3 .build();4driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');5driver.findElement(webdriver.By.name('btnG')).click();6driver.wait(function() {7 return driver.getTitle().then(function(title) {8 return title === 'webdriver - Google Search';9 });10}, 1000);11driver.quit();12var driver = new webdriver.Builder()13 .forBrowser('chrome')14 .build();15driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');16driver.findElement(webdriver.By.name('btnG')).click();17driver.wait(function() {18 return driver.getTitle().then(function(title) {19 return title === 'webdriver - Google Search';20 });21}, 1000);22driver.quit();23{ [Error: Method has not yet been implemented]24 { status: 13,25 orgStatusMessage: 'Method has not yet been implemented' } }26var webdriver = require('selenium-webdriver');27var driver = new webdriver.Builder()28 .forBrowser('chrome')29 .build();30driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');31driver.findElement(webdriver.By.name('btnG')).click();32driver.wait(function() {33 return driver.getTitle().then(function(title) {34 return title === 'webdriver - Google Search';35 });36}, 1000);37driver.quit();38{ [Error: Method has not yet been implemented]39 { status: 13,40 orgStatusMessage: 'Method has not yet been implemented' } }

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.iphone()).build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6return driver.getTitle().then(function(title) {7return title === 'webdriver - Google Search';8});9}, 1000);10driver.quit();11info: Welcome to Appium v1.3.4 (REV 8b3c8d7e90b0d4e7d2f2b1c5f5e3a5c5b5d5f5c5)

Full Screen

Using AI Code Generation

copy

Full Screen

1 build();2driver.findElements({css: 'input'}).then(function(elements) {3 console.log('Found', elements.length, 'elements.');4 driver.quit();5});6 build();7driver.findElements(webdriver.By.css('input')).then(function(elements) {8 console.log('Found', elements.length, 'elements.');9 driver.quit();10});11 build();12driver.findElements(webdriver.By.css('input')).then(function(elements) {13 console.log('Found', elements.length, 'elements.');14 driver.quit();15});16 build();17driver.findElements(webdriver.By.css('input')).then(function(elements) {18 console.log('Found', elements.length, 'elements.');19 driver.quit();20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var path = require('path');3 withCapabilities({4 build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8 return driver.getTitle().then(function(title) {9 return title === 'webdriver - Google Search';10 });11}, 1000);12driver.findElements(webdriver.By.css('div.g')).then(function(elements) {13 console.log('Found', elements.length, 'elements.');14});15driver.quit();16var webdriver = require('selenium-webdriver');17var path = require('path');18 withCapabilities({19 build();20driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');21driver.findElement(webdriver.By.name('btnG')).click();22driver.wait(function() {23 return driver.getTitle().then(function(title) {24 return title === 'webdriver - Google Search';25 });26}, 1000);27driver.findElements(webdriver.By.css('div.g')).then(function(elements) {28 console.log('Found', elements.length, 'elements.');29});30driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('chrome')4 .build();5driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');6driver.findElement(webdriver.By.name('btnG')).click();7driver.wait(function() {8 return driver.getTitle().then(function(title) {9 return title === 'webdriver - Google Search';10 });11}, 1000);12driver.quit();13var webdriver = require('selenium-webdriver');14var driver = new webdriver.Builder()15 .forBrowser('chrome')16 .build();17driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');18driver.findElement(webdriver.By.name('btnG')).click();19driver.wait(function() {20 return driver.getTitle().then(function(title) {21 return title === 'webdriver - Google Search';22 });23}, 1000);24driver.quit();25var webdriver = require('selenium-webdriver');26var driver = new webdriver.Builder()27 .forBrowser('chrome')28 .build();29driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');30driver.findElement(webdriver.By.name('btnG')).click();31driver.wait(function() {32 return driver.getTitle().then(function(title) {33 return title === 'webdriver - Google Search';34 });35}, 1000);36driver.quit();37var webdriver = require('selenium

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var driver = new webdriver.Builder().forBrowser('chrome').build();13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16 return driver.getTitle().then(function(title) {17 return title === 'webdriver - Google Search';18 });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder().forBrowser('chrome').build();23driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');24driver.findElement(webdriver.By.name('btnG')).click();25driver.wait(function() {26 return driver.getTitle().then(function(title) {27 return title === 'webdriver - Google Search';28 });29}, 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32var driver = new webdriver.Builder().forBrowser('chrome').build();33driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');34driver.findElement(webdriver.By.name('btnG')).click();35driver.wait(function() {36 return driver.getTitle().then(function(title) {37 return title === 'webdriver - Google Search';38 });39}, 1000);40driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(result);2console.log(result);3console.log(result);4console.log(result);5console.log(result);6console.log(result);7console.log(result);8console.log(result);9console.log(result);10console.log(result);11console.log(result);12console.log(result);13console.log(result);14console.log(result);15console.log(result);16console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1function findElements(locator) {2 var self = this;3 return self.execute('findElements', {using: locator.using, value: locator.value})4 .then(function (res) {5 if (!Array.isArray(res)) {6 throw new Error("findElements did not return an array. Instead it returned " + JSON.stringify(res));7 }8 return res.map(function (el) {9 return new Element(self, el.ELEMENT);10 });11 });12}13function findElement(locator) {14 var self = this;15 return self.execute('findElement', {using: locator.using, value: locator.value})16 .then(function (res) {17 if (!res || !res.ELEMENT) {18 throw new Error("findElement did not return an element. Instead it returned " + JSON.stringify(res));19 }20 return new Element(self, res.ELEMENT);21 });22}23Element.prototype.click = function () {24 return this._webElem.click();25};26Element.prototype.sendKeys = function (text) {27 return this._webElem.sendKeys(text);28};29Element.prototype.getText = function () {30 return this._webElem.getText();31};32Element.prototype.getAttribute = function (attribute) {33 return this._webElem.getAttribute(attribute);34};35Element.prototype.getAttribute = function (attribute) {36 return this._webElem.getAttribute(attribute);37};38Element.prototype.getAttribute = function (attribute) {39 return this._webElem.getAttribute(attribute);40};41Element.prototype.getAttribute = function (attribute) {42 return this._webElem.getAttribute(attribute);43};44Element.prototype.getAttribute = function (attribute) {

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Appium Base Driver automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful