How to use this.remote.execute method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

DatePicker.js

Source:DatePicker.js Github

copy

Full Screen

1define(function () {2 "use strict";3 var registerSuite = intern.getPlugin("interface.object").registerSuite;4 var pollUntil = requirejs.nodeRequire("@theintern/leadfoot/helpers/pollUntil").default;5 var assert = intern.getPlugin("chai").assert;6 var keys = requirejs.nodeRequire("@theintern/leadfoot/keys").default;7 var luxon = require("luxon"),8 DateTime = luxon.DateTime;9 registerSuite("DatePicker - functional", {10 before: function () {11 return this.remote12 .get("deliteful/tests/functional/DatePicker.html")13 .then(pollUntil("return ready ? true : null;", [],14 intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL));15 },16 tests: {17 "basic mouse navigation": function () {18 return this.remote19 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")20 // Try month back/forward buttons on day view.21 .findByCssSelector(".d-date-picker-header .d-date-picker-button").click().click().end()22 .findByCssSelector(".d-date-picker-header .d-label").getVisibleText().then(function (month) {23 assert.strictEqual(month, "December");24 }).end()25 .findByCssSelector(".d-date-picker-footer .d-label").getVisibleText().then(function (year) {26 assert.strictEqual(year, "1999");27 }).end()28 .findAllByCssSelector("[role=gridcell]").getVisibleText().then(function (days) {29 assert.strictEqual(days[0].trim(), "28", "Nov 28");30 assert.strictEqual(days[days.length - 1].trim(), "1", "January 1");31 }).end()32 .findByCssSelector(".d-date-picker-header .d-date-picker-button:last-child").click().click().end()33 .findByCssSelector(".d-date-picker-header .d-label").getVisibleText().then(function (month) {34 assert.strictEqual(month, "February");35 }).end()36 .findByCssSelector(".d-date-picker-footer .d-label").getVisibleText().then(function (year) {37 assert.strictEqual(year, "2000");38 }).end()39 // Try year back/forward buttons on day view.40 .findByCssSelector(".d-date-picker-footer .d-date-picker-button").click().click().end()41 .findByCssSelector(".d-date-picker-header .d-label").getVisibleText().then(function (month) {42 assert.strictEqual(month, "February");43 }).end()44 .findByCssSelector(".d-date-picker-footer .d-label").getVisibleText().then(function (year) {45 assert.strictEqual(year, "1998");46 }).end()47 .findAllByCssSelector("[role=gridcell]").getVisibleText().then(function (days) {48 assert.strictEqual(days[0].trim(), "1", "Feb 1, 1998");49 assert.strictEqual(days[days.length - 1].trim(), "28", "Feb 28, 1998");50 }).end()51 .findByCssSelector(".d-date-picker-footer .d-date-picker-button:last-child").click().end()52 .findByCssSelector(".d-date-picker-header .d-label").getVisibleText().then(function (month) {53 assert.strictEqual(month, "February");54 }).end()55 .findByCssSelector(".d-date-picker-footer .d-label").getVisibleText().then(function (year) {56 assert.strictEqual(year, "1999");57 }).end();58 },59 "selection": {60 "current month": function () {61 return this.remote62 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 1);")63 .findByCssSelector("[role=row]:nth-child(3) [role=gridcell]:nth-child(4)")64 .getVisibleText().then(function (day) {65 assert.strictEqual(day.trim(), "5", "Jan 5");66 })67 .click()68 .end()69 .findByCssSelector(".d-date-picker-selected").getVisibleText().then(function (day) {70 assert.strictEqual(day.trim(), "5");71 }).end()72 .findById("value").getVisibleText().then(function (value) {73 assert.strictEqual(value, "2000-01-05");74 }).end();75 },76 "previous month": function () {77 // Select a day from previous month (and year).78 return this.remote79 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 1);")80 .findByCssSelector("[role=gridcell]:nth-child(1)").getVisibleText().then(function (day) {81 assert.strictEqual(day.trim(), "26", "Dec 26");82 })83 .click()84 .end()85 .findByCssSelector(".d-date-picker-selected").getVisibleText().then(function (day) {86 assert.strictEqual(day.trim(), "26");87 }).end()88 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")89 .getVisibleText().then(function (month) {90 assert.strictEqual(month, "December", "selected month");91 })92 .end()93 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")94 .getVisibleText().then(function (year) {95 assert.strictEqual(year, "1999", "selected year");96 })97 .end()98 .findById("value").getVisibleText().then(function (value) {99 assert.strictEqual(value, "1999-12-26");100 }).end();101 },102 "next month": function () {103 return this.remote104 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 1);")105 .findByCssSelector("[role=row]:last-child [role=gridcell]:last-child")106 .getVisibleText().then(function (day) {107 assert.strictEqual(day.trim(), "5", "Feb 5");108 })109 .click()110 .end()111 .findByCssSelector(".d-date-picker-selected").getVisibleText().then(function (day) {112 assert.strictEqual(day.trim(), "5");113 }).end()114 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")115 .getVisibleText().then(function (month) {116 assert.strictEqual(month, "February", "selected month");117 })118 .end()119 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")120 .getVisibleText().then(function (year) {121 assert.strictEqual(year, "2000", "selected year");122 })123 .end()124 .findById("value").getVisibleText().then(function (value) {125 assert.strictEqual(value, "2000-02-05");126 }).end();127 }128 },129 "month picker": {130 "click currently selected month": function () {131 return this.remote132 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")133 // Open the month view.134 .findByCssSelector(".d-day-picker .d-date-picker-header .d-date-picker-button:nth-child(2)")135 .click().end()136 .sleep(500)137 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {138 assert.isTrue(displayed, "month picker displayed");139 }).end()140 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {141 assert.isFalse(displayed, "day picker hidden");142 }).end()143 .findAllByCssSelector(".d-month-picker [role=gridcell]").getVisibleText()144 .then(function (months) {145 assert.strictEqual(months.length, 12, "# of cells");146 assert.strictEqual(months[0], "Jan", "first cell");147 assert.strictEqual(months[11], "Dec", "last cell");148 }).end()149 // Try clicking currently selected month.150 .findByCssSelector(".d-month-picker .d-date-picker-selected")151 .getVisibleText().then(function (month) {152 assert.strictEqual(month, "Feb");153 })154 .click()155 .end()156 .sleep(500)157 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {158 assert.isFalse(displayed, "month picker hidden");159 }).end()160 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {161 assert.isTrue(displayed, "day picker displayed");162 }).end()163 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")164 .getVisibleText().then(function (month) {165 assert.strictEqual(month, "February", "selected month");166 })167 .end()168 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")169 .getVisibleText().then(function (year) {170 assert.strictEqual(year, "2000", "selected year");171 })172 .end();173 },174 "select first month": function () {175 // Reopen month picker and click first month.176 return this.remote177 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")178 .findByCssSelector(".d-day-picker .d-date-picker-header .d-date-picker-button:nth-child(2)")179 .click().end()180 .sleep(500)181 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {182 assert.isTrue(displayed, "month picker displayed");183 }).end()184 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {185 assert.isFalse(displayed, "day picker hidden");186 }).end()187 .findByCssSelector(".d-month-picker [role=gridcell]")188 .getVisibleText().then(function (month) {189 assert.strictEqual(month, "Jan");190 })191 .click()192 .end()193 .sleep(500)194 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {195 assert.isFalse(displayed, "month picker hidden");196 }).end()197 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {198 assert.isTrue(displayed, "day picker displayed");199 }).end()200 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")201 .getVisibleText().then(function (month) {202 assert.strictEqual(month, "January", "selected month");203 })204 .end()205 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")206 .getVisibleText().then(function (year) {207 assert.strictEqual(year, "2000", "selected year");208 })209 .end();210 },211 "select last month": function () {212 // Reopen month picker and click last month.213 return this.remote214 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")215 .findByCssSelector(".d-day-picker .d-date-picker-header .d-date-picker-button:nth-child(2)")216 .click().end()217 .sleep(500)218 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {219 assert.isTrue(displayed, "month picker displayed");220 }).end()221 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {222 assert.isFalse(displayed, "day picker hidden");223 }).end()224 .findByCssSelector(".d-month-picker [role=row]:last-child [role=gridcell]:last-child")225 .getVisibleText().then(function (month) {226 assert.strictEqual(month, "Dec");227 })228 .click()229 .end()230 .sleep(500)231 .findByCssSelector(".d-month-picker").isDisplayed().then(function (displayed) {232 assert.isFalse(displayed, "month picker hidden");233 }).end()234 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {235 assert.isTrue(displayed, "day picker displayed");236 }).end()237 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")238 .getVisibleText().then(function (month) {239 assert.strictEqual(month, "December", "selected month");240 })241 .end()242 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")243 .getVisibleText().then(function (year) {244 assert.strictEqual(year, "2000", "selected year");245 })246 .end();247 }248 },249 "year picker": {250 "click currently selected year": function () {251 return this.remote252 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")253 // Open the year view.254 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-date-picker-button:nth-child(2)")255 .click().end()256 .sleep(500)257 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {258 assert.isTrue(displayed, "year picker displayed");259 }).end()260 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {261 assert.isFalse(displayed, "day picker hidden");262 }).end()263 .findAllByCssSelector(".d-year-picker [role=gridcell]").getVisibleText().then(function (years) {264 assert.strictEqual(years.length, 25, "# of cells");265 assert.strictEqual(years[0], "1988", "first cell");266 assert.strictEqual(years[24], "2012", "last cell");267 }).end()268 .findByCssSelector(".d-year-picker .d-label").getVisibleText().then(function (label) {269 assert.strictEqual(label, "1988-2012", "label");270 }).end()271 // Try clicking currently selected year.272 .findByCssSelector(".d-year-picker .d-date-picker-selected")273 .getVisibleText().then(function (year) {274 assert.strictEqual(year, "2000");275 })276 .click()277 .end()278 .sleep(500)279 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {280 assert.isFalse(displayed, "year picker hidden");281 }).end()282 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {283 assert.isTrue(displayed, "day picker displayed");284 }).end()285 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")286 .getVisibleText().then(function (month) {287 assert.strictEqual(month, "February", "selected month");288 })289 .end()290 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")291 .getVisibleText().then(function (year) {292 assert.strictEqual(year, "2000", "selected year");293 })294 .end();295 },296 "navigation": function () {297 return this.remote298 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")299 // Open the year view.300 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-date-picker-button:nth-child(2)")301 .click().end()302 .sleep(500)303 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {304 assert.isTrue(displayed, "year picker displayed");305 }).end()306 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {307 assert.isFalse(displayed, "day picker hidden");308 }).end()309 // Advance 25 years.310 .findByCssSelector(".d-year-picker .d-date-picker-footer .d-date-picker-button:nth-child(3)")311 .click().end()312 .sleep(500)313 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {314 assert.isTrue(displayed, "year picker still displayed");315 }).end()316 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {317 assert.isFalse(displayed, "day picker still hidden");318 }).end()319 .findAllByCssSelector(".d-year-picker [role=gridcell]").getVisibleText().then(function (years) {320 assert.strictEqual(years.length, 25, "# of cells");321 assert.strictEqual(years[0], "2013", "first cell");322 assert.strictEqual(years[24], "2037", "last cell");323 }).end()324 .findByCssSelector(".d-year-picker .d-label").getVisibleText().then(function (label) {325 assert.strictEqual(label, "2013-2037", "label");326 }).end()327 // Go back 50 years.328 .findByCssSelector(".d-year-picker .d-date-picker-footer .d-date-picker-button:nth-child(1)")329 .click().click().end()330 .sleep(500)331 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {332 assert.isTrue(displayed, "year picker still displayed #2");333 }).end()334 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {335 assert.isFalse(displayed, "day picker still hidden #2");336 }).end()337 .findAllByCssSelector(".d-year-picker [role=gridcell]").getVisibleText().then(function (years) {338 assert.strictEqual(years.length, 25, "# of cells");339 assert.strictEqual(years[0], "1963", "first cell");340 assert.strictEqual(years[24], "1987", "last cell");341 }).end()342 .findByCssSelector(".d-year-picker .d-label").getVisibleText().then(function (label) {343 assert.strictEqual(label, "1963-1987", "label");344 }).end()345 // Close by clicking first year.346 .findByCssSelector(".d-year-picker [role=gridcell]")347 .getVisibleText().then(function (year) {348 assert.strictEqual(year, "1963", "first cell (again)");349 })350 .click()351 .end()352 .sleep(500)353 .findByCssSelector(".d-year-picker").isDisplayed().then(function (displayed) {354 assert.isFalse(displayed, "year picker hidden");355 }).end()356 .findByCssSelector(".d-day-picker").isDisplayed().then(function (displayed) {357 assert.isTrue(displayed, "day picker displayed");358 }).end()359 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")360 .getVisibleText().then(function (month) {361 assert.strictEqual(month, "February", "selected month");362 })363 .end()364 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")365 .getVisibleText().then(function (year) {366 assert.strictEqual(year, "1963", "selected year");367 })368 .end();369 }370 },371 "external buttons": {372 "today button": function () {373 var today = DateTime.local();374 return this.remote375 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")376 .findByCssSelector(".-d-datepicker-today-button").click().end()377 .sleep(500)378 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")379 .getVisibleText().then(function (month) {380 var currentMonth = today.toLocaleString({month: "long"});381 assert.strictEqual(month, currentMonth, "current month");382 }).end()383 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")384 .getVisibleText().then(function (year) {385 var currentYear = "" + today.year;386 assert.strictEqual(year, currentYear, "current year");387 }).end();388 },389 "clear button": function () {390 return this.remote391 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 2, 1);")392 .findByCssSelector("[role=row]:nth-child(3) [role=gridcell]:nth-child(4)").click().end()393 .findByCssSelector("#value").getVisibleText().then(function (text) {394 assert.strictEqual(text, "2000-02-09", "after selecting value");395 }).end()396 .findByCssSelector(".-d-datepicker-clear-button").click().end()397 .sleep(500)398 .findByCssSelector("#value").getVisibleText().then(function (text) {399 assert.strictEqual(text, "", "after clearing value");400 }).end();401 }402 },403 "keyboard": {404 before: function () {405 var remote = this.remote;406 if (remote.environmentType.brokenSendKeys || !remote.environmentType.nativeEvents) {407 return this.skip("no keyboard support");408 }409 },410 tests: {411 "arrows and selection": function () {412 return this.remote413 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 22);")414 .findById("before").click().end()415 .pressKeys(keys.TAB) // Press TAB -> DatePicker416 .getActiveElement().getVisibleText().then(function (text) {417 assert.strictEqual(text, "22", "initial focus");418 }).end()419 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")420 .getVisibleText().then(function (month) {421 assert.strictEqual(month, "January", "selected month");422 })423 .end()424 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")425 .getVisibleText().then(function (year) {426 assert.strictEqual(year, "2000", "selected year");427 })428 .end()429 .pressKeys(keys.ARROW_RIGHT)430 .getActiveElement().getVisibleText().then(function (text) {431 assert.strictEqual(text, "23", "right arrow (loops to next row)");432 }).end()433 .pressKeys(keys.ARROW_DOWN)434 .getActiveElement().getVisibleText().then(function (text) {435 assert.strictEqual(text, "30", "down arrow");436 }).end()437 .pressKeys(keys.ARROW_DOWN)438 .getActiveElement().getVisibleText().then(function (text) {439 assert.strictEqual(text, "6", "arrow down to next month");440 }).end()441 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")442 .getVisibleText().then(function (month) {443 assert.strictEqual(month, "February", "selected month");444 })445 .end()446 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")447 .getVisibleText().then(function (year) {448 assert.strictEqual(year, "2000", "selected year");449 })450 .end()451 .pressKeys(keys.ARROW_LEFT)452 .getActiveElement().getVisibleText().then(function (text) {453 assert.strictEqual(text, "5", "arrow left");454 }).end()455 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")456 .getVisibleText().then(function (month) {457 assert.strictEqual(month, "February", "selected month");458 })459 .end()460 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")461 .getVisibleText().then(function (year) {462 assert.strictEqual(year, "2000", "selected year");463 })464 .end()465 .pressKeys(keys.ARROW_UP)466 .getActiveElement().getVisibleText().then(function (text) {467 assert.strictEqual(text, "29", "arrow up to previous month");468 }).end()469 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")470 .getVisibleText().then(function (month) {471 assert.strictEqual(month, "January", "selected month");472 })473 .end()474 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")475 .getVisibleText().then(function (year) {476 assert.strictEqual(year, "2000", "selected year");477 })478 .end()479 .pressKeys(keys.ENTER)480 .findByCssSelector(".d-date-picker-selected").getVisibleText().then(function (day) {481 assert.strictEqual(day, "29");482 }).end()483 .findById("value").getVisibleText().then(function (value) {484 assert.strictEqual(value, "2000-01-29");485 }).end();486 },487 "home and end": function () {488 return this.remote489 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 15);")490 .findById("before").click().end()491 .pressKeys(keys.TAB) // Press TAB -> DatePicker492 .getActiveElement().getVisibleText().then(function (text) {493 assert.strictEqual(text, "15", "initial focus");494 }).end()495 .pressKeys(keys.HOME)496 .getActiveElement().getVisibleText().then(function (text) {497 assert.strictEqual(text, "1", "home");498 }).end()499 .pressKeys(keys.END)500 .getActiveElement().getVisibleText().then(function (text) {501 assert.strictEqual(text, "31", "end");502 }).end();503 },504 "page down / page up": function () {505 if (this.remote.environmentType.browserName.toLowerCase() === "internet explorer") {506 // Since evt.shiftKey not set (although it works when manually tested).507 return this.skip("shift-page-down getting treated as page-down, spurious test failure");508 }509 return this.remote510 .execute("document.getElementById('calendar1').value = DateTime.local(2000, 1, 31);")511 .findById("before").click().end()512 .pressKeys(keys.TAB) // Press TAB -> DatePicker513 .getActiveElement().getVisibleText().then(function (text) {514 assert.strictEqual(text, "31", "initial focus Jan 15");515 }).end()516 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")517 .getVisibleText().then(function (month) {518 assert.strictEqual(month, "January", "initial selected month");519 })520 .end()521 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")522 .getVisibleText().then(function (year) {523 assert.strictEqual(year, "2000", "initial selected year");524 })525 .end()526 .pressKeys(keys.PAGE_DOWN)527 .getActiveElement().getVisibleText().then(function (text) {528 // There's no Feb 30, so page-down should go from Jan 31 to Feb 29.529 assert.strictEqual(text, "29", "page down to next month");530 }).end()531 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")532 .getVisibleText().then(function (month) {533 assert.strictEqual(month, "February", "selected month after page-down");534 })535 .end()536 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")537 .getVisibleText().then(function (year) {538 assert.strictEqual(year, "2000", "selected year after page-down");539 })540 .end()541 .pressKeys(keys.PAGE_UP)542 .getActiveElement().getVisibleText().then(function (text) {543 assert.strictEqual(text, "29", "page up to previous month");544 }).end()545 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")546 .getVisibleText().then(function (month) {547 assert.strictEqual(month, "January", "selected month after page-up");548 })549 .end()550 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")551 .getVisibleText().then(function (year) {552 assert.strictEqual(year, "2000", "selected year after page-up");553 })554 .end()555 .pressKeys(keys.SHIFT + keys.PAGE_DOWN)556 .pressKeys(keys.SHIFT)557 .getActiveElement().getVisibleText().then(function (text) {558 assert.strictEqual(text, "29", "shift-page down to next year");559 }).end()560 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")561 .getVisibleText().then(function (month) {562 assert.strictEqual(month, "January", "selected month after shift-page-down");563 })564 .end()565 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")566 .getVisibleText().then(function (year) {567 assert.strictEqual(year, "2001", "selected year after shift-page-down");568 })569 .end()570 .pressKeys(keys.SHIFT + keys.PAGE_UP)571 .pressKeys(keys.SHIFT)572 .getActiveElement().getVisibleText().then(function (text) {573 assert.strictEqual(text, "29", "shift-page up to previous year");574 }).end()575 .findByCssSelector(".d-day-picker .d-date-picker-header .d-label")576 .getVisibleText().then(function (month) {577 assert.strictEqual(month, "January", "selected month after shift-page-up");578 })579 .end()580 .findByCssSelector(".d-day-picker .d-date-picker-footer .d-label")581 .getVisibleText().then(function (year) {582 assert.strictEqual(year, "2000", "selected year after shift-page-up");583 })584 .end();585 }586 }587 }588 }589 });...

Full Screen

Full Screen

KeyNav.js

Source:KeyNav.js Github

copy

Full Screen

...85 assert.deepEqual(value, [-1, 0, -1, -1, -1, -1, -1, -1], "tabindexes #2");86 });87 },88 "grid arrow navigation": function () {89 return this.remote.execute("grid.focus();")90 .execute("return document.activeElement.textContent")91 .then(function (value) {92 assert.strictEqual(value, "apple", "focus");93 })94 .pressKeys(keys.ARROW_DOWN)95 .execute("return document.activeElement.textContent")96 .then(function (value) {97 assert.strictEqual(value, "pear", "down");98 })99 .pressKeys(keys.ARROW_RIGHT)100 .execute("return document.activeElement.textContent")101 .then(function (value) {102 assert.strictEqual(value, "grapes", "right");103 })104 .pressKeys(keys.ARROW_LEFT)105 .execute("return document.activeElement.textContent")106 .then(function (value) {107 assert.strictEqual(value, "pear", "left");108 })109 .pressKeys(keys.ARROW_UP)110 .execute("return document.activeElement.textContent")111 .then(function (value) {112 assert.strictEqual(value, "apple", "up");113 })114 .pressKeys(keys.END)115 .execute("return document.activeElement.textContent")116 .then(function (value) {117 assert.strictEqual(value, "raspberry", "end");118 })119 .pressKeys(keys.HOME)120 .execute("return document.activeElement.textContent")121 .then(function (value) {122 assert.strictEqual(value, "apple", "home");123 });124 },125 "grid letter search": function () {126 return this.remote.execute("grid.focus();")127 .execute("return document.activeElement.textContent")128 .then(function (value) {129 assert.strictEqual(value, "apple", "focus");130 })131 .pressKeys("b") // search for word starting with b132 .execute("return document.activeElement.textContent")133 .then(function (value) {134 assert.strictEqual(value, "banana", "b");135 })136 .sleep(100) // clear timer so next keystroke taken as new search rather than continuation137 .pressKeys("b") // search for next word starting with b138 .execute("return document.activeElement.textContent")139 .then(function (value) {140 assert.strictEqual(value, "blueberry", "b again");141 })142 .sleep(100) // clear timer so next keystroke taken as new search rather than continuation143 .pressKeys("r") // search for word starting with r144 .execute("return document.activeElement.textContent")145 .then(function (value) {146 assert.strictEqual(value, "raspberry", "right");147 })148 .sleep(100) // clear timer so next keystroke taken as new search rather than continuation149 .pressKeys("bl") // search for word starting with bl150 .execute("return document.activeElement.textContent")151 .then(function (value) {152 assert.strictEqual(value, "blueberry", "bl");153 });154 },155 "activationTracker integration": function () {156 return this.remote157 .findById("keyboardInput").click().end()158 .pressKeys(keys.TAB)159 .execute("return document.activeElement.activateLog.join(', ')").then(function (value) {160 // Test for bug where child would get a delite-deactivated event immediately after the161 // delite-activated event.162 assert.strictEqual(value, "activated");163 });164 },165 "multi char search": function () {166 return this.remote167 .findById("keyboardInput")168 .click()169 .pressKeys(keys.TAB)170 .execute("return document.activeElement.textContent")171 .then(function (value) {172 assert.strictEqual(value, "Alabama", "navigated to Alabama");173 })174 .execute("return clicks.textContent")175 .then(function (value) {176 assert.strictEqual(value, "0", "no click events yet");177 })178 .sleep(1000)179 // Now that 1000ms have elapsed, the search should be canceled, and each space typed180 // should generate an a11y click event181 .pressKeys(" ")182 .execute("return clicks.textContent")183 .then(function (value) {184 assert.strictEqual(value, "3", "space key outside of search causes click events");185 })186 // And make sure that we can search to somewhere else187 .pressKeys("n")188 .execute("return document.activeElement.textContent")189 .then(function (value) {190 assert.strictEqual(value, "New Hampshire", "n");191 });192 },193 "setup key handler for space": function () {194 return this.remote195 .findByCssSelector("#keyboardInputCust")196 .click()197 .end()198 .pressKeys(keys.TAB)// enters KeyNav, navigates to <input>199 .execute("return document.activeElement.id;")200 .then(function (value) {201 assert.strictEqual(value, "myInput", "focused on <input>");202 })203 .pressKeys("a b c") // sending space to input shouldn't call registered handler for space key204 .execute("return myInput.value")205 .then(function (value) {206 assert.strictEqual(value, "a b c", "typing into input");207 })208 .execute("return spaces.textContent")209 .then(function (value) {210 assert.strictEqual(value, "0", "<input>: no handler callbacks");211 })212 .pressKeys(keys.ARROW_DOWN) // navigate to <button>213 .execute("return document.activeElement.id;")214 .then(function (value) {215 assert.strictEqual(value, "myButton", "focused on <button>");216 })217 .pressKeys(" ") // sending space to <button> shouldn't call registered handler for space key218 .pressKeys(keys.ENTER) // likewise for enter key219 .execute("return spaces.textContent")220 .then(function (value) {221 assert.strictEqual(value, "0", "<button>: no handler callbacks");222 })223 .execute("return myButton.innerHTML")224 .then(function (value) {225 assert.strictEqual(value, "2 clicks", "keyboard clicks on <button>");226 })227 .pressKeys(keys.ARROW_DOWN) // navigate to <a>228 .execute("return document.activeElement.id;")229 .then(function (value) {230 assert.strictEqual(value, "myAnchor", "focused on <a>");231 })232 .pressKeys(keys.ENTER) // sending Enter to <a> should click it, not be processed by KeyNav233 .execute("return myAnchor.innerHTML")234 .then(function (value) {235 assert.strictEqual(value, "1 click", "keyboard click on <a>");236 })237 .execute("return spaces.textContent")238 .then(function (value) {239 assert.strictEqual(value, "0", "<a>: no handler callbacks");240 })241 .pressKeys(keys.ARROW_DOWN)242 .pressKeys("new m")// similarly, handler shouldn't be called for space within a searchstring243 .execute("return document.activeElement.textContent")244 .then(function (value) {245 assert.strictEqual(value, "New Mexico", "new m");246 })247 .execute("return spaces.textContent")248 .then(function (value) {249 assert.strictEqual(value, "0", "no handler callback after 'new m' search");250 })251 .sleep(1000)252 // Now that 1000ms have elapsed, the search should be canceled, and each space typed253 // should call the handler registered for the space key.254 .pressKeys(" ")255 .execute("return spaces.textContent")256 .then(function (value) {257 assert.strictEqual(value, "3", "space key outside of search calls registered handler");258 });259 },260 "embedded form controls": function () {261 return this.remote.execute("testContainer2.focus();")262 .execute("return document.activeElement.textContent")263 .then(function (value) {264 assert.strictEqual(value, "four", "focus");265 })266 .pressKeys(keys.ARROW_DOWN)267 .execute("return document.activeElement.id")268 .then(function (value) {269 assert.strictEqual(value, "input", "down");270 })271 .pressKeys("fo") // should write to the <input> rather than letter searching to <div>four</div>272 .execute("return document.activeElement.id")273 .then(function (value) {274 assert.strictEqual(value, "input", "still input1");275 })276 .execute("return document.activeElement.value")277 .then(function (value) {278 assert.strictEqual(value, "fo", "input works");279 })280 .pressKeys(keys.ARROW_LEFT + "l")281 .execute("return document.activeElement.value")282 .then(function (value) {283 assert.strictEqual(value, "flo", "left arrow worked");284 })285 .pressKeys(keys.ARROW_DOWN) // arrow down should exit the <input> and go to the next node286 .execute("return document.activeElement.textContent")287 .then(function (value) {288 assert.strictEqual(value, "five", "down to five");289 })290 .pressKeys(keys.ARROW_DOWN) // arrow down again to checkbox291 .execute("return document.activeElement.id")292 .then(function (value) {293 assert.strictEqual(value, "checkbox", "down to checkbox");294 })295 .pressKeys(" ") // check the checkbox using keyboard296 .execute("return document.activeElement.checked")297 .then(function (value) {298 assert.strictEqual(value, true, "checked the checkbox");299 })300 .pressKeys("f") // keyboard search should go to "four" node301 .execute("return document.activeElement.textContent")302 .then(function (value) {303 assert.strictEqual(value, "four", "keyboard searched to 'four'");304 });305 },306 "combobox": {307 keyboard: function () {308 return this.remote.execute("document.body.scrollTop = 10000; combobox.focus();")309 .pressKeys(keys.ARROW_DOWN)310 .execute("return document.activeElement.id")311 .then(function (value) {312 assert.strictEqual(value, "combobox", "down arrow leaves focus on combobox");313 })314 .findByCssSelector("#combobox_dropdown .d-active-descendant")315 .getVisibleText().then(function (value) {316 assert.strictEqual(value, "Alaska", "navigated to Alaska");317 })318 .end()319 .findById("combobox_dropdown_previous_node")320 .getVisibleText().then(function (value) {321 assert.strictEqual(value, "Alabama", "got navigation event (prev)");322 })323 .end()324 .findById("combobox_dropdown_current_node")325 .getVisibleText().then(function (value) {326 assert.strictEqual(value, "Alaska", "got navigation event (cur)");327 })328 .end();329 },330 mouse: function () {331 var environmentType = this.remote.environmentType;332 if (environmentType.brokenMouseEvents) {333 // https://github.com/theintern/leadfoot/issues/17334 return this.skip("click() doesn't generate mousedown, so navigation won't work");335 }336 if (environmentType.platformName === "iOS" || environmentType.platform === "ANDROID") {337 // https://github.com/theintern/leadfoot/issues/61338 return this.skip("click() doesn't generate touchstart, so navigation won't work");339 }340 return this.remote.execute("document.body.scrollTop = 10000; combobox.focus();")341 .findById("unfocusable_NJ")342 .click()343 .end()344 .findByCssSelector("#combobox_dropdown .d-active-descendant")345 .getVisibleText().then(function (value) {346 assert.strictEqual(value, "New Jersey", "navigated to New Jersey");347 })348 .end()349 .findById("combobox_dropdown_current_node")350 .getVisibleText().then(function (value) {351 assert.strictEqual(value, "New Jersey", "got navigation event (cur)");352 })353 .end();354 }...

Full Screen

Full Screen

activationTracker.js

Source:activationTracker.js Github

copy

Full Screen

1define([], function () {2 var registerSuite = intern.getPlugin("interface.object").registerSuite;3 var assert = intern.getPlugin("chai").assert;4 var keys = requirejs.nodeRequire("@theintern/leadfoot/keys").default;5 var pollUntil = requirejs.nodeRequire("@theintern/leadfoot/helpers/pollUntil").default;6 registerSuite("activationTracker functional tests", {7 before: function () {8 return this.remote9 .get("delite/tests/functional/activationTracker.html")10 .then(pollUntil("return ready || null;", [], intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL));11 },12 beforeEach: function () {13 return this.remote.findById("clearButton")14 .click()15 .end()16 .sleep(100); // because the clear button clears things on a setTimeout()17 },18 tests: {19 "basic": function () {20 var environmentType = this.remote.environmentType;21 return this.remote22 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {23 assert.strictEqual(changes, "0", "activeStack changes #0");24 })25 .findById("first").click().end()26 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {27 assert.strictEqual(changes, "1", "activeStack changes #1");28 })29 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {30 assert.strictEqual(activeStack, "form, first", "activeStack #1");31 })32 .execute("return document.getElementById('log').value;").then(function (log) {33 assert.strictEqual(log.trim(), "form activated", "log #1");34 })35 .findById("second").click().end() // focus another simple input36 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {37 assert.strictEqual(changes, "2", "activeStack changes #2");38 })39 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {40 assert.strictEqual(activeStack, "form, second", "activeStack #2");41 })42 .execute("return document.getElementById('log').value;").then(function (log) {43 // Since the deliteful/Form widget didn't leave the focus chain it44 // shouldn't have any more events besides the original.45 assert.strictEqual(log.trim(), "form activated", "log #2");46 })47 .findByCssSelector("#combobox input").click().end() // focus combobox48 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {49 assert.strictEqual(changes, "3", "activeStack changes #3");50 })51 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {52 assert.strictEqual(activeStack, "form, fieldset1, combobox, input", "activeStack #3");53 })54 .execute("return document.getElementById('log').value;").then(function (log) {55 assert.strictEqual(log.trim(),56 "form activated\nfieldset1 activated\ncombobox activated", "log #3");57 })58 .findByCssSelector("#combobox input").click().end() // to check for dup notifications59 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {60 assert.strictEqual(changes, "3", "activeStack changes #4");61 })62 .findByCssSelector("#editor div").click().end()63 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {64 assert.strictEqual(activeStack, "form, editor, div", "activeStack #4");65 })66 .execute("return document.getElementById('log').value;").then(function (log) {67 assert.strictEqual(log.trim(), "form activated\nfieldset1 activated\ncombobox activated\n" +68 "combobox deactivated\nfieldset1 deactivated\neditor activated", "log #4");69 })70 // clicking spinner buttons should activate the spinner, even71 // though there's no actual DOM focus event72 .findByCssSelector("fake-spinner .button").click().end()73 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {74 if (environmentType.brokenMouseEvents) {75 // click() doesn't generate pointerdown event on IE10+ and neither does76 // moveMouseTo().pressMouseButton(1).releaseMouseButton(1).77 // see https://github.com/theintern/leadfoot/issues/17.78 return;79 }80 if (environmentType.platformName === "iOS" || environmentType.platform === "ANDROID") {81 // click() doesn't generate touchstart on iOS or android, see82 // https://github.com/theintern/leadfoot/issues/6183 return;84 }85 assert.strictEqual(activeStack, "form, fieldset2, spinner, span", "activeStack #5");86 });87 },88 "keyboard": function () {89 if (this.remote.environmentType.brokenSendKeys || !this.remote.environmentType.nativeEvents) {90 return this.skip("no keyboard support");91 }92 return this.remote93 .findById("first").click().end()94 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {95 assert.strictEqual(activeStack, "form, first", "activeStack #1");96 })97 .execute("return document.getElementById('log').value;").then(function (log) {98 assert.strictEqual(log.trim(), "form activated", "log #1");99 })100 .pressKeys(keys.TAB) // focus another simple input101 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {102 assert.strictEqual(activeStack, "form, second", "activeStack #2");103 })104 .execute("return document.getElementById('log').value;").then(function (log) {105 // Since the deliteful/Form widget didn't leave the focus chain it106 // shouldn't have any more events besides the original.107 assert.strictEqual(log.trim(), "form activated", "log #2");108 })109 .pressKeys(keys.TAB) // focus combobox110 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {111 assert.strictEqual(activeStack, "form, fieldset1, combobox, input", "activeStack #3");112 })113 .execute("return document.getElementById('log').value;").then(function (log) {114 assert.strictEqual(log.trim(),115 "form activated\nfieldset1 activated\ncombobox activated", "log #3");116 })117 .findById("combobox").click().end() // focus combobox again to check for duplicate notifications118 .execute("return document.getElementById('activeStackChanges').value;").then(function (changes) {119 assert.strictEqual(changes, "3", "activeStack changes #1");120 });121 },122 "dropdown": function () {123 var environmentType = this.remote.environmentType;124 return this.remote125 .execute("document.getElementById('dropdownButton').scrollIntoView();")126 .findById("dropdownButton").click().end()127 .findByCssSelector("fake-popup")128 .isDisplayed().then(function (visible) {129 assert(visible, "popup visible");130 })131 .click()132 .end()133 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {134 if (environmentType.brokenMouseEvents) {135 // click() doesn't generate pointerdown event on IE10+ and neither does136 // moveMouseTo().pressMouseButton(1).releaseMouseButton(1).137 // see https://github.com/theintern/leadfoot/issues/17.138 return;139 }140 if (environmentType.platformName === "iOS" || environmentType.platform === "ANDROID") {141 // click() doesn't generate touchstart on iOS, see142 // https://github.com/theintern/leadfoot/issues/61143 return;144 }145 assert.strictEqual(activeStack, "form, dropdownButton, popup", "activeStack #1");146 });147 },148 "hover": function () {149 // note: check specifically for iOS to workaround https://github.com/theintern/leadfoot/issues/62150 if (!this.remote.environmentType.mouseEnabled || this.remote.environmentType.platformName === "iOS") {151 return this.skip("touch device, skipping mouse specific test");152 }153 return this.remote154 .execute("document.getElementById('hoverDropdownButton').scrollIntoView();")155 .findByCssSelector("#hoverDropdownButton span:nth-child(1)").moveMouseTo().end()156 .sleep(1000)157 .execute("return document.getElementById('hoverDropdownButton').log").then(function (log) {158 assert.deepEqual(log, [159 "this delite-hover-activated",160 "child 1 delite-hover-activated"161 ], "button hovered");162 })163 .findById("hoverPopup").isDisplayed().then(function (visible) {164 assert(visible, "popup visible");165 }).end()166 .findByCssSelector("#hoverDropdownButton span:nth-child(2)").moveMouseTo().end()167 .sleep(1000)168 .execute("return document.getElementById('hoverDropdownButton').log").then(function (log) {169 assert.deepEqual(log, [170 "this delite-hover-activated",171 "child 1 delite-hover-activated",172 "child 1 delite-hover-deactivated",173 "child 2 delite-hover-activated"174 ], "checking delite-hover-activated doesn't bubble to root node");175 })176 .findById("hoverPopup").isDisplayed().then(function (visible) {177 assert(visible, "popup still visible");178 }).moveMouseTo().end()179 .sleep(1000)180 .execute("return document.getElementById('hoverDropdownButton').log").then(function (log) {181 assert.deepEqual(log, [182 "this delite-hover-activated",183 "child 1 delite-hover-activated",184 "child 1 delite-hover-deactivated",185 "child 2 delite-hover-activated",186 "child 2 delite-hover-deactivated",187 "popup delite-hover-activated"188 ], "hover stack works with popups");189 })190 .findById("clearButton").moveMouseTo().end()191 .sleep(1000)192 .execute("return document.getElementById('hoverDropdownButton').log").then(function (log) {193 assert.deepEqual(log, [194 "this delite-hover-activated",195 "child 1 delite-hover-activated",196 "child 1 delite-hover-deactivated",197 "child 2 delite-hover-activated",198 "child 2 delite-hover-deactivated",199 "popup delite-hover-activated",200 "popup delite-hover-deactivated",201 "this delite-hover-deactivated"202 ], "everything unhovered");203 });204 },205 "detaching hovered/active nodes": function () {206 return this.remote207 // Test that detaching active (and hovered) node removes it from the activeStack/hoverStack.208 .findById("removeMe").click().end()209 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {210 assert.strictEqual(activeStack, "grandparent, parent", "activeStack #1");211 })212 .execute("return document.getElementById('hoverStack').value;").then(function (activeStack) {213 assert.strictEqual(activeStack, "grandparent, parent", "hoverStack #1");214 })215 // Test that detaching parent of active (and hovered) node216 // removes it from the activeStack/hoverStack.217 .findById("removeMyParent").click().end()218 .execute("return document.getElementById('activeStack').value;").then(function (activeStack) {219 assert.strictEqual(activeStack, "grandparent", "activeStack #2");220 })221 .execute("return document.getElementById('hoverStack').value;").then(function (hoverStack) {222 assert.strictEqual(hoverStack, "grandparent", "hoverStack #2");223 });224 }225 }226 });...

Full Screen

Full Screen

popup.js

Source:popup.js Github

copy

Full Screen

1define([], function () {2 var registerSuite = intern.getPlugin("interface.object").registerSuite;3 var assert = intern.getPlugin("chai").assert;4 var pollUntil = requirejs.nodeRequire("@theintern/leadfoot/helpers/pollUntil").default;5 var tests = {6 "repeat move off screen": function () {7 // In old version of code, calling moveOffScreen twice would cause an exception.8 // No actual assert here, we're relying on the browser throwing an exception to webdriver.9 return this.remote10 .execute("glblPopupUtil.moveOffScreen(document.getElementById('spw'));")11 .execute("glblPopupUtil.moveOffScreen(document.getElementById('spw'));");12 },13 "open popup on the edge of another widget": function () {14 return this.remote15 .findById("choiceDropDownButton").click().end()16 .findById("choiceDropDown").isDisplayed().then(function (displayed) {17 assert.isTrue(displayed, "choiceDropDown popup visible");18 }).end();19 },20 "close popup on the edge of another widget": function () {21 return this.remote22 .findById("stub-for-blurring").click().end()23 .sleep(500)24 .findById("choiceDropDown").isDisplayed().then(function (displayed) {25 assert.isFalse(displayed, "choiceDropDown popup not visible");26 }).end();27 },28 "centered popup": function () {29 return this.remote30 .findById("showCenteredDialogButton").click().end()31 .findById("centeredDialog").isDisplayed().then(function (displayed) {32 assert.isTrue(displayed, "centeredDialog popup visible");33 }).end()34 .findByCssSelector("d-dialog-underlay").isDisplayed().then(function (displayed) {35 assert.isTrue(displayed, "d-dialog-underlay visible");36 }).end()37 .findByCssSelector("#centeredDialog .ok-button").click().end() // close popup38 .findById("centeredDialog").isDisplayed().then(function (displayed) {39 assert.isFalse(displayed, "centeredDialog popup hidden");40 }).end()41 .findByCssSelector("d-dialog-underlay").isDisplayed().then(function (displayed) {42 // Underlay should be either detached or display:none. Currently it's display:none.43 assert.isFalse(displayed, "d-dialog-underlay hidden");44 }).end();45 },46 "nested": function () {47 return this.remote48 .findById("showNestedMenuButton").click().end()49 .sleep(500)50 .findById("nestedOpener").isDisplayed().then(function (displayed) {51 assert.isTrue(displayed, "nestedOpener popup wasn't visible");52 }).end()53 .execute("nestedOpener._openPopup(nestedChoice1)")54 .sleep(500)55 .findById("nestedChoice1").isDisplayed().then(function (displayed) {56 assert.isTrue(displayed, "nestedChoice1 popup wasn't visible");57 }).end()58 .findById("stub-for-blurring").click().end()59 .sleep(500)60 .findById("nestedChoice1").isDisplayed().then(function (displayed) {61 assert.isFalse(displayed, "nestedChoice1 popup hidden");62 }).end()63 .findById("nestedOpener").isDisplayed().then(function (displayed) {64 assert.isFalse(displayed, "nestedOpener popup hidden");65 }).end();66 },67 "no hidden tab stops": function () {68 return this.remote69 .execute("return tabOrder()[0].id").then(function (value) {70 assert.strictEqual(value, "inputAtStart");71 })72 .execute("return tabOrder()[tabOrder().length - 1].id").then(function (value) {73 assert.strictEqual(value, "inputAtEnd");74 });75 },76 "x/y placement": function () {77 return this.remote78 .execute("window.scrollTo(0, 0);") // avoid spurious error due to scroll79 .findById("openAt1015Button").click().end()80 // note: "return xyPopup.getBoundingClientRect();" doesn't work on IE; webdriver bug.81 .execute("var pos = xyPopup.getBoundingClientRect(); return {left: pos.left, top: pos.top};")82 .then(function (pos) {83 assert.strictEqual(pos.left, 10, "popup x coord " + JSON.stringify(pos));84 assert.strictEqual(pos.top, 15, "popup y coord " + JSON.stringify(pos));85 })86 .findById("xyPopup").click().end();87 },88 "popup-after-position event": {89 before: function () {90 return this.remote91 .execute(function () { require("delite/scrollIntoView")(tooltipDropDownButton) })92 .findById("tooltipDropDownButton").click().end()93 .execute("return tooltip.popupAfterPositionEvents.length").then(function (value) {94 assert.strictEqual(value, 1, "popupAfterPositionEvents.length");95 })96 .findById("stub-for-blurring").click().end();97 },98 around: function () {99 return this.remote100 .execute("return tooltip.popupAfterPositionEvents.length").then(function (value) {101 assert.strictEqual(value, 1, "popupAfterPositionEvents.length");102 })103 .execute("return tooltip.popupAfterPositionEvents.pop();").then(function (final) {104 assert.strictEqual(final.corner, "TL", "popup corner");105 assert.strictEqual(final.aroundCorner, "BL", "aroundNode corner");106 })107 .execute("return tooltipDropDownButton._openRet").then(function (value) {108 assert.strictEqual(value.corner, "TL", "popup corner");109 assert.strictEqual(value.aroundCorner, "BL", "popup aroundCorner");110 });111 },112 at: function () {113 return this.remote114 .execute("tooltip.popupAfterPositionEvents = [];")115 .findById("openTooltipAt1015Button").click().end()116 .execute("return tooltip.popupAfterPositionEvents.length").then(function (value) {117 assert.strictEqual(value, 1, "popupAfterPositionEvents.length");118 })119 .execute("return tooltip.popupAfterPositionEvents.pop()").then(function (value) {120 // The final call to orient(), as well as the call to onOpen(), should have been for the121 // final position of the node, where corner == TL and aroundCorner == BR122 // (they are caddy-corner).123 assert.strictEqual(value.corner, "TL", "popup corner");124 assert.strictEqual(value.aroundCorner, "BR", "aroundNode corner");125 })126 .execute("return openRet;").then(function (value) {127 assert.strictEqual(value.corner, "TL", "popup corner");128 assert.strictEqual(value.aroundCorner, "BR", "aroundNode corner");129 })130 .findById("tooltip").click().end();131 }132 },133 "scrollbar": {134 at: function () {135 return this.remote136 .execute("openLotsOfChoicesPopupButton.scrollIntoView();")137 .findById("openLotsOfChoicesPopupButton").click().end()138 .execute(139 "return [getComputedStyle(lotsOfChoicesPopup).height.replace(/px/, ''), " +140 "document.documentElement.clientHeight, " +141 "getComputedStyle(lotsOfChoicesPopup.parentNode).height.replace(/px/, '')];")142 .then(function (value) {143 assert.isTrue(value[0] < value[1], "lotsOfChoicesPopup popup not shorter than viewport " +144 value[0] + ", " + value[1]);145 })146 .findById("lotsOfChoicesPopup").click().isDisplayed().then(function (visible) {147 assert.isFalse(visible, "lotsOfChoicesPopup hidden");148 })149 .end();150 },151 around: function () {152 return this.remote153 .execute("tallChoiceDropDownButton.scrollIntoView();")154 .findById("tallChoiceDropDownButton").click().end()155 .execute("return [getComputedStyle(tallChoiceDropDown).height.replace(/px/, ''), " +156 "document.documentElement.clientHeight, " +157 "getComputedStyle(tallChoiceDropDown.parentNode).height.replace(/px/, '')];")158 .then(function (value) {159 assert.isTrue(value[0] < value[1], "tallChoiceDropDown popup not shorter than viewport");160 });161 }162 },163 "change events": {164 "change event from dropdown closes dropdown": function () {165 return this.remote166 .findById("showDatePickerButton").click().end()167 .findById("myDatePicker")168 .isDisplayed().then(function (displayed) {169 assert.isTrue(displayed, "DatePicker popup visible");170 })171 .click()172 .isDisplayed().then(function (displayed) {173 assert.isFalse(displayed, "DatePicker popup hidden");174 })175 .end();176 },177 "change event from dropdown descendant doesn't close dropdown": function () {178 return this.remote179 .findById("showSimpleDialogButton").click().end()180 .findById("simpleDialog")181 .isDisplayed().then(function (displayed) {182 assert.isTrue(displayed, "Dialog visible");183 })184 .findByCssSelector("#simpleDialog input:nth-of-type(1)").type("hello").end()185 .findByCssSelector("#simpleDialog input:nth-of-type(2)").click().end()186 .isDisplayed().then(function (displayed) {187 assert.isTrue(displayed, "Dialog still visible");188 })189 .end();190 }191 }192 };193 registerSuite("popup functional tests", {194 "popup attached to body": {195 before: function () {196 return this.remote197 .get("delite/tests/functional/popup.html?sibling=false")198 .then(pollUntil("return ready || null;", [], intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL))199 .setFindTimeout(5000);200 },201 afterEach: function () {202 // Try to make sure that all popups are closed.203 return this.remote204 .findById("stub-for-blurring").click().end();205 },206 tests: tests207 },208 "popup sibling of anchor node": {209 before: function () {210 return this.remote211 .get("delite/tests/functional/popup.html")212 .then(pollUntil("return ready || null;", [], intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL))213 .setFindTimeout(5000);214 },215 afterEach: function () {216 // Try to make sure that all popups are closed.217 return this.remote218 .findById("stub-for-blurring").click().end();219 },220 tests: tests221 }222 });...

Full Screen

Full Screen

on.js

Source:on.js Github

copy

Full Screen

...27 "keydown, keyup": function () {28 if (this.remote.environmentType.brokenSendKeys || !this.remote.environmentType.nativeEvents) {29 return this.skip("no keyboard support");30 }31 return this.remote.execute("document.getElementById('key').focus();")32 .pressKeys(keys.ARROW_DOWN)33 .execute("return keydown_log.value;").then(function (log) {34 assert.strictEqual(log, "ArrowDown");35 })36 .execute("return keyup_log.value;").then(function (log) {37 assert.strictEqual(log, "ArrowDown");38 })39 .pressKeys(keys.TAB)40 .execute("return keydown_log.value;").then(function (log) {41 assert.strictEqual(log, "Tab");42 })43 .execute("return keyup_log.value;").then(function (log) {44 assert.strictEqual(log, "Tab");45 })46 .pressKeys(keys.ESCAPE)47 .execute("return keydown_log.value;").then(function (log) {48 assert.strictEqual(log, "Escape");49 })50 .pressKeys(" ")51 .execute("return keydown_log.value;").then(function (log) {52 assert.strictEqual(log, "Spacebar");53 })54 .execute("return keyup_log.value;").then(function (log) {55 assert.strictEqual(log, "Spacebar");56 })57 .pressKeys(keys.BACKSPACE)58 .execute("return keydown_log.value;").then(function (log) {59 assert.strictEqual(log, "Backspace");60 })61 .pressKeys(keys.ENTER)62 .execute("return keydown_log.value;").then(function (log) {63 assert.strictEqual(log, "Enter");64 })65 .pressKeys("a")66 .execute("return keydown_log.value;").then(function (log) {67 assert.strictEqual(log, "a");68 })69 .pressKeys("z")70 .execute("return keyup_log.value;").then(function (log) {71 assert.strictEqual(log, "z");72 })73 .pressKeys("A")74 .execute("return keydown_log.value;").then(function (log) {75 assert.strictEqual(log, "A");76 })77 .pressKeys("Z")78 .execute("return keydown_log.value;").then(function (log) {79 assert.strictEqual(log, "Z");80 })81 .pressKeys("5")82 .execute("return keyup_log.value;").then(function (log) {83 assert.strictEqual(log, "5");84 });85 },86 "keypress": function () {87 if (this.remote.environmentType.brokenSendKeys || !this.remote.environmentType.nativeEvents) {88 return this.skip("no keyboard support");89 }90 if (this.remote.environmentType.browserName === "chrome") {91 return this.skip("chrome webdriver doesn't generate keypress events when typing");92 }93 return this.remote.execute("keypress.focus();")94 .pressKeys("a")95 .execute("return keypress_log.value;").then(function (log) {96 assert.strictEqual(log, "a");97 })98 .pressKeys("z")99 .execute("return keypress_log.value;").then(function (log) {100 assert.strictEqual(log, "z");101 })102 .pressKeys("A")103 .execute("return keypress_log.value;").then(function (log) {104 assert.strictEqual(log, "A");105 })106 .pressKeys("Z")107 .execute("return keypress_log.value;").then(function (log) {...

Full Screen

Full Screen

DojoParser.js

Source:DojoParser.js Github

copy

Full Screen

1define([], function () {2 var registerSuite = intern.getPlugin("interface.object").registerSuite;3 var assert = intern.getPlugin("chai").assert;4 var pollUntil = requirejs.nodeRequire("@theintern/leadfoot/helpers/pollUntil").default;5 registerSuite("delite/dojo parser compatibility test", {6 before: function () {7 return this.remote8 .get("delite/tests/functional/DojoParser.html")9 .then(pollUntil("return (readyDijit && readyDelite) || null;", [],10 intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL));11 },12 tests: {13 "Dijit widgets": {14 "declarative dijit widget": function () {15 return this.remote16 .execute("return dijitRegistry.byId('dijitcalendardeclarative').id").then(function (value) {17 assert.strictEqual(value, "dijitcalendardeclarative", "declarative dijit widget exists");18 });19 },20 "programmatic dijit widget": function () {21 return this.remote22 .execute("return dijitRegistry.byId('dijitprogrammaticid').id").then(function (value) {23 assert.strictEqual(value, "dijitprogrammaticid", "programmatic dijit widget exists");24 });25 },26 "all dijit widgets exist": function () {27 return this.remote28 .execute("return dojoWidgetsLength").then(function (value) {29 assert.strictEqual(value, 2, "2 dijit widgets exist");30 });31 }32 },33 "Custom elements": {34 "programmatic custom element": function () {35 return this.remote36 .execute("return typeof(document.getElementById('simplewidget').initializeRendering)")37 .then(function (value) {38 assert.strictEqual(value, "function", "simplewidget is a delite custom element");39 });40 },41 "declarative custom element": function () {42 return this.remote43 .execute("return typeof(document.getElementById('declarativecustomelement').initializeRendering)")44 .then(function (value) {45 assert.strictEqual(value, "function",46 "declarativecustomelement is a delite custom element");47 });48 }49 }50 }51 });...

Full Screen

Full Screen

FormValueWidget.js

Source:FormValueWidget.js Github

copy

Full Screen

...9 .then(pollUntil("return ready || null;", [], intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL));10 },11 tests: {12 creation: function () {13 return this.remote.execute("return spinner1.value").then(function (value) {14 assert.equal(value, 5, "original value"); // taken from the embedded <input>15 }).execute("return spinner1.name").then(function (name) {16 assert.strictEqual(name, "spinner1_name", "name");17 });18 },19 reset: function () {20 return this.remote.findByCssSelector("my-spinner .increment")21 .click()22 .end()23 .execute("return spinner1.value").then(function (value) {24 assert.equal(value, 6, "incremented value"); // use equal() to ignore string vs. number diff25 })26 .findByCssSelector("#resetB")27 .click()...

Full Screen

Full Screen

register.js

Source:register.js Github

copy

Full Screen

1define([], function () {2 var registerSuite = intern.getPlugin("interface.object").registerSuite;3 var assert = intern.getPlugin("chai").assert;4 var pollUntil = requirejs.nodeRequire("@theintern/leadfoot/helpers/pollUntil").default;5 registerSuite("register functional tests", {6 before: function () {7 return this.remote8 .get("delite/tests/functional/register.html")9 .then(pollUntil("return ready || null;", [], intern.config.WAIT_TIMEOUT, intern.config.POLL_INTERVAL));10 },11 tests: {12 "custom element created": function () {13 return this.remote14 .execute(function () {15 return document.getElementById("myCustomElement")._constructorCalled;16 }).then(function (value) {17 assert(value, "custom element created");18 })19 .execute(function () {20 return document.getElementById("myCustomElement")._connectedCallbackCalled;21 }).then(function (value) {22 assert(value, "custom element attached");23 });24 }25 }26 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var remote = require('selenium-webdriver/remote');3var driver = new webdriver.Builder()4 .forBrowser('safari')5 .build();6driver.getSession().then(function(session) {7 driver.execute('mobile: executeCommand', {8 args: {bundleId: 'com.apple.mobilesafari'}9 });10});11driver.getSession().then(function(session) {12 driver.execute('mobile: executeCommand', {13 args: {bundleId: 'com.apple.mobilesafari'}14 });15});16driver.getSession().then(function(session) {17 driver.execute('mobile: executeCommand', {18 args: {bundleId: 'com.apple.mobilesafari'}19 });20});21driver.getSession().then(function(session) {22 driver.execute('mobile: executeCommand', {23 args: {appPath: '/Users/username/Downloads/MyApp.app'}24 });25});26driver.getSession().then(function(session) {27 driver.execute('mobile: executeCommand', {28 args: {bundleId: 'com.apple.mobilesafari'}29 });30});31driver.getSession().then(function(session) {32 driver.execute('mobile: executeCommand', {33 args: {bundleId: 'com.apple.mobilesafari'}34 });35});36driver.getSession().then(function(session) {37 driver.execute('mobile: executeCommand', {38 args: {bundleId: 'com.apple.mobilesafari'}39 });40});41driver.getSession().then(function(session) {42 driver.execute('mobile: executeCommand', {43 args: {}44 });45});46driver.getSession().then(function(session) {47 driver.execute('mobile: executeCommand', {48 args: {action: 'search'}49 });50});51driver.getSession().then(function(session) {52 driver.execute('mobile: executeCommand', {53 args: {action: 'search', actionKey: 'search'}54 });55});56driver.getSession().then(function(session)

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .end();9client.then(function() {10 console.log('done');11}).catch(function(err) {12 console.log(err);13});14client.execute('mobile: swipe', {direction: 'down'}).then(function() {15 console.log('done');16}).catch(function(err) {17 console.log(err);18});19Error: Protocol error (mobile: swipe): POST /wd/hub/session/7b2a4c4c-4e93-4c3f-a5c5-5e8b5a5f0b7d/execute/sync did not match a known command20client.execute(function() {21 var target = UIATarget.localTarget();22 var app = target.frontMostApp();23 var window = app.mainWindow();24 window.swipeDown();25});26client.execute('mobile: swipe', {direction: 'down', element: ''}).then(function() {27 console.log('done');28}).catch(function(err) {29 console.log(err);30});31Error: Protocol error (mobile: swipe): POST /wd/hub/session/7b2a4c4c-4e93-4c3f-a5c5-5e8b5a5f0b7d/execute/sync did not match a known command32client.execute(function() {33 var target = UIATarget.localTarget();34 var app = target.frontMostApp();35 var window = app.mainWindow();36 window.swipeDown();37 return window;

Full Screen

Using AI Code Generation

copy

Full Screen

1const webdriverio = require('webdriverio');2const options = {3 desiredCapabilities: {4 }5};6const client = webdriverio.remote(options);7 .init()8 .execute('mobile: alert', {action: 'accept'})9 .end();10const webdriverio = require('webdriverio');11const options = {12 desiredCapabilities: {13 }14};15const client = webdriverio.remote(options);16 .init()17 .execute('mobile: alert', {action: 'accept'})18 .end();19const webdriverio = require('webdriverio');20const options = {21 desiredCapabilities: {22 }23};24const client = webdriverio.remote(options);25 .init()26 .execute('mobile: alert', {action: 'accept'})27 .end();28const webdriverio = require('webdriverio');29const options = {30 desiredCapabilities: {31 }32};33const client = webdriverio.remote(options);34 .init()35 .execute('mobile: alert', {action: 'accept'})36 .end();37const webdriverio = require('webdriverio');38const options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should work', function() {3 .execute(function() {4 return 'Hello';5 })6 .then(function(result) {7 });8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6chaiAsPromised.transferPromiseness = wd.transferPromiseness;

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { XCUITestDriver } = require('appium-xcuitest-driver');3const caps = {4};5 .init(caps)6 .then(() => {7 return driver.execute('mobile: executeCommand', {8 args: {9 },10 });11 })12 .then((res) => {13 console.log(res);14 })15 .catch((err) => {16 console.log(err);17 });18const wd = require('wd');19const { XCUITestDriver } = require('appium-xcuitest-driver');20const caps = {21};22 .init(caps)23 .then(() => {24 return driver.execute('mobile: executeCommand', {25 args: {26 },27 });28 })29 .then((res) => {30 console.log(res);31 })32 .catch((err) => {33 console.log(err);34 });35const wd = require('wd');36const { XCUITestDriver } = require('appium-xcuitest-driver');37const caps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to execute remote commands', function() {2 it('should execute remote commands', function() {3 .execute('mobile: alert', {action: 'accept'});4 });5});6describe('Test to execute remote commands', function() {7 it('should execute remote commands', function() {8 .execute('mobile: alert', {action: 'accept'});9 });10});11describe('Test to execute remote commands', function() {12 it('should execute remote commands', function() {13 .execute('mobile: alert', {action: 'accept'});14 });15});16describe('Test to execute remote commands', function() {17 it('should execute remote commands', function() {18 .execute('mobile: currentActivity', {});19 });20});21describe('Test to execute remote commands', function() {22 it('should execute remote commands', function() {23 .execute('mobile: currentActivity', {});24 });25});26describe('Test to execute remote commands', function() {27 it('should execute remote commands', function() {28 .execute('mobile: currentActivity', {});29 });30});31describe('Test to execute remote commands', function() {32 it('should execute remote commands', function() {33 .execute('mobile: currentActivity', {});34 });35});36describe('Test to execute remote

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

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful