How to use saveScreenshot method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

when.js

Source:when.js Github

copy

Full Screen

...63 browser64 .element(`${fileutils.readPropertyFile(platform, object)}`)65 .click();66 console.log(`Clicked on ${object}`);67 ////browser.saveScreenshot();68 }69 browser.pause(2000);70 break;71 case "ios":72 const exists = browser.waitUntil(73 () =>74 browser75 .element(`${fileutils.readPropertyFile(platform, object)}`)76 .isVisible(),77 timeOutinMs,78 "Element not found"79 );80 if (exists) {81 browser82 .element(`${fileutils.readPropertyFile(platform, object)}`)83 .click();84 console.log(`Clicked on ${object}`);85 ////browser.saveScreenshot();86 }87 break;88 case "web":89 // perform operation on web element90 break;91 default:92 break;93 }94 } catch (e) {95 console.error(` Cannot click on ${object}${e}`);96 //browser.saveScreenshot();97 return assert.strictEqual(platform, "", e);98 }99 }100);101When(/^I tap "([^"]*)" (?:view|checkbox)$/, async object => {102 try {103 switch (platform) {104 case "android":105 const exists1 = browser.waitUntil(106 () =>107 browser108 .element(`${fileutils.readPropertyFile(platform, object)}`)109 .click(),110 timeOutinMs,111 "Element not found"112 );113 if (exists1) {114 if (object.indexOf("checkbox") == -1) {115 let object1 = object + ".checkbox";116 let element1 = browser.element(117 `${fileutils.readPropertyFile(platform, object1)}`118 );119 if (element1.getAttribute("checked") == "true") {120 element1.click();121 console.log(`Clicked on ${object1} and is deselected`);122 } else {123 element1.click();124 console.log(`Clicked on ${object} and is selected`);125 }126 } else {127 let element = browser.element(128 `${fileutils.readPropertyFile(platform, object)}`129 );130 if (element.getAttribute("checked") == "true") {131 element.click();132 console.log(`Clicked on ${object} and is deselected`);133 } else {134 element.click();135 console.log(`Clicked on ${object} and is selected`);136 }137 }138 ////browser.saveScreenshot();139 }140 break;141 case "ios":142 const exists = browser.waitUntil(143 () =>144 browser145 .element(`${fileutils.readPropertyFile(platform, object)}`)146 .click(),147 timeOutinMs,148 "Element not found"149 );150 if (exists) {151 if (object.indexOf("checkbox") == -1) {152 let object1 = object + ".checkbox";153 let element1 = browser.element(154 `${fileutils.readPropertyFile(platform, object1)}`155 );156 if (element1.getAttribute("value") == 1) {157 element1.click();158 console.log(`Clicked on ${object1} and is deselected`);159 } else {160 element1.click();161 console.log(`Clicked on ${object} and is selected`);162 }163 } else {164 let element = browser.element(165 `${fileutils.readPropertyFile(platform, object)}`166 );167 if (element.getAttribute("value") == 1) {168 element.click();169 console.log(`Clicked on ${object} and is deselected`);170 } else {171 element.click();172 console.log(`Clicked on ${object} and is selected`);173 }174 }175 ////browser.saveScreenshot();176 }177 break;178 case "web":179 // perform operation on web element180 break;181 default:182 break;183 }184 } catch (e) {185 console.error(` Cannot click on ${object} checkbox`);186 //browser.saveScreenshot();187 return assert.strictEqual(platform, "", e);188 }189});190When(/^I tap "([^"]*)"$/, async object => {191 try {192 switch (platform) {193 case "android":194 const exists1 = browser.waitUntil(195 () =>196 browser197 .element(`${fileutils.readPropertyFile(platform, object)}`)198 .isVisible(),199 timeOutinMs,200 "Element not found"201 );202 if (exists1) {203 browser204 .element(`${fileutils.readPropertyFile(platform, object)}`)205 .click();206 console.log(`Clicked on ${object}`);207 ////browser.saveScreenshot();208 }209 browser.pause(2000);210 break;211 case "ios":212 const exists = browser.waitUntil(213 () =>214 browser215 .element(`${fileutils.readPropertyFile(platform, object)}`)216 .isVisible(),217 timeOutinMs,218 "Element not found"219 );220 let element = browser.element(221 `${fileutils.readPropertyFile(platform, object)}`222 );223 if (exists) {224 element.click();225 console.log(`Clicked on ${object}`);226 }227 break;228 case "web":229 // perform operation on web element230 break;231 default:232 break;233 }234 } catch (e) {235 console.error(` Cannot click on ${object}`);236 //browser.saveScreenshot();237 return assert.strictEqual(platform, "", e);238 }239});240When(/^I enter "([^"]*)"$/, async object => {241 try {242 switch (platform) {243 case "android":244 browser.pause(1000);245 expect(246 browser.element(`${fileutils.readPropertyFile(platform, object)}`)247 .isExisting248 );249 browser.setValue(250 fileutils.readPropertyFile(platform, object),251 fileutils.readPropertyFile("data", object)252 );253 console.log(`Entered value to ${object} field`);254 ////browser.saveScreenshot();255 break;256 case "ios":257 const exists = browser.waitUntil(258 () =>259 browser260 .element(`${fileutils.readPropertyFile(platform, object)}`)261 .isVisible(),262 timeOutinMs,263 "Error: Element not found"264 );265 if (exists) {266 mobileElementAction.clearTextBox(267 `${fileutils.readPropertyFile(platform, object)}`268 );269 if (object === "Email") {270 browser271 .element(`${fileutils.readPropertyFile(platform, object)}`)272 .setValue(fileutils.readMobileCaps()[0].Email);273 console.log(`Entered value to ${object} field`);274 mobileElementAction.tapOutsideElement();275 ////browser.saveScreenshot();276 } else if (object === "Password") {277 browser278 .element(`${fileutils.readPropertyFile(platform, object)}`)279 .setValue(fileutils.readMobileCaps()[0].Password);280 console.log(`Entered value to ${object} field`);281 mobileElementAction.tapOutsideElement();282 ////browser.saveScreenshot();283 }284 }285 break;286 case "web":287 // perform operation on web element288 break;289 default:290 break;291 }292 } catch (e) {293 console.error(` Cannot Enter ${object}\n${e}`);294 //browser.saveScreenshot();295 return assert.strictEqual(platform, "", e);296 }297});298When(/^I enter "([^"]*)" into "([^"]*)" field$/, async (value, object) => {299 try {300 switch (platform) {301 case "android":302 const exists1 = browser.waitUntil(303 () => {304 const xpathcheck = fileutils.readPropertyFile(platform, object);305 if (xpathcheck.startsWith("/") || xpathcheck.startsWith("//")) {306 return $(307 fileutils.readPropertyFile(platform, object)308 ).isVisible();309 }310 return browser311 .element(`${fileutils.readPropertyFile(platform, object)}`)312 .isVisible();313 },314 timeOutinMs,315 "Error: Element not found"316 );317 if (exists1) {318 let val = `${fileutils.readPropertyFile("data", value)}`;319 browser320 .element(`${fileutils.readPropertyFile(platform, object)}`)321 .click();322 browser.clearElement(323 `${fileutils.readPropertyFile(platform, object)}`324 );325 browser326 .element(`${fileutils.readPropertyFile(platform, object)}`)327 .setValue(val);328 console.log(`Entered ${value} to ${object} field`);329 mobileactions.hideDeviceKeyboard();330 browser.pause(1000);331 ////browser.saveScreenshot();332 }333 break;334 case "ios":335 const exists = browser.waitUntil(336 () => {337 const xpathcheck = fileutils.readPropertyFile(platform, object);338 if (xpathcheck.startsWith("/") || xpathcheck.startsWith("//")) {339 return $(340 fileutils.readPropertyFile(platform, object)341 ).isVisible();342 }343 return browser344 .element(`${fileutils.readPropertyFile(platform, object)}`)345 .isVisible();346 },347 timeOutinMs,348 "Error: Element not found"349 );350 if (exists) {351 let val = `${fileutils.readPropertyFile("data", value)}`;352 if (object === "mg.dl.logbook") {353 browser354 .element(`${fileutils.readPropertyFile(platform, object)}`)355 .click();356 browser.clearElement(357 `${fileutils.readPropertyFile(platform, object)}`358 );359 browser360 .element(`${fileutils.readPropertyFile(platform, object)}`)361 .setValue(val);362 console.log(363 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`364 );365 ////browser.saveScreenshot();366 } else if (object === "blood.sugar.mg.dl") {367 browser368 .element(`${fileutils.readPropertyFile(platform, object)}`)369 .click();370 browser.clearElement(371 `${fileutils.readPropertyFile(platform, object)}`372 );373 browser374 .element(`${fileutils.readPropertyFile(platform, object)}`)375 .setValue(val);376 console.log(377 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`378 );379 ////browser.saveScreenshot();380 } else if (object === "carb.intake.grams") {381 browser382 .element(`${fileutils.readPropertyFile(platform, object)}`)383 .click();384 browser.clearElement(385 `${fileutils.readPropertyFile(platform, object)}`386 );387 browser388 .element(`${fileutils.readPropertyFile(platform, object)}`)389 .setValue(val);390 console.log(391 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`392 );393 ////browser.saveScreenshot();394 } else if (object === "edit.carb.intake.grams") {395 browser396 .element(`${fileutils.readPropertyFile(platform, object)}`)397 .click();398 browser.clearElement(399 `${fileutils.readPropertyFile(platform, object)}`400 );401 browser402 .element(`${fileutils.readPropertyFile(platform, object)}`)403 .setValue(val);404 console.log(405 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`406 );407 ////browser.saveScreenshot();408 } else if (object === "units") {409 browser410 .element(`${fileutils.readPropertyFile(platform, object)}`)411 .click();412 browser.clearElement(413 `${fileutils.readPropertyFile(platform, object)}`414 );415 browser416 .element(`${fileutils.readPropertyFile(platform, object)}`)417 .setValue(val);418 console.log(419 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`420 );421 ////browser.saveScreenshot();422 } else if (object === "longacting.units") {423 browser424 .element(`${fileutils.readPropertyFile(platform, object)}`)425 .click();426 browser.clearElement(427 `${fileutils.readPropertyFile(platform, object)}`428 );429 browser430 .element(`${fileutils.readPropertyFile(platform, object)}`)431 .setValue(val);432 console.log(433 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`434 );435 ////browser.saveScreenshot();436 } else if (object === "mealtime.units") {437 browser438 .element(`${fileutils.readPropertyFile(platform, object)}`)439 .click();440 browser.clearElement(441 `${fileutils.readPropertyFile(platform, object)}`442 );443 browser444 .element(`${fileutils.readPropertyFile(platform, object)}`)445 .setValue(val);446 console.log(447 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`448 );449 ////browser.saveScreenshot();450 } else if (object === "grams") {451 browser452 .element(`${fileutils.readPropertyFile(platform, object)}`)453 .click();454 browser.clearElement(455 `${fileutils.readPropertyFile(platform, object)}`456 );457 browser458 .element(`${fileutils.readPropertyFile(platform, object)}`)459 .setValue(val);460 console.log(461 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`462 );463 ////browser.saveScreenshot();464 } else if (object === "manual.mealtime.units") {465 browser466 .element(`${fileutils.readPropertyFile(platform, object)}`)467 .click();468 browser.clearElement(469 `${fileutils.readPropertyFile(platform, object)}`470 );471 browser472 .element(`${fileutils.readPropertyFile(platform, object)}`)473 .setValue(val);474 console.log(475 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`476 );477 ////browser.saveScreenshot();478 } else if (object === "manual.long-acting.units") {479 browser480 .element(`${fileutils.readPropertyFile(platform, object)}`)481 .click();482 browser.clearElement(483 `${fileutils.readPropertyFile(platform, object)}`484 );485 browser486 .element(`${fileutils.readPropertyFile(platform, object)}`)487 .setValue(val);488 console.log(489 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`490 );491 ////browser.saveScreenshot();492 } else if (object === "manual.carb.intake.grams") {493 browser494 .element(`${fileutils.readPropertyFile(platform, object)}`)495 .click();496 browser.clearElement(497 `${fileutils.readPropertyFile(platform, object)}`498 );499 browser500 .element(`${fileutils.readPropertyFile(platform, object)}`)501 .setValue(val);502 console.log(503 ` ${fileutils.readPropertyFile("data", value)} in ${object} field`504 );505 ////browser.saveScreenshot();506 } else {507 browser508 .element(`${fileutils.readPropertyFile(platform, object)}`)509 .click();510 browser.clearElement(511 `${fileutils.readPropertyFile(platform, object)}`512 );513 browser514 .element(`${fileutils.readPropertyFile(platform, object)}`)515 .setValue(val);516 console.log(517 `Entered ${fileutils.readPropertyFile(518 "data",519 value520 )} to ${object} field`521 );522 mobileactions.hideDeviceKeyboardIOS();523 ////browser.saveScreenshot();524 }525 }526 break;527 case "web":528 // perform operation on web element529 break;530 default:531 break;532 }533 } catch (e) {534 console.error(` Cannot enter ${object}\n${e}`);535 //browser.saveScreenshot();536 return assert.strictEqual(platform, "", e);537 }538});539When(/^I swipe down$/, async () => {540 try {541 switch (platform) {542 case "android":543 // android operation544 mobileactions.swipeDown(0.85);545 ////browser.saveScreenshot();546 break;547 case "ios":548 mobileactions.swipeDown(0.85);549 ////browser.saveScreenshot();550 break;551 case "web":552 // perform operation on web element553 break;554 default:555 break;556 }557 } catch (e) {558 console.error(` Cannot swipe ${e}`);559 //browser.saveScreenshot();560 return assert.strictEqual(platform, "", e);561 }562});563When(/^I swipe up$/, async () => {564 try {565 switch (platform) {566 case "android":567 mobileactions.swipeUp(0.85);568 ////browser.saveScreenshot();569 break;570 case "ios":571 mobileactions.swipeUp(0.85);572 ////browser.saveScreenshot();573 break;574 case "web":575 // perform operation on web element576 break;577 default:578 break;579 }580 } catch (e) {581 console.error(` Cannot swipe ${e}`);582 //browser.saveScreenshot();583 return assert.strictEqual(platform, "", e);584 }585});586When(/^I swipe left$/, async () => {587 try {588 switch (platform) {589 case "android":590 mobileactions.swipeLeft(0.85);591 ////browser.saveScreenshot();592 break;593 case "ios":594 browser.pause(3000);595 mobileactions.swipeLeft(0.85);596 ////browser.saveScreenshot();597 break;598 case "web":599 // perform operation on web element600 break;601 default:602 break;603 }604 } catch (e) {605 console.error(` Cannot swipe ${e}`);606 //browser.saveScreenshot();607 return assert.strictEqual(platform, "", e);608 }609});610When(/^I swipe right$/, async () => {611 try {612 switch (platform) {613 case "android":614 mobileactions.swipeRight(0.85);615 ////browser.saveScreenshot();616 break;617 case "ios":618 browser.pause(3000);619 mobileactions.swipeRight(0.85);620 ////browser.saveScreenshot();621 break;622 case "web":623 // perform operation on web element624 break;625 default:626 break;627 }628 } catch (e) {629 console.error(` Cannot swipe ${e}`);630 //browser.saveScreenshot();631 return assert.strictEqual(platform, "", e);632 }633});634When(/^I swipe up the intensity scale$/, async () => {635 try {636 switch (platform) {637 case "android":638 break;639 case "ios":640 mobileactions.mobileScroll("down");641 ////browser.saveScreenshot();642 break;643 case "web":644 // perform operation on web element645 break;646 default:647 break;648 }649 } catch (e) {650 console.error(` Cannot swipe ${e}`);651 //browser.saveScreenshot();652 return assert.strictEqual(platform, "", e);653 }654});655When(656 /^I should see "([^"]*)" (?:CTA|message|alertdescription|toastmessage|alertheader|link|field|hyperlink)$/,657 async object => {658 try {659 switch (platform) {660 case "android":661 expect(662 browser.element(`${fileutils.readPropertyFile(platform, object)}`)663 .isExisting664 );665 console.log(`${object} is visible`);666 ////browser.saveScreenshot();667 break;668 case "ios":669 const exists = browser.waitUntil(670 () =>671 browser672 .element(`${fileutils.readPropertyFile(platform, object)}`)673 .isVisible(),674 timeOutinMs,675 "Error: Element not found"676 );677 if (exists) {678 console.log(679 `${object} is visible : message displayed: ${mobileElementAction.getElementText(680 browser.element(681 `${fileutils.readPropertyFile(platform, object)}`682 )683 )}`684 );685 ////browser.saveScreenshot();686 }687 break;688 case "web":689 // perform operation on web element690 break;691 default:692 break;693 }694 } catch (e) {695 console.error(` Cannot find ${object}`);696 //browser.saveScreenshot();697 return assert.strictEqual(platform, "", e);698 }699 }700);701When(/^I tap on "([^"]*)" using coordinates$/, async object => {702 try {703 switch (platform) {704 case "android":705 // perform operation on android element706 break;707 case "ios":708 if (object === "SelectDOB") {709 mobileElementAction.tapByCoord(34, 235);710 break;711 } else if (object === "Done") {712 mobileElementAction.tapByCoord(36, 427);713 } else {714 console.log(715 "Unable to click on the",716 `${object}`,717 "for the coordinates given"718 );719 }720 break;721 case "web":722 // perform operation on web element723 break;724 default:725 break;726 }727 } catch (e) {728 console.error(` Cannot click on ${object}`);729 //browser.saveScreenshot();730 return assert.strictEqual(platform, "", e);731 }732});733/*734When statements to enter valid text for First name, Last name, Email Id, and Password ---->735*/736When(/^I enter "([^"]*)" into "([^"]*)" textbox$/, async (value, object) => {737 try {738 switch (platform) {739 case "android":740 // Perform for Android741 break;742 case "ios":743 let val = value;744 if (object === "FirstName") {745 const FirstNameRegex = new RegExp(regex.FirstNameandLastName);746 val = FirstName;747 if (FirstNameRegex.test(val)) {748 browser749 .element(`${fileutils.readPropertyFile(platform, object)}`)750 .click();751 browser752 .element(`${fileutils.readPropertyFile(platform, object)}`)753 .setValue(val);754 ////browser.saveScreenshot();755 } else {756 console.error("Unable to perform on ", `${object}`);757 }758 } else if (object === "LastName") {759 const LastNameRegex = new RegExp(regex.FirstNameandLastName);760 val = LastName;761 if (LastNameRegex.test(val)) {762 browser763 .element(`${fileutils.readPropertyFile(platform, object)}`)764 .click();765 browser766 .element(`${fileutils.readPropertyFile(platform, object)}`)767 .setValue(val);768 ////browser.saveScreenshot();769 } else {770 console.error("Unable to perform on", `${object}`);771 }772 } else if (object === "Email_Address") {773 const EmailIDRegex = new RegExp(regex.EmailAddress);774 val = EmailAddress;775 if (EmailIDRegex.test(value)) {776 mobileElementAction.clearTextBox(777 `${fileutils.readPropertyFile(platform, object)}`778 );779 browser780 .element(`${fileutils.readPropertyFile(platform, object)}`)781 .setValue(EmailAddress);782 ////browser.saveScreenshot();783 } else {784 console.error("Unable to perform on", `${object}`);785 }786 } else if (object === "ChoosePassword") {787 // Regex for password is same as of First Name and Last Name story ( VEGA - 90 ).788 // There is no separate password regex to verify789 const PasswordRegex = new RegExp(regex.FirstNameandLastName);790 if (PasswordRegex.test(ChoosePassword)) {791 browser792 .element(`${fileutils.readPropertyFile(platform, object)}`)793 .click();794 browser795 .element(`${fileutils.readPropertyFile(platform, object)}`)796 .setValue(ChoosePassword);797 ////browser.saveScreenshot();798 } else {799 console.error("Unable to perform on", `${object}`);800 }801 }802 break;803 case "web":804 break;805 default:806 break;807 }808 } catch (e) {809 console.error("Cannot Enter", `${object}`);810 //browser.saveScreenshot();811 return assert.strictEqual(platform, "", e);812 }813});814/*815When statement to capture the invalid text for First name, Last name, Email Id, and Password ---->816*/817When(/^I enter invalid text in "([^"]*)" textbox$/, async object => {818 try {819 switch (platform) {820 case "android":821 // Perform for Android822 break;823 case "ios":824 browser825 .element(`${fileutils.readPropertyFile(platform, object)}`)826 .click();827 browser828 .element(`${fileutils.readPropertyFile(platform, object)}`)829 .setValue(new RandExp(/[0-9]{6}/).gen());830 ////browser.saveScreenshot();831 break;832 case "web":833 break;834 default:835 break;836 }837 } catch (e) {838 console.error(` Cannot enter ${object}`);839 //browser.saveScreenshot();840 return assert.strictEqual(platform, "", e);841 }842});843When(844 /^I enter invalid text with numbers in the "([^"]*)" textbox$/,845 async object => {846 try {847 switch (platform) {848 case "android":849 // Perform for Android850 break;851 case "ios":852 browser853 .element(`${fileutils.readPropertyFile(platform, object)}`)854 .click();855 browser856 .element(`${fileutils.readPropertyFile(platform, object)}`)857 .setValue(new RandExp(/[a-zA-Z]{4}[0-9]{2}/).gen());858 ////browser.saveScreenshot();859 break;860 default:861 break;862 }863 } catch (e) {864 console.error(` Cannot click on ${object}`);865 //browser.saveScreenshot();866 return assert.strictEqual(platform, "", e);867 }868 }869);870When(/^I enter alphabets only in "([^"]*)" textbox$/, async object => {871 try {872 switch (platform) {873 case "android":874 // Perform for Android875 break;876 case "ios":877 browser878 .element(`${fileutils.readPropertyFile(platform, object)}`)879 .click();880 browser881 .element(`${fileutils.readPropertyFile(platform, object)}`)882 .setValue(new RandExp(/[a-z]{6}/).gen());883 ////browser.saveScreenshot();884 break;885 case "web":886 break;887 default:888 break;889 }890 } catch (e) {891 console.error(` Cannot click on ${object}`);892 //browser.saveScreenshot();893 return assert.strictEqual(platform, "", e);894 }895});896/*897And statements to select day, year, and month ---->898*/899When(/^I select "([^"]*)"$/, async object => {900 try {901 switch (platform) {902 case "android":903 if (object === "year") {904 let reqYear = `${fileutils.readPropertyFile("data", object)}`;905 let selectYear = browser.getText(906 fileutils.readPropertyFile(platform, "required.year")907 );908 while (selectYear.indexOf(reqYear) == -1) {909 mobileactions.swipe_up("datepicker.screen");910 selectYear = browser.getText(911 fileutils.readPropertyFile(platform, "required.year")912 );913 }914 let selYear = fileutils915 .readPropertyFile(platform, "select.year")916 .replace("2019", reqYear);917 browser.element(selYear).click();918 } else if (object === "month") {919 let month = browser.getAttribute(920 fileutils.readPropertyFile(platform, "month.text"),921 "content-desc"922 );923 let reqMonth = `${fileutils.readPropertyFile("data", object)}`;924 while (month.split(" ")[1] != reqMonth) {925 browser926 .element(fileutils.readPropertyFile(platform, "previous.month"))927 .click();928 month = browser.getAttribute(929 fileutils.readPropertyFile(platform, "month.text"),930 "content-desc"931 );932 }933 } else if (object === "date") {934 let reqDate = `${fileutils.readPropertyFile("data", object)}`;935 let selDate = fileutils936 .readPropertyFile(platform, object)937 .replace("10", reqDate);938 browser.element(selDate).click();939 } else {940 console.log(object + "not found");941 }942 break;943 case "ios":944 let exists = browser.waitUntil(945 function() {946 return browser947 .element(fileutils.readPropertyFile(platform, object))948 .click();949 },950 timeOutinMs,951 "Element not found"952 );953 if (exists) {954 console.log("Clicked on " + object);955 ////browser.saveScreenshot();956 if (object === "year") {957 mobileElementAction.selectValueFromPicker(958 fileutils.readPropertyFile(platform, object),959 fileutils.readPropertyFile("data", object)960 );961 } else if (object === "month") {962 mobileElementAction.selectValueFromPicker(963 fileutils.readPropertyFile(platform, object),964 fileutils.readPropertyFile("data", object)965 );966 } else if (object === "date") {967 mobileElementAction.selectValueFromPicker(968 fileutils.readPropertyFile(platform, object),969 fileutils.readPropertyFile("data", object)970 );971 } else {972 console.log(object + "not found");973 }974 }975 break;976 case "web":977 // perform operation on web element978 break;979 }980 } catch (e) {981 console.error(" Cannot Select " + object + e);982 //browser.saveScreenshot();983 return assert.strictEqual(platform, "", e);984 }985});986When(/^I select "([^"]*)" in "([^"]*)" field$/, async (value, object) => {987 try {988 switch (platform) {989 case "android":990 991 let data = `${fileutils.readPropertyFile("data", value)}`;992 if (object === "year") {993 let reqYear;994 if (value == "past.year") {995 reqYear = (new Date().getFullYear() - 1).toString();996 } else if (value == "current.year") {997 reqYear = new Date().getFullYear().toString();998 } else {999 reqYear = `${fileutils.readPropertyFile("data", object)}`;1000 }1001 let selectYear = browser.getText(1002 fileutils.readPropertyFile(platform, "required.year")1003 );1004 while (selectYear.indexOf(reqYear) == -1) {1005 mobileactions.swipe_up("datepicker.screen");1006 selectYear = browser.getText(1007 fileutils.readPropertyFile(platform, "required.year")1008 );1009 }1010 let selYear = fileutils1011 .readPropertyFile(platform, "select.year")1012 .replace("2019", reqYear);1013 browser.element(selYear).click();1014 let curmonth = parseInt(new Date().getMonth() + 1);1015 let curdate = utils.currentDate();1016 pastDate =1017 ("0" + curmonth.toString()).slice(-2) +1018 "/" +1019 curdate.split("-")[2] +1020 "/" +1021 reqYear;1022 console.log(pastDate);1023 } else if (object === "month") {1024 let month = browser.getAttribute(1025 fileutils.readPropertyFile(platform, "month.text"),1026 "content-desc"1027 );1028 let reqMonth = `${fileutils.readPropertyFile("data", object)}`;1029 while (month.split(" ")[1] != reqMonth) {1030 browser1031 .element(fileutils.readPropertyFile(platform, "previous.month"))1032 .click();1033 month = browser.getAttribute(1034 fileutils.readPropertyFile(platform, "month.text"),1035 "content-desc"1036 );1037 }1038 } else if (object === "date") {1039 let reqDate = `${fileutils.readPropertyFile("data", object)}`;1040 let selDate = fileutils1041 .readPropertyFile(platform, object)1042 .replace("10", reqDate);1043 browser.element(selDate).click();1044 } else if (object === "hour") {1045 if (value === "future.time") {1046 let exists1 = browser.waitUntil(1047 function() {1048 return browser1049 .element(fileutils.readPropertyFile(platform, "pm"))1050 .isVisible();1051 },1052 timeOutinMs,1053 "Error: Element not found"1054 );1055 if(exists1)1056 {1057 let finaldata;1058 let timeLog = new Date().getHours() + 1;1059 if (timeLog >= 12) {1060 if (timeLog == 12) {1061 finaldata = timeLog;1062 let PMdata1 = fileutils.readPropertyFile(platform, "pm");1063 $(PMdata1).click();1064 } else {1065 finaldata = timeLog - 12;1066 let PMdata1 = fileutils.readPropertyFile(platform, "pm");1067 $(PMdata1).click();1068 }1069 } else {1070 finaldata = timeLog;1071 let PMdata12 = fileutils.readPropertyFile(platform, "am");1072 $(PMdata12).click();1073 }1074 data = finaldata;1075 }1076 } 1077 1078 else if (value === 'device.future.time') {1079 1080 let time = browser.getDeviceTime();1081 1082 1083 1084 var values = Object.keys(time).map(function(key){1085 return time[key];1086 });1087 1088 1089 1090 let finaldata1091 let timeHour = parseInt(values[0].toString().slice(11,13));1092 let timeLog = timeHour + 1;1093 if (timeLog >= 12) {1094 if(timeLog==12){1095 finaldata = timeLog1096 let PMdata1 = fileutils.readPropertyFile(platform, "pm")1097 $(PMdata1).click();1098 }1099 else{1100 finaldata = timeLog - 121101 let PMdata1 = fileutils.readPropertyFile(platform, "pm")1102 $(PMdata1).click();1103 }1104 }1105 else {1106 finaldata = timeLog1107 let PMdata12 = fileutils.readPropertyFile(platform, "am")1108 $(PMdata12).click();1109 }1110 data = finaldata1111 }1112 1113 1114 1115 else if (value === "future.time.24") {1116 let finaldata = new Date().getHours();1117 data = finaldata + 1;1118 } 1119 1120 else if (value === 'device.future.time.24') {1121 let time = browser.getDeviceTime();1122 var values = Object.keys(time).map(function(key){1123 return time[key];1124 });1125 1126 let finaldata = parseInt(values[0].toString().slice(11,13));1127 data = finaldata + 11128 }1129 1130 1131 1132 else if (value === "past.hour") {1133 let finaldata1;1134 let timeLog1 = new Date().getHours() - 1;1135 if (timeLog1 > 12) {1136 finaldata1 = timeLog1 - 12;1137 } else if (timeLog1 == 12) {1138 finaldata1 = timeLog1;1139 } else {1140 finaldata1 = timeLog1;1141 }1142 data = finaldata1;1143 } 1144 1145 else if (value === 'device.past.hour') {1146 let time = browser.getDeviceTime();1147 var values = Object.keys(time).map(function(key){1148 return time[key];1149 });1150 1151 let finaldata11152 let timeHour = parseInt(values[0].toString().slice(11,13));1153 let timeLog1 = timeHour - 1;1154 if (timeLog1 > 12) {1155 finaldata1 = timeLog1 - 121156 }1157 else if (timeLog1 == 12) {1158 finaldata1 = timeLog11159 }1160 else {1161 finaldata1 = timeLog11162 }1163 data = finaldata11164 }1165 1166 else if (value === "past.hour.24") {1167 let timeLog1 = new Date().getHours() - 1;1168 data = timeLog1;1169 } 1170 1171 else if (value === 'device.past.hour.24') {1172 let time = browser.getDeviceTime();1173 var values = Object.keys(time).map(function(key){1174 return time[key];1175 });1176 let timeHour = parseInt(values[0].toString().slice(11,13));1177 let timeLog1 = timeHour - 1;1178 data = timeLog11179 }1180 1181 1182 else {1183 data = data;1184 }1185 pastHour = data;1186 browser.pause(1000);1187 let hourdata = fileutils1188 .readPropertyFile(platform, object)1189 .replace("9", data);1190 $(hourdata).click();1191 if (value == "past.hour") {1192 if (pastHour >= 12) {1193 let PMdata1 = fileutils.readPropertyFile(platform, "pm");1194 $(PMdata1).click();1195 } else {1196 let PMdata1 = fileutils.readPropertyFile(platform, "am");1197 $(PMdata1).click();1198 }1199 }1200 else if (value== "device.past.hour"){1201 if(pastHour>=12){1202 let PMdata1 = fileutils.readPropertyFile(platform, "pm")1203 $(PMdata1).click();1204 }1205 else{1206 let PMdata1 = fileutils.readPropertyFile(platform, "am")1207 $(PMdata1).click();1208 }1209 }1210 console.log("Selected " + data + " in " + object + " field");1211 ////browser.saveScreenshot();1212 } else if (object === "minutes") {1213 if (value == "past.minutes") {1214 const today = new Date();1215 let minutes = today.getMinutes();1216 if (minutes >= 55) {1217 var minround = Math.floor(minutes / 5) * 5;1218 data = minround.toString();1219 } else {1220 var minround = Math.ceil(minutes / 5) * 5;1221 data = minround.toString();1222 }1223 } 1224 else if (value=='device.past.minutes'){1225 let time = browser.getDeviceTime();1226 var values = Object.keys(time).map(function(key){1227 return time[key];1228 });1229 1230 let minutes=parseInt(values[0].toString().slice(14,16));1231 if(minutes >= 55)1232 {1233 var minround = (Math.floor(minutes/5))*5;1234 data = minround.toString();1235 }1236 else{1237 var minround = (Math.ceil(minutes/5))*5;1238 1239 data = minround.toString();1240 1241 }1242 1243 }1244 1245 1246 else {1247 if (data.indexOf('"') == -1) {1248 data = data;1249 } else {1250 data = `${fileutils.readPropertyFile("data", value)}`1251 .replace(/"/g, "")1252 1253 }1254 }1255 pastMinute = ("00" + data).slice(-2);1256 let minutesdata = fileutils1257 .readPropertyFile(platform, object)1258 .replace("05", data);1259 $(minutesdata).click();1260 console.log("Selected " + data + " in " + object + " field");1261 ////browser.saveScreenshot();1262 } else if (object === "am") {1263 let AMdata = fileutils1264 .readPropertyFile(platform, object)1265 .replace("AM", data);1266 $(AMdata).click();1267 console.log("Selected " + data + " in " + object + " field");1268 } else if (object === "pm") {1269 let PMdata = fileutils1270 .readPropertyFile(platform, object)1271 .replace("PM", data);1272 $(PMdata).click();1273 console.log("Selected " + data + " in " + object + " field");1274 } else if (value === "future.time") {1275 let finaldata = parseInt(1276 browser.getAttribute(1277 fileutils.readPropertyFile(platform, object),1278 "value"1279 )1280 );1281 browser1282 .element(fileutils.readPropertyFile(platform, object))1283 .setValue((finaldata + 1).toString());1284 console.log("Selected " + amPMdata + " in " + object + " field");1285 } else if (value === "future.year") {1286 let finaldata1 = parseInt(1287 browser.getAttribute(1288 fileutils.readPropertyFile(platform, object),1289 "value"1290 )1291 );1292 browser1293 .element(fileutils.readPropertyFile(platform, object))1294 .setValue((finaldata1 + 1).toString());1295 console.log("Selected " + amPMdata + " in " + object + " field");1296 } else if (value === "past.time") {1297 let finaldata2 = parseInt(1298 browser.getAttribute(1299 fileutils.readPropertyFile(platform, object),1300 "value"1301 )1302 );1303 browser1304 .element(fileutils.readPropertyFile(platform, object))1305 .setValue((finaldata2 - 1).toString());1306 console.log("Selected " + amPMdata + " in " + object + " field");1307 } else if (value === "current.year") {1308 let finaldata2 = parseInt(1309 browser.getAttribute(1310 fileutils.readPropertyFile(platform, object),1311 "value"1312 )1313 );1314 browser1315 .element(fileutils.readPropertyFile(platform, object))1316 .setValue((finaldata2 - 1).toString());1317 console.log("Selected " + amPMdata + " in " + object + " field");1318 } else {1319 console.log(object + "not found");1320 }1321 1322 break;1323 case "ios":1324 let data1 = `${fileutils.readPropertyFile("data", value)}`;1325 let exists = browser.waitUntil(1326 function() {1327 return browser1328 .element(fileutils.readPropertyFile(platform, object))1329 .isVisible();1330 },1331 timeOutinMs,1332 "Element not found"1333 );1334 if (exists) {1335 if (value === "future.time") {1336 let finaldata;1337 let timeLog = new Date().getHours()+1;1338 if (timeLog > 12) {1339 finaldata = timeLog - 12;1340 mobileElementAction.selectValueFromPicker(1341 fileutils.readPropertyFile(platform, object),1342 finaldata1343 );1344 console.log(1345 "Selected " + (finaldata) + " in " + object + " field"1346 );1347 let PMdata1 = fileutils.readPropertyFile(platform, "am.pm");1348 mobileElementAction.selectValueFromPicker(PMdata1, "PM");1349 }1350 else if (timeLog == 12) {1351 finaldata = timeLog;1352 mobileElementAction.selectValueFromPicker(1353 fileutils.readPropertyFile(platform, object),1354 finaldata1355 );1356 console.log(1357 "Selected " + (finaldata) + " in " + object + " field"1358 );1359 let PMdata1 = fileutils.readPropertyFile(platform, "am.pm");1360 mobileElementAction.selectValueFromPicker(PMdata1, "PM");1361 }1362 else {1363 finaldata = timeLog;1364 mobileElementAction.selectValueFromPicker(1365 fileutils.readPropertyFile(platform, object),1366 finaldata 1367 );1368 console.log(1369 "Selected " + (finaldata ) + " in " + object + " field"1370 );1371 let PMdata1 = fileutils.readPropertyFile(platform, "am.pm");1372 mobileElementAction.selectValueFromPicker(PMdata1, "AM");1373 }1374 } else if (value === "future.time.24") {1375 let finaldata = new Date().getHours();1376 mobileElementAction.selectValueFromPicker(1377 fileutils.readPropertyFile(platform, object),1378 finaldata + 11379 );1380 console.log(1381 "Selected " + (finaldata + 1) + " in " + object + " field"1382 );1383 } 1384 else if (value === 'device.future.time') {1385 let time = browser.getDeviceTime();1386 var values = Object.keys(time).map(function(key){1387 return time[key];1388 });1389 let finaldata1390 let timeLog = parseInt(values[0].toString().slice(11,13));1391 1392 if (timeLog >= 12) {1393 finaldata = timeLog - 121394 1395 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata + 1))1396 console.log('Selected ' + (finaldata + 1) + ' in ' + object + ' field');1397 let PMdata1 = fileutils.readPropertyFile(platform, "am.pm")1398 mobileElementAction.selectValueFromPicker(PMdata1, "PM")1399 }1400 else {1401 finaldata = timeLog1402 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata + 1))1403 console.log('Selected ' + (finaldata + 1) + ' in ' + object + ' field');1404 // let PMdata1 = fileutils.readPropertyFile(platform, "am.pm")1405 // mobileElementAction.selectValueFromPicker(PMdata1, "AM")1406 }1407 1408 }1409 1410 else if (value === 'device.future.time.24') {1411 let time = browser.getDeviceTime();1412 var values = Object.keys(time).map(function(key){1413 return time[key];1414 });1415 let finaldata = parseInt(values[0].toString().slice(11,13));1416 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata + 1))1417 console.log('Selected ' + (finaldata + 1) + ' in ' + object + ' field');1418 }1419 1420 1421 else if (value === "future.year") {1422 let finaldata1 = new Date().getFullYear();1423 mobileElementAction.selectValueFromPicker(1424 fileutils.readPropertyFile(platform, object),1425 finaldata1 + 11426 );1427 console.log(1428 "Selected " + (finaldata1 + 1) + " in " + object + " field"1429 );1430 } else if (value === "past.year") {1431 let yearLog = new Date().getFullYear();1432 let finaldata3 = yearLog - 1;1433 mobileElementAction.selectValueFromPicker(1434 fileutils.readPropertyFile(platform, object),1435 finaldata31436 );1437 console.log("Selected " + finaldata3 + " in " + object + " field");1438 let monthLog = new Date().getMonth() + 1;1439 let month1= ("0"+monthLog.toString()).slice(-2)1440 let dateLog = parseInt(1441 browser.getAttribute(1442 fileutils.readPropertyFile(platform, "date"),1443 "value"1444 )1445 );1446 pastDate = month1 + "/" + ("0"+dateLog.toString()).slice(-2) + "/" + finaldata3;1447 console.log(pastDate);1448 } else if (value === "current.year") {1449 let finaldata2 = new Date().getFullYear().toString();1450 browser1451 .element(fileutils.readPropertyFile(platform, object))1452 .setValue(finaldata2);1453 console.log("Selected " + amPMdata + " in " + object + " field");1454 } else if (value === "past.time") {1455 let finaldata2 = new Date().getHours()-1;1456 let finaldata3 = new Date().getMinutes() - 10;1457 let ampm1458 if(finaldata2-1 >=12){1459 ampm = "PM"1460 }1461 else{1462 ampm = "AM"1463 }1464 if (finaldata2 > 12) {1465 finaldata2 = finaldata2 - 12;1466 }1467 else if(finaldata2==0){1468 finaldata2 = 12;1469 } 1470 else {1471 finaldata2 = finaldata2;1472 }1473 if (finaldata3 <= 0) {1474 finaldata3 = finaldata3 + 60;1475 } else {1476 finaldata3 = finaldata3;1477 }1478 mobileElementAction.selectValueFromPicker(1479 fileutils.readPropertyFile(platform, object),1480 finaldata21481 );1482 mobileElementAction.selectValueFromPicker(1483 fileutils.readPropertyFile(platform, "minutes"),1484 finaldata31485 );1486 1487 let pmfield = fileutils.readPropertyFile(platform, "am.pm")1488 mobileElementAction.selectValueFromPicker(pmfield, ampm)1489 console.log(1490 "Selected " + (finaldata2 ) + " in " + object + " field"1491 );1492 let hourLog = parseInt(1493 browser.getAttribute(1494 fileutils.readPropertyFile(platform, "hour"),1495 "value"1496 )1497 );1498 let minLog = parseInt(1499 browser.getAttribute(1500 fileutils.readPropertyFile(platform, "minutes"),1501 "value"1502 )1503 );1504 let ampmLog = browser.getAttribute(1505 fileutils.readPropertyFile(platform, "am.pm"),1506 "value"1507 );1508 // else if (value === 'past.time') {1509 // let finaldata2 = new Date().getHours()-1;1510 // let finaldata3 = (new Date().getMinutes()) - 10;1511 // let ampm1512 // if(new Date().getHours() >=12){1513 // ampm = "PM"1514 // }1515 // else{1516 // ampm = "AM"1517 // }1518 // if (finaldata2 > 12) {1519 // finaldata2 = finaldata2 - 12;1520 // }1521 // else if(finaldata2<0){1522 // finaldata2=finaldata2+24;1523 // }1524 // else if(finaldata2 ==0){1525 // finaldata2 = finaldata2 + 12;1526 // }1527 // else {1528 // finaldata2 = finaldata21529 // }1530 // if (finaldata3 <= 0) {1531 // finaldata3 = finaldata3 + 601532 // }1533 // else {1534 // finaldata3 = finaldata31535 // }1536 // mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata2))1537 // mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1538 // let pmfield = fileutils.readPropertyFile(platform, "am.pm")1539 // mobileElementAction.selectValueFromPicker(pmfield, ampm)1540 // console.log('Selected ' + (finaldata2 ) + ' in ' + object + ' field');1541 // let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1542 // let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1543 // let ampmLog = browser.getAttribute(fileutils.readPropertyFile(platform, "am.pm"), "value")1544 if (parseInt(hourLog) <= 9) {1545 if (parseInt(minLog) <= 9) {1546 pastTime =1547 hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1548 console.log(pastTime);1549 } else {1550 pastTime =1551 hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1552 console.log(pastTime);1553 }1554 } else {1555 if (parseInt(minLog) <= 9) {1556 pastTime =1557 hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1558 console.log(pastTime);1559 } else {1560 pastTime = hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1561 console.log(pastTime);1562 }1563 }1564 } else if (value === "past.time.24") {1565 let finaldata2 = ("0"+((new Date().getHours())-2).toString()).slice(-2);1566 let finaldata3 = new Date().getMinutes() - 10;1567 if (finaldata3 <= 0) {1568 finaldata3 = finaldata3 + 60;1569 } else {1570 finaldata3 = finaldata3;1571 }1572 mobileElementAction.selectValueFromPicker(1573 fileutils.readPropertyFile(platform, object),1574 finaldata21575 );1576 mobileElementAction.selectValueFromPicker(1577 fileutils.readPropertyFile(platform, "minutes"),1578 finaldata31579 );1580 console.log(1581 "Selected " + (finaldata2) + " in " + object + " field"1582 );1583 let hourLog = parseInt(1584 browser.getAttribute(1585 fileutils.readPropertyFile(platform, "hour"),1586 "value"1587 )1588 );1589 let minLog = parseInt(1590 browser.getAttribute(1591 fileutils.readPropertyFile(platform, "minutes"),1592 "value"1593 )1594 );1595 if (parseInt(hourLog) <= 9) {1596 if (parseInt(minLog) <= 9) {1597 pastTime24 = "0" + hourLog + ":0" + minLog;1598 console.log(pastTime24);1599 } else {1600 pastTime24 = "0" + hourLog + ":" + minLog;1601 console.log(pastTime24);1602 }1603 } else {1604 if (parseInt(minLog) <= 9) {1605 pastTime24 = ("0"+hourLog).slice(-2) + ":0" + minLog;1606 console.log(pastTime24);1607 } else {1608 pastTime24 = ("0"+hourLog).slice(-2) + ":" + minLog;1609 console.log(pastTime24);1610 }1611 }1612 } 1613 1614 else if (value === 'device.past.time') {1615 let time = browser.getDeviceTime();1616 var values = Object.keys(time).map(function(key){1617 return time[key];1618 });1619 let timeHour = parseInt(values[0].toString().slice(11,13));1620 let timeMinutes = parseInt(values[0].toString().slice(14,16));1621 let finaldata2 = timeHour - 1;1622 let finaldata3 = timeMinutes - 10;1623 let ampm1624 if(finaldata2 >=12){1625 ampm = "PM"1626 }1627 else{1628 ampm = "AM"1629 }1630 if (finaldata2 > 12) {1631 finaldata2 = finaldata2 - 12;1632 1633 }1634 else if(finaldata2<0){1635 finaldata2=finaldata2+24;1636 }1637 else if(finaldata2 ==0){1638 finaldata2 = finaldata2 + 12;1639 }1640 else {1641 finaldata2 = finaldata21642 }1643 if (finaldata3 <= 0) {1644 finaldata3 = finaldata3 + 601645 }1646 else {1647 finaldata3 = finaldata31648 }1649 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata2))1650 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1651 let pmfield = fileutils.readPropertyFile(platform, "am.pm")1652 mobileElementAction.selectValueFromPicker(pmfield, ampm)1653 console.log('Selected ' + (finaldata2 ) + ' in ' + object + ' field');1654 let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1655 let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1656 let ampmLog = browser.getAttribute(fileutils.readPropertyFile(platform, "am.pm"), "value")1657 if (parseInt(hourLog) <= 9) {1658 if (parseInt(minLog) <= 9) {1659 pastTime = "0" + hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1660 console.log(pastTime)1661 }1662 else {1663 pastTime = "0" + hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1664 console.log(pastTime)1665 }1666 }1667 else {1668 if (parseInt(minLog) <= 9) {1669 pastTime = hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1670 console.log(pastTime)1671 }1672 else {1673 pastTime = hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1674 console.log(pastTime)1675 }1676 }1677 }1678 else if (value === 'device.current.time') {1679 let time = browser.getDeviceTime();1680 var values = Object.keys(time).map(function(key){1681 return time[key];1682 });1683 let finaldata2 = parseInt(values[0].toString().slice(11,13));1684 let finaldata3 = parseInt(values[0].toString().slice(14,16));1685 let ampm1686 if(finaldata2 >=12){1687 ampm = "PM"1688 }1689 else{1690 ampm = "AM"1691 }1692 if (finaldata2 > 12) {1693 finaldata2 = finaldata2 - 12;1694 1695 }1696 else if(finaldata2<0){1697 finaldata2=finaldata2+24;1698 }1699 else if(finaldata2 ==0){1700 finaldata2 = finaldata2 + 12;1701 }1702 else {1703 finaldata2 = finaldata21704 }1705 if (finaldata3 <= 0) {1706 finaldata3 = finaldata3 + 601707 }1708 else {1709 finaldata3 = finaldata31710 }1711 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata2))1712 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1713 let pmfield = fileutils.readPropertyFile(platform, "am.pm")1714 mobileElementAction.selectValueFromPicker(pmfield, ampm)1715 console.log('Selected ' + (finaldata2 ) + ' in ' + object + ' field');1716 let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1717 let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1718 let ampmLog = browser.getAttribute(fileutils.readPropertyFile(platform, "am.pm"), "value")1719 if (parseInt(hourLog) <= 9) {1720 if (parseInt(minLog) <= 9) {1721 currentTime = hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1722 console.log(currentTime)1723 }1724 else {1725 currentTime = hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1726 console.log(currentTime)1727 }1728 }1729 else {1730 if (parseInt(minLog) <= 9) {1731 currentTime = hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1732 console.log(currentTime)1733 }1734 else {1735 currentTime = hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1736 console.log(currentTime)1737 }1738 }1739 }1740 else if (value === 'device.past.time.24') {1741 let time = browser.getDeviceTime();1742 var values = Object.keys(time).map(function(key){1743 return time[key];1744 });1745 let timeHour = parseInt(values[0].toString().slice(11,13));1746 let timeMinutes = parseInt(values[0].toString().slice(14,16));1747 let finaldata2 = timeHour;1748 let finaldata3 = timeMinutes - 10;1749 if (finaldata3 <= 0) {1750 finaldata3 = finaldata3 + 601751 }1752 else {1753 finaldata3 = finaldata31754 }1755 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata2 - 2))1756 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1757 console.log('Selected ' + (finaldata2 - 2) + ' in ' + object + ' field');1758 let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1759 let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1760 if (parseInt(hourLog) <= 9) {1761 if (parseInt(minLog) <= 9) {1762 pastTime24 = "0" + hourLog + ":0" + minLog;1763 console.log(pastTime24)1764 }1765 else {1766 pastTime24 = "0" + hourLog + ":" + minLog;1767 console.log(pastTime24)1768 }1769 }1770 else {1771 if (parseInt(minLog) <= 9) {1772 pastTime24 = hourLog + ":0" + minLog;1773 console.log(pastTime24)1774 }1775 else {1776 pastTime24 = hourLog + ":" + minLog;1777 console.log(pastTime24)1778 }1779 }1780 }1781 else if (value === 'device.past.3hours') {1782 let time = browser.getDeviceTime();1783 var values = Object.keys(time).map(function(key){1784 return time[key];1785 });1786 let timeHour = parseInt(values[0].toString().slice(11,13));1787 let timeMinutes = parseInt(values[0].toString().slice(14,16));1788 let finaldata2 = timeHour - 3;1789 let finaldata3 = timeMinutes;1790 let ampm1791 if(finaldata2 >=12){1792 ampm = "PM"1793 }1794 else{1795 ampm = "AM"1796 }1797 if (finaldata2 > 12) {1798 finaldata2 = finaldata2 - 12;1799 1800 }1801 else if(finaldata2<0){1802 finaldata2=finaldata2+24;1803 }1804 else if(finaldata2 ==0){1805 finaldata2 = finaldata2 + 12;1806 }1807 else {1808 finaldata2 = finaldata21809 }1810 if (finaldata3 <= 0) {1811 finaldata3 = finaldata3 + 601812 }1813 else {1814 finaldata3 = finaldata31815 }1816 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), (finaldata2))1817 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1818 let pmfield = fileutils.readPropertyFile(platform, "am.pm")1819 mobileElementAction.selectValueFromPicker(pmfield, ampm)1820 console.log('Selected ' + (finaldata2 ) + ' in ' + object + ' field');1821 let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1822 let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1823 let ampmLog = browser.getAttribute(fileutils.readPropertyFile(platform, "am.pm"), "value")1824 if (parseInt(hourLog) <= 9) {1825 if (parseInt(minLog) <= 9) {1826 pastTime = "0" + hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1827 console.log(pastTime)1828 }1829 else {1830 pastTime = "0" + hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1831 console.log(pastTime)1832 }1833 }1834 else {1835 if (parseInt(minLog) <= 9) {1836 pastTime = hourLog + ":0" + minLog + " " + ampmLog.toLowerCase();1837 console.log(pastTime)1838 }1839 else {1840 pastTime = hourLog + ":" + minLog + " " + ampmLog.toLowerCase();1841 console.log(pastTime)1842 }1843 }1844 }1845 else if (value === 'device.current.time.24') {1846 let time = browser.getDeviceTime();1847 var values = Object.keys(time).map(function(key){1848 return time[key];1849 });1850 let finaldata2 = parseInt(values[0].toString().slice(11,13));1851 let finaldata3 = parseInt(values[0].toString().slice(14,16));1852 if (finaldata3 <= 0) {1853 finaldata3 = finaldata3 + 601854 }1855 else {1856 finaldata3 = finaldata31857 }1858 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), finaldata2)1859 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "minutes"), (finaldata3))1860 console.log('Selected ' + finaldata2 + ' in ' + object + ' field');1861 let hourLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "hour"), "value"))1862 let minLog = parseInt(browser.getAttribute(fileutils.readPropertyFile(platform, "minutes"), "value"))1863 if (parseInt(hourLog) <= 9) {1864 if (parseInt(minLog) <= 9) {1865 currentTime24 = "0" + hourLog + ":0" + minLog;1866 console.log(currentTime24)1867 }1868 else {1869 currentTime24 = "0" + hourLog + ":" + minLog;1870 console.log(currentTime24)1871 }1872 }1873 else {1874 if (parseInt(minLog) <= 9) {1875 currentTime24 = hourLog + ":0" + minLog;1876 console.log(currentTime24)1877 }1878 else {1879 currentTime24 = hourLog + ":" + minLog;1880 console.log(currentTime24)1881 }1882 }1883 }1884 1885 1886 1887 else {1888 if (data1.indexOf('"') == -1) {1889 data1 = data1;1890 } else {1891 data1 = `${fileutils.readPropertyFile("data", value)}`1892 .replace(/"/g, "")1893 }1894 mobileElementAction.selectValueFromPicker(1895 fileutils.readPropertyFile(platform, object),1896 data11897 );1898 console.log("Selected " + data1 + " from " + object + " field");1899 ////browser.saveScreenshot();1900 }1901 }1902 break;1903 case "web":1904 // perform operation on web element1905 break;1906 }1907 } catch (e) {1908 console.error(" Cannot Select " + object + e);1909 //browser.saveScreenshot();1910 return assert.strictEqual(platform, "", e);1911 }1912});1913/*1914When statement for tapping outside the textbox1915*/1916When(/^I should scroll up$/, async () => {1917 try {1918 switch (platform) {1919 case "android":1920 // android code1921 break;1922 case "ios":1923 mobileactions.mobileScroll("up");1924 browser.break;1925 case "web":1926 // perform operation on web element1927 break;1928 default:1929 break;1930 }1931 } catch (e) {1932 console.error(` Cannot Scroll ${object}`);1933 //browser.saveScreenshot();1934 return assert.strictEqual(platform, "", e);1935 }1936});1937When(1938 /^I tap outside "([^"]*)" (?:button|link|header|field|tab|option|icon|pop-up)$/,1939 async object => {1940 try {1941 switch (platform) {1942 case "android":1943 browser.pressKeycode(4);1944 console.log(` Focussed out of ${object}`);1945 // android code1946 break;1947 case "ios":1948 mobileElementAction.tapOutsideElement();1949 console.log(` Focussed out of ${object}`);1950 ////browser.saveScreenshot();1951 break;1952 case "web":1953 // perform operation on web element1954 break;1955 default:1956 break;1957 }1958 } catch (e) {1959 console.error(` Cannot Tap outside ${object}`);1960 //browser.saveScreenshot();1961 return assert.strictEqual(platform, "", e);1962 }1963 }1964);1965When(/^I set "([^"]*)"$/, async object => {1966 try {1967 switch (platform) {1968 case "android":1969 // android code1970 break;1971 case "ios":1972 const exists = browser.waitUntil(1973 () => browser.element("*//XCUIElementTypePickerWheel").isVisible(),1974 timeOutinMs,1975 "Error: Element not found"1976 );1977 if (exists) {1978 const picker = $(fileutils.readPropertyFile(platform, object));1979 if (object === "Year")1980 mobileElementAction.selectValueFromPicker(picker, Year);1981 else if (object === "Month")1982 mobileElementAction.selectValueFromPicker(picker, Month);1983 else if (object === "Day")1984 mobileElementAction.selectValueFromPicker(picker, Day);1985 }1986 ////browser.saveScreenshot();1987 break;1988 case "web":1989 // perform operation on web element1990 break;1991 default:1992 break;1993 }1994 } catch (e) {1995 console.error(` Cannot set ${object}`);1996 //browser.saveScreenshot();1997 return assert.strictEqual(platform, "", e);1998 }1999});2000When(/^I should see the current month calendar$/, async () => {2001 try {2002 switch (platform) {2003 case "android":2004 // android code here2005 break;2006 case "ios":2007 const exists = browser.waitUntil(2008 () => browser.elements("~calendar_daylabel_text").isVisible(),2009 timeOutinMs,2010 "Error: Element not found"2011 );2012 if (exists) {2013 console.log("Current month calendar is displayed");2014 browser2015 .elements("~calendar_daylabel_text")2016 .value.forEach(element =>2017 console.log(browser.elementIdText(element.ELEMENT).value)2018 );2019 }2020 ////browser.saveScreenshot();2021 break;2022 case "web":2023 // perform operation on web element2024 break;2025 default:2026 break;2027 }2028 } catch (e) {2029 console.error("Cannot find current month");2030 //browser.saveScreenshot();2031 return assert.strictEqual(platform, "", e);2032 }2033});2034When(/^I tap current date$/, async () => {2035 try {2036 switch (platform) {2037 case "android":2038 // android code here2039 break;2040 case "ios":2041 let currDate = new Date().getDate();2042 currDate = currDate.toString();2043 browser.pause(7000);2044 const exists = browser.waitUntil(2045 () => browser.elements("~calendar_daylabel_text").isEnabled(),2046 timeOutinMs,2047 "Error: Element not found"2048 );2049 if (exists) {2050 browser2051 .elements(2052 "//XCUIElementTypeStaticText[@name='calendar_daylabel_text']"2053 )2054 .value.forEach(element => {2055 const val = browser.elementIdText(element.ELEMENT).value;2056 if (currDate === val) {2057 const { x } = browser.elementIdLocation(element.ELEMENT).value;2058 const { y } = browser.elementIdLocation(element.ELEMENT).value;2059 return mobileElementAction.tapByCoordinates(x, y);2060 }2061 });2062 console.log("Clicked on current date");2063 browser.saveScreenshot("CurrentDate");2064 }2065 break;2066 case "web":2067 // perform operation on web element2068 break;2069 default:2070 break;2071 }2072 } catch (e) {2073 console.error(" Cannot find date ");2074 //browser.saveScreenshot();2075 return assert.strictEqual(platform, "", e);2076 }2077});2078When(/^I should see days of the week below the month$/, async () => {2079 try {2080 switch (platform) {2081 case "android":2082 // android code here2083 break;2084 case "ios":2085 const exists = browser.waitUntil(2086 () => browser.elements("~calendar_weekday_text").isVisible(),2087 timeOutinMs,2088 "Error: Element not found"2089 );2090 if (exists) {2091 console.log("Days of the week:");2092 browser2093 .elements("~calendar_weekday_text")2094 .value.forEach(element =>2095 console.log(browser.elementIdText(element.ELEMENT).value)2096 );2097 }2098 ////browser.saveScreenshot();2099 break;2100 case "web":2101 // perform operation on web element2102 break;2103 default:2104 break;2105 }2106 } catch (e) {2107 console.error("Cannot find week days");2108 //browser.saveScreenshot();2109 return assert.strictEqual(platform, "", e);2110 }2111});2112/*2113When statement for verifying valid and invalid email and for alert check2114*/2115When(2116 /^I enter "([^"]*)" into "([^"]*)" textbox for alert verification$/,2117 async (value, object) => {2118 try {2119 switch (platform) {2120 case "android":2121 // Perform for Android2122 break;2123 case "ios":2124 let val = value;2125 if (2126 value === "EmailAddress" &&2127 object === "Forgot.Password.EmailAddress"2128 ) {2129 val = EmailAddress;2130 browser2131 .element(`${fileutils.readPropertyFile(platform, object)}`)2132 .click();2133 browser2134 .element(`${fileutils.readPropertyFile(platform, object)}`)2135 .setValue(val);2136 ////browser.saveScreenshot();2137 } else if (2138 value === "InvalidEmail" &&2139 object === "Forgot.Password.EmailAddress"2140 ) {2141 val = InvalidEmail;2142 browser2143 .element(`${fileutils.readPropertyFile(platform, object)}`)2144 .click();2145 browser2146 .element(`${fileutils.readPropertyFile(platform, object)}`)2147 .setValue(val);2148 ////browser.saveScreenshot();2149 }2150 break;2151 case "web":2152 break;2153 default:2154 break;2155 }2156 } catch (e) {2157 console.error(` Cannot click on ${object}`);2158 //browser.saveScreenshot();2159 return assert.strictEqual(platform, "", e);2160 }2161 }2162);2163When(2164 /^the "([^"]*)" (?:button should be|should be) (?:disabled|enabled)$/,2165 async object => {2166 try {2167 switch (platform) {2168 case "android":2169 let exists1 = browser.waitUntil(2170 function() {2171 return browser2172 .element(fileutils.readPropertyFile(platform, object))2173 .isVisible();2174 },2175 timeOutinMs,2176 "Error: Element not found"2177 );2178 if (exists1) {2179 var isEnabled = mobileElementAction.verifyElementEnabled(2180 fileutils.readPropertyFile(platform, object)2181 );2182 if (isEnabled) {2183 console.log(object + " is enabled");2184 } else {2185 console.log(object + " is disabled");2186 }2187 }2188 break;2189 case "ios":2190 const exists = browser.waitUntil(2191 () =>2192 browser2193 .element(`${fileutils.readPropertyFile(platform, object)}`)2194 .isVisible(),2195 timeOutinMs,2196 "Error: Element not found"2197 );2198 if (exists) {2199 const isEnabled = mobileElementAction.verifyElementEnabled(2200 `${fileutils.readPropertyFile(platform, object)}`2201 );2202 if (isEnabled) {2203 console.log(`${object} is enabled`);2204 } else {2205 console.log(`${object} is disabled`);2206 }2207 }2208 break;2209 case "web":2210 // perform operation on web element2211 break;2212 default:2213 break;2214 }2215 } catch (e) {2216 console.error(` Cannot find ${object}`);2217 //browser.saveScreenshot();2218 return assert.strictEqual(platform, "ios", ` Cannot find${object}`);2219 }2220 }2221);2222When(/^I add "([^"]*)" voice command$/, async object => {2223 try {2224 let command;2225 switch (platform) {2226 case "android":2227 // android code here2228 break;2229 case "ios":2230 command = object;2231 const exists = browser.waitUntil(2232 () => browser.execute("mobile: siriCommand", { text: command }),2233 timeOutinMs,2234 "Error: Element not found"2235 );2236 if (exists) {2237 console.log(` Logged ${object}`);2238 ////browser.saveScreenshot();2239 console.log(browser.contexts());2240 }2241 break;2242 case "web":2243 // perform operation on web element2244 break;2245 default:2246 break;2247 }2248 } catch (e) {2249 console.error(` Cannot find ${object}`);2250 //browser.saveScreenshot();2251 return assert.strictEqual(platform, "", e);2252 }2253});2254// ----Tap Hamburger Menu items------2255When(/^I tap "([^"]*)" menu item$/, async object => {2256 try {2257 switch (platform) {2258 case "android":2259 // perform operation on android element2260 break;2261 case "ios":2262 const exists = browser.waitUntil(2263 () =>2264 browser2265 .elements(`${fileutils.readPropertyFile(platform, object)}`)2266 .isVisible(),2267 timeOutinMs,2268 "Element not found"2269 );2270 if (exists) {2271 let obj = object;2272 if (object.includes(".")) {2273 obj = object.replace(/\./g, " ");2274 browser2275 .elements("~rightmenu_celltitle_text")2276 .value.forEach(element => {2277 if (obj === browser.elementIdText(element.ELEMENT).value) {2278 return browser.elementIdClick(element.ELEMENT);2279 }2280 });2281 } else {2282 browser2283 .elements("~rightmenu_celltitle_text")2284 .value.forEach(element => {2285 if (object === browser.elementIdText(element.ELEMENT).value) {2286 return browser.elementIdClick(element.ELEMENT);2287 }2288 });2289 }2290 console.log(`Clicked on ${object}`);2291 ////browser.saveScreenshot();2292 }2293 break;2294 case "web":2295 // perform operation on web element2296 break;2297 default:2298 break;2299 }2300 } catch (e) {2301 console.error(` Cannot click on ${object}${e}`);2302 //browser.saveScreenshot();2303 return assert.strictEqual(platform, "", e);2304 }2305});2306Then(/^I should see Siri "([^"]*)" text$/, async object => {2307 try {2308 switch (platform) {2309 case "android":2310 browser.waitUntil(2311 () =>2312 browser2313 .element(`${fileutils.readPropertyFile(platform, object)}`)2314 .isVisible(),2315 timeOutinMs,2316 "Element not found"2317 );2318 console.log(`${object} screen is displayed`);2319 ////browser.saveScreenshot();2320 break;2321 case "ios":2322 const exists = browser.waitUntil(2323 () =>2324 browser2325 .element(`${fileutils.readPropertyFile(platform, object)}`)2326 .isVisible(),2327 timeOutinMs,2328 "Element not found"2329 );2330 if (exists) {2331 console.log(2332 ` Message displayed${mobileElementAction.getElementText(2333 $(fileutils.readPropertyFile(platform, object))2334 )}`2335 );2336 ////browser.saveScreenshot();2337 }2338 break;2339 case "web":2340 // web operation2341 break;2342 default:2343 break;2344 }2345 } catch (e) {2346 console.error(`${object} text is not displayed`);2347 //browser.saveScreenshot();2348 return assert.strictEqual(platform, "", e);2349 }2350});2351When(2352 /^I swipe "([^"]*)" and hold should show summary for "([^"]*)"$/,2353 async (swipeDirection, object) => {2354 try {2355 let selector;2356 switch (platform) {2357 case "android":2358 // perform operation on android element2359 break;2360 case "ios":2361 selector = $("//XCUIElementTypeCollectionView");2362 const exists = browser.waitUntil(2363 () =>2364 browser.execute(2365 "mobile: swipe",2366 { direction: swipeDirection },2367 { element: selector }2368 ),2369 timeOutinMs,2370 "Element not found"2371 );2372 if (exists) {2373 console.log(` Swiped ${swipeDirection} the calendar view`);2374 ////browser.saveScreenshot();2375 }2376 break;2377 case "web":2378 // perform operation on web element2379 break;2380 default:2381 break;2382 }2383 } catch (e) {2384 console.error(` Cannot click on ${object}`);2385 //browser.saveScreenshot();2386 return assert.strictEqual(platform, "", e);2387 }2388 }2389);2390When(2391 /^I verify "([^"]*)" (?:text|title|message|header) for "([^"]*)" (?:screen|text|field)$/,2392 async (object, screen) => {2393 try {2394 switch (platform) {2395 case "android":2396 browser.waitUntil(2397 () =>2398 browser2399 .element(`${fileutils.readPropertyFile(platform, object)}`)2400 .isVisible(),2401 timeOutinMs,2402 "Element not found"2403 );2404 console.log(`${object} screen is displayed`);2405 ////browser.saveScreenshot();2406 break;2407 case "ios":2408 const exists = browser.waitUntil(2409 () =>2410 browser2411 .element(`${fileutils.readPropertyFile(platform, object)}`)2412 .isVisible(),2413 timeOutinMs,2414 "Element not found"2415 );2416 if (exists) {2417 const textmessage = browser2418 .element(`${fileutils.readPropertyFile(platform, object)}`)2419 .getText();2420 const textFromConfig = appconfig.verifyTextFromConfig(screen);2421 assert.strictEqual(2422 textmessage,2423 textFromConfig,2424 `Message displayed: ${textFromConfig}`2425 );2426 if (textmessage === textFromConfig) {2427 console.log(`Message displayed: ${textFromConfig}`);2428 }2429 ////browser.saveScreenshot();2430 }2431 break;2432 case "web":2433 // web operation2434 break;2435 default:2436 break;2437 }2438 } catch (e) {2439 console.error(`${object} is not displayed`);2440 //browser.saveScreenshot();2441 return assert.strictEqual(platform, "", e);2442 }2443 }2444);2445When(/^I should see "([^"]*)" available$/, async listName => {2446 try {2447 switch (platform) {2448 case "android":2449 // android code here2450 break;2451 case "ios":2452 const exists = browser.waitUntil(2453 () =>2454 browser2455 .elements("~widget_symptomslistcomponentlabel_text")2456 .isVisible(),2457 timeOutinMs,2458 "Element not found"2459 );2460 if (exists) {2461 const textFromConfig = appconfig.verifyTextFromConfig(listName);2462 browser2463 .elements("~widget_symptomslistcomponentlabel_text")2464 .value.forEach(element => {2465 for (let i = 0; i < textFromConfig.length; i += 1) {2466 if (2467 textFromConfig[i] ===2468 browser.elementIdText(element.ELEMENT).value2469 ) {2470 return console.log(2471 `Symptoms${i}: ${2472 browser.elementIdText(element.ELEMENT).value2473 }`2474 );2475 }2476 }2477 });2478 }2479 ////browser.saveScreenshot();2480 break;2481 case "web":2482 // web operation2483 break;2484 default:2485 break;2486 }2487 } catch (e) {2488 console.error(`${listName} is not displayed`);2489 //browser.saveScreenshot();2490 return assert.strictEqual(platform, "", e);2491 }2492});2493When(2494 /^I (?:select|unselect) "([^"]*)" (?:symptom|symptoms) on "([^"]*)"$/,2495 async (count, listName) => {2496 try {2497 switch (platform) {2498 case "android":2499 // android code here2500 break;2501 case "ios":2502 let counter;2503 const exists = browser.waitUntil(2504 () =>2505 browser2506 .elements("~widget_symptomslistcomponentlabel_text")2507 .isVisible(),2508 timeOutinMs,2509 "Element not found"2510 );2511 if (exists) {2512 const textFromConfig = appconfig.verifyTextFromConfig(listName);2513 if (count === "all") {2514 counter = textFromConfig.length;2515 } else {2516 counter = Number(count);2517 }2518 browser2519 .elements("~widget_symptomslistcomponentlabel_text")2520 .value.forEach(element => {2521 for (let i = 0; i < counter; i += 1) {2522 if (2523 textFromConfig[i] ===2524 browser.elementIdText(element.ELEMENT).value2525 ) {2526 return browser.elementIdClick(element.ELEMENT);2527 }2528 }2529 });2530 }2531 ////browser.saveScreenshot();2532 break;2533 case "web":2534 // web operation2535 break;2536 default:2537 break;2538 }2539 } catch (e) {2540 console.error(`${listName} is never displayed`);2541 //browser.saveScreenshot();2542 return assert.strictEqual(platform, "", e);2543 }2544 }2545);2546When(/^I should see all symptoms unselected$/, async () => {2547 try {2548 switch (platform) {2549 case "android":2550 // android code here2551 break;2552 case "ios":2553 const isSelected = browser2554 .elements(2555 "//XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']"2556 )2557 .value.forEach(element =>2558 browser.elementIdDisplayed(element.ELEMENT)2559 );2560 if (!isSelected) {2561 console.log("No symptoms are selected");2562 ////browser.saveScreenshot();2563 break;2564 }2565 break;2566 case "web":2567 // web operation2568 break;2569 default:2570 break;2571 }2572 } catch (e) {2573 console.error("Symptom selected");2574 //browser.saveScreenshot();2575 return assert.strictEqual(platform, "", e);2576 }2577});2578When(/^the scale should have range of "([^"]*)"$/, async range => {2579 try {2580 switch (platform) {2581 case "android":2582 // android code here2583 break;2584 case "ios":2585 const exists = browser.waitUntil(2586 () => browser.elements("~impairment_levellabel_text").isVisible(),2587 timeOutinMs,2588 "Element not found"2589 );2590 if (exists) {2591 let i = 0;2592 browser2593 .elements("~impairment_levellabel_text")2594 .value.forEach(element => {2595 i += 1;2596 return console.log(2597 `Value ${i}: ${browser.elementIdText(element.ELEMENT).value}`2598 );2599 });2600 ////browser.saveScreenshot();2601 break;2602 }2603 break;2604 case "web":2605 break;2606 default:2607 break;2608 }2609 } catch (e) {2610 console.error(`${range} range is not displayed`);2611 //browser.saveScreenshot();2612 return assert.strictEqual(platform, "", e);2613 }2614});2615When(2616 /^I verify all "([^"]*)" texts for "([^"]*)" field$/,2617 async (object, screen) => {2618 try {2619 switch (platform) {2620 case "android":2621 // android code here----2622 break;2623 case "ios":2624 const exists = browser.waitUntil(2625 () =>2626 browser2627 .element(`${fileutils.readPropertyFile(platform, object)}`)2628 .isVisible(),2629 timeOutinMs,2630 "Element not found"2631 );2632 if (exists) {2633 const textFromConfig = appconfig.verifyTextFromConfig(screen);2634 console.log(textFromConfig);2635 browser2636 .elements("~impairment_descriptiontext_view")2637 .value.forEach(element => {2638 for (let i = 0; i < textFromConfig.length; i += 1) {2639 if (2640 textFromConfig[i] ===2641 browser.elementIdText(element.ELEMENT).value2642 ) {2643 return console.log(2644 `Value${i}: ${2645 browser.elementIdText(element.ELEMENT).value2646 }`2647 );2648 }2649 }2650 });2651 ////browser.saveScreenshot();2652 }2653 break;2654 case "web":2655 // web operation---2656 break;2657 default:2658 break;2659 }2660 } catch (e) {2661 console.error(`${object} is not displayed`);2662 //browser.saveScreenshot();2663 return assert.strictEqual(platform, "", e);2664 }2665 }2666);2667When(/^I verify card title for "([^"]*)"$/, async screen => {2668 try {2669 switch (platform) {2670 case "android":2671 // android code here----2672 break;2673 case "ios":2674 const exists = browser.waitUntil(2675 () => browser.elements("~siri_celltitle_text").isVisible(),2676 timeOutinMs,2677 "Element not found"2678 );2679 if (exists) {2680 const textFromConfig = appconfig.verifyTextFromConfig(screen);2681 browser.elements("~siri_celltitle_text").value.forEach(element => {2682 for (let i = 0; i < textFromConfig.length; i += 1) {2683 if (2684 textFromConfig[i] ===2685 browser.elementIdText(element.ELEMENT).value2686 ) {2687 return console.log(2688 `Shortcut title: ${2689 browser.elementIdText(element.ELEMENT).value2690 }`2691 );2692 }2693 }2694 });2695 browser.elements("~siri_cellsubtitle_text").value.forEach(element => {2696 for (let i = 0; i < textFromConfig.length; i += 1) {2697 if (2698 textFromConfig[i] ===2699 browser.elementIdText(element.ELEMENT).value2700 ) {2701 return console.log(2702 `Shortcut subtitle: ${2703 browser.elementIdText(element.ELEMENT).value2704 }`2705 );2706 }2707 }2708 });2709 ////browser.saveScreenshot();2710 }2711 break;2712 case "web":2713 // web operation---2714 break;2715 default:2716 break;2717 }2718 } catch (e) {2719 console.error(`${screen} screen is not displayed`);2720 //browser.saveScreenshot();2721 return assert.strictEqual(platform, "", e);2722 }2723});2724// For tapping on each slider value2725When(/^I tap on all "([^"]*)"$/, async object => {2726 try {2727 switch (platform) {2728 case "android":2729 // perform operation on android element2730 break;2731 case "ios":2732 const tapImpairment = function tapImpairment(xpaths) {2733 browser.element(xpaths).click();2734 const levelText = browser.element(xpaths).getText();2735 console.log(`\nSelected Slider value : ${levelText}`);2736 const textFromConfig = appconfig.verifyTextFromConfig(2737 "ImpairmentScaleValue"2738 );2739 browser2740 .elements("~impairment_descriptiontext_view")2741 .value.forEach(element => {2742 for (let i = 0; i < 11; i += 1) {2743 if (2744 textFromConfig[i] ===2745 browser.elementIdText(element.ELEMENT).value2746 ) {2747 console.log(2748 `${"Actual and expected match \n" + "Actual :"}${2749 browser.elementIdText(element.ELEMENT).value2750 }\n` + `Expected :${textFromConfig[i]}`2751 );2752 break;2753 }2754 }2755 });2756 };2757 for (let i = 1; i <= 11; i += 1) {2758 let xpath = fileutils.readPropertyFile(platform, object);2759 xpath = `${xpath}[${String(i)}]`;2760 tapImpairment(xpath);2761 }2762 // Tap on each element from 0-10 , Verify the Slider tap movement,2763 // Verify the config texts with actuals2764 ////browser.saveScreenshot();2765 break;2766 case "web":2767 break;2768 default:2769 break;2770 }2771 } catch (e) {2772 console.error(`\n Cannot click on ${object}${e}`);2773 //browser.saveScreenshot();2774 return assert.strictEqual(platform, "", e);2775 }2776});2777When(/^I should see the "([^"]*)"$/, async object => {2778 try {2779 switch (platform) {2780 case "android":2781 expect(2782 browser2783 .element(`${fileutils.readPropertyFile(platform, object)}`)2784 .isExisting()2785 );2786 console.log(`${object} is visible`);2787 ////browser.saveScreenshot();2788 break;2789 case "ios":2790 const exists = browser.waitUntil(2791 () =>2792 browser2793 .element(`${fileutils.readPropertyFile(platform, object)}`)2794 .isVisible(),2795 timeOutinMs,2796 "Error: Element not found"2797 );2798 if (exists) {2799 console.log(2800 `${object} is visible`,2801 `: message displayed: ${mobileElementAction.getElementText(2802 browser.element(`${fileutils.readPropertyFile(platform, object)}`)2803 )}`2804 );2805 ////browser.saveScreenshot();2806 }2807 break;2808 case "web":2809 // perform operation on web element2810 break;2811 default:2812 break;2813 }2814 } catch (e) {2815 console.error(` Cannot find ${object}`);2816 //browser.saveScreenshot();2817 return assert.strictEqual(platform, "", e);2818 }2819});2820When(2821 /^I select "([^"]*)" option on "([^"]*)" screen$/,2822 async (option, screen) => {2823 try {2824 switch (platform) {2825 case "android":2826 let exists1 = browser.waitUntil(2827 function() {2828 return browser2829 .element(fileutils.readPropertyFile(platform, screen))2830 .isVisible();2831 },2832 timeOutinMs,2833 "Element not found"2834 );2835 if (exists1) {2836 if (2837 browser2838 .element(fileutils.readPropertyFile(platform, option))2839 .getAttribute("checked") == "true"2840 ) {2841 console.log(2842 object + "is already Selected " + " in " + block + " field"2843 );2844 ////browser.saveScreenshot();2845 } else {2846 $(fileutils.readPropertyFile(platform, object)).click();2847 console.log("Selected " + object + " in " + block + " field");2848 ////browser.saveScreenshot();2849 }2850 }2851 break;2852 case "ios":2853 const exists = browser.waitUntil(2854 () =>2855 browser2856 .element(`${fileutils.readPropertyFile(platform, screen)}`)2857 .isVisible(),2858 timeOutinMs,2859 "Error: Element not found"2860 );2861 if (exists) {2862 browser2863 .element(`${fileutils.readPropertyFile(platform, option)}`)2864 .click();2865 ////browser.saveScreenshot();2866 break;2867 }2868 break;2869 case "web":2870 // perform operation on web element2871 break;2872 default:2873 break;2874 }2875 } catch (e) {2876 console.error(` Cannot find ${screen}`);2877 //browser.saveScreenshot();2878 return assert.strictEqual(platform, "", e);2879 }2880 }2881);2882// When Statement to tap on Reports tab2883When(/^I click on "([^"]*)" (?:tab|button)$/, async object => {2884 try {2885 switch (platform) {2886 case "android":2887 expect(2888 browser.element(`${fileutils.readPropertyFile(platform, object)}`)2889 .isExisting2890 );2891 console.log(`${object} is visible`);2892 ////browser.saveScreenshot();2893 break;2894 case "ios":2895 const exists = browser.waitUntil(2896 () => $(fileutils.readPropertyFile(platform, object)).isVisible(),2897 timeOutinMs,2898 "Error: Element not found"2899 );2900 if (exists) {2901 $(fileutils.readPropertyFile(platform, object)).click();2902 ////browser.saveScreenshot();2903 }2904 break;2905 case "web":2906 // perform operation on web element2907 break;2908 default:2909 break;2910 }2911 } catch (e) {2912 console.error(` Cannot find ${object}`);2913 //browser.saveScreenshot();2914 return assert.strictEqual(platform, "", e);2915 }2916});2917// When Statement to tap on Reports tab2918When(/^I tap on "([^"]*)" dropdown$/, async object => {2919 try {2920 switch (platform) {2921 case "android":2922 expect(2923 browser.element(`${fileutils.readPropertyFile(platform, object)}`)2924 .isExisting2925 );2926 console.log(`${object} is visible`);2927 ////browser.saveScreenshot();2928 break;2929 case "ios":2930 const exists = browser.waitUntil(2931 () =>2932 browser2933 .element(`${fileutils.readPropertyFile(platform, object)}`)2934 .isVisible(),2935 timeOutinMs,2936 "Error: Element not found"2937 );2938 if (exists) {2939 browser2940 .element(`${fileutils.readPropertyFile(platform, object)}`)2941 .click();2942 ////browser.saveScreenshot();2943 }2944 break;2945 case "web":2946 // perform operation on web element2947 break;2948 default:2949 break;2950 }2951 } catch (e) {2952 console.error(` Cannot find ${object}`);2953 //browser.saveScreenshot();2954 return assert.strictEqual(platform, "", e);2955 }2956});2957// When Statement to tap on Reports option in the dropdown2958When(/^I select "([^"]*)" from the dropdown$/, async object => {2959 try {2960 switch (platform) {2961 case "android":2962 expect(2963 browser.element(`${fileutils.readPropertyFile(platform, object)}`)2964 .isExisting2965 );2966 console.log(`${object} is visible`);2967 ////browser.saveScreenshot();2968 break;2969 case "ios":2970 const reportoption = browser.element(2971 `${fileutils.readPropertyFile(platform, object)}`2972 );2973 if (reportoption.isVisible()) {2974 const reporttext = reportoption.getText();2975 console.log("Clicking on", `${reporttext} `, "from the dropdown");2976 reportoption.click();2977 }2978 break;2979 case "web":2980 // perform operation on web element2981 break;2982 default:2983 break;2984 }2985 } catch (e) {2986 console.error(` Cannot find ${object}`);2987 //browser.saveScreenshot();2988 return assert.strictEqual(platform, "", e);2989 }2990});2991When(/^I select "([^"]*)" link$/, async linkName => {2992 try {2993 switch (platform) {2994 case "android":2995 // android code here-----2996 break;2997 case "ios":2998 const exists = browser.waitUntil(2999 () => browser.element("//XCUIElementTypeTextView").isVisible(),3000 timeOutinMs,3001 "Element not found"3002 );3003 if (exists) {3004 let legalcontentlink = await contentful.termsOfUse(3005 "legalContent",3006 linkName3007 );3008 legalcontentlink = legalcontentlink.replace(/["']/g, "");3009 browser.element(`~${legalcontentlink}`).click();3010 ////browser.saveScreenshot();3011 }3012 break;3013 case "web":3014 // web operation3015 break;3016 default:3017 break;3018 }3019 } catch (e) {3020 console.error(`Cannot click ${linkName} link`);3021 //browser.saveScreenshot();3022 return assert.strictEqual(platform, "", e);3023 }3024});3025When(/^I should see "([^"]*)" available on screen$/, async listName => {3026 try {3027 switch (platform) {3028 case "android":3029 // android code here3030 break;3031 case "ios":3032 const exists = browser.waitUntil(3033 () =>3034 browser3035 .elements(`${fileutils.readPropertyFile(platform, listName)}`)3036 .isVisible(),3037 timeOutinMs,3038 "Element not found"3039 );3040 if (exists) {3041 const textFromConfig = appconfig.verifyTextFromConfig(listName);3042 browser3043 .elements(`${fileutils.readPropertyFile(platform, listName)}`)3044 .value.forEach(element => {3045 for (let i = 0; i < textFromConfig.length; i += 1) {3046 if (textFromConfig[i].includes("Version")) {3047 return console.log(3048 `\n${i}: ${browser.elementIdText(element.ELEMENT).value}`3049 );3050 }3051 if (3052 textFromConfig[i] ===3053 browser.elementIdText(element.ELEMENT).value3054 ) {3055 return console.log(3056 `\n${i}: ${browser.elementIdText(element.ELEMENT).value}`3057 );3058 }3059 }3060 });3061 }3062 ////browser.saveScreenshot();3063 break;3064 case "web":3065 // web operation3066 break;3067 default:3068 break;3069 }3070 } catch (e) {3071 console.error(`${listName} is not displayed`);3072 //browser.saveScreenshot();3073 return assert.strictEqual(platform, "", e);3074 }3075});3076When(/^I select "([^"]*)" tab on "([^"]*)"$/, async (tab, navigationtab) => {3077 try {3078 switch (platform) {3079 case "android":3080 // android code here----3081 break;3082 case "ios":3083 const exists = browser.waitUntil(3084 () =>3085 browser3086 .elements(3087 `${fileutils.readPropertyFile(platform, navigationtab)}`3088 )3089 .isVisible(),3090 timeOutinMs,3091 "Element not found"3092 );3093 if (exists) {3094 browser3095 .elements(`${fileutils.readPropertyFile(platform, navigationtab)}`)3096 .value.forEach(element => {3097 if (tab === browser.elementIdText(element.ELEMENT).value) {3098 return browser.elementIdClick(element.ELEMENT);3099 }3100 });3101 }3102 ////browser.saveScreenshot();3103 break;3104 case "web":3105 // web operation3106 break;3107 default:3108 break;3109 }3110 } catch (e) {3111 console.error(`${tab} is not displayed`);3112 //browser.saveScreenshot();3113 return assert.strictEqual(platform, "", e);3114 }3115});3116//3117// Verifies data from config matches with data from object(xpath)3118//3119When(3120 /^I verify "([^"]*)" matches with data in "([^"]*)" (?:screen|text|field)$/,3121 async (object, screen) => {3122 try {3123 switch (platform) {3124 case "android":3125 browser.waitUntil(3126 () => $(fileutils.readPropertyFile(platform, object)).isVisible(),3127 timeOutinMs,3128 "Element not found"3129 );3130 console.log(`${object} screen is displayed`);3131 ////browser.saveScreenshot();3132 break;3133 case "ios":3134 const exists = browser.waitUntil(3135 () =>3136 $(`${fileutils.readPropertyFile(platform, object)}`).isVisible(),3137 timeOutinMs,3138 "Element not found"3139 );3140 if (exists) {3141 const textmessage = $(3142 `${fileutils.readPropertyFile(platform, object)}`3143 ).getText();3144 const textFromConfig = appconfig.verifyTextFromConfig(screen);3145 assert.strictEqual(3146 textmessage,3147 textFromConfig,3148 `Message displayed: ${textFromConfig}`3149 );3150 if (textmessage === textFromConfig) {3151 console.log(`Message displayed: ${textFromConfig}`);3152 }3153 ////browser.saveScreenshot();3154 break;3155 }3156 break;3157 case "Web":3158 // web operation3159 break;3160 default:3161 break;3162 }3163 } catch (e) {3164 console.error(`${object} screen is not displayed`);3165 //browser.saveScreenshot();3166 return assert.strictEqual(3167 platform,3168 "ios",3169 `${object} screen is not displayed`3170 );3171 }3172 }3173);3174When(3175 /^I slide the "([^"]*)" towards "([^"]*)"$/,3176 async (slider, swipedirection) => {3177 try {3178 switch (platform) {3179 case "android":3180 // android code here3181 break;3182 case "ios":3183 const check = browser.waitUntil(3184 () =>3185 browser3186 .element(`${fileutils.readPropertyFile(platform, slider)}`)3187 .isVisible(),3188 timeOutinMs,3189 "Element not found"3190 );3191 if (check) {3192 const selector = browser.element(3193 `${fileutils.readPropertyFile(platform, slider)}`3194 );3195 browser.execute("mobile: scroll", {3196 direction: swipedirection,3197 element: selector.value.ELEMENT3198 });3199 ////browser.saveScreenshot();3200 }3201 break;3202 case "web":3203 // perform operation on web element3204 break;3205 default:3206 break;3207 }3208 } catch (e) {3209 console.error(` Cannot slide ${e}`);3210 //browser.saveScreenshot();3211 return assert.strictEqual(platform, "", e);3212 }3213 }3214);3215When(3216 /^I move the "([^"]*)" towards "([^"]*)"$/,3217 async (slider, swipedirection) => {3218 try {3219 switch (platform) {3220 case "android":3221 // android code here3222 break;3223 case "ios":3224 const check = browser.waitUntil(3225 () =>3226 browser3227 .element(`${fileutils.readPropertyFile(platform, slider)}`)3228 .isVisible(),3229 timeOutinMs,3230 "Element not found"3231 );3232 if (check) {3233 const selector = browser.element(3234 `${fileutils.readPropertyFile(platform, slider)}`3235 );3236 browser.execute("mobile: swipe", {3237 direction: swipedirection,3238 element: selector.value.ELEMENT3239 });3240 ////browser.saveScreenshot();3241 }3242 break;3243 case "web":3244 // perform operation on web element3245 break;3246 default:3247 break;3248 }3249 } catch (e) {3250 console.error(` Cannot slide ${e}`);3251 //browser.saveScreenshot();3252 return assert.strictEqual(platform, "", e);3253 }3254 }3255);3256When(/^I swipe left "([^"]*)" screen$/, async object => {3257 try {3258 switch (platform) {3259 case "android":3260 mobileactions.swipeLeft(0.85);3261 console.log("Swiped Left");3262 ////browser.saveScreenshot();3263 break;3264 case "ios":3265 mobileactions.swipeLeft(0.85);3266 console.log("Swiped Left");3267 ////browser.saveScreenshot();3268 break;3269 case "web":3270 // perform operation on web element3271 break;3272 default:3273 break;3274 }3275 } catch (e) {3276 console.error(` Cannot slide ${e}`);3277 //browser.saveScreenshot();3278 return assert.strictEqual(platform, "", e);3279 }3280});3281When(/^I swipe right "([^"]*)" screen$/, async object => {3282 try {3283 switch (platform) {3284 case "android":3285 mobileactions.swipeRight(0.85);3286 console.log("Swiped Right");3287 ////browser.saveScreenshot();3288 break;3289 case "ios":3290 mobileactions.swipeRight(0.85);3291 console.log("Swiped Right");3292 ////browser.saveScreenshot();3293 break;3294 case "web":3295 // perform operation on web element3296 break;3297 default:3298 break;3299 }3300 } catch (e) {3301 console.error(` Cannot slide ${e}`);3302 //browser.saveScreenshot();3303 return assert.strictEqual(platform, "", e);3304 }3305});3306When(/^I swipe the "([^"]*)" icon$/, async slider => {3307 try {3308 switch (platform) {3309 case "android":3310 // android code here3311 break;3312 case "ios":3313 const check = browser.waitUntil(3314 () =>3315 browser3316 .element(`${fileutils.readPropertyFile(platform, slider)}`)3317 .isVisible(),3318 timeOutinMs,3319 "Element not found"3320 );3321 if (check) {3322 browser.touchAction(3323 '//XCUIElementTypeImage[@name="editintensity_swipe_icon"]',3324 ["press", { action: "moveTo", x: 0, y: 527 }, "release"]3325 );3326 ////browser.saveScreenshot();3327 }3328 break;3329 case "web":3330 // perform operation on web element3331 break;3332 default:3333 break;3334 }3335 } catch (e) {3336 console.error(` Cannot slide ${e}`);3337 //browser.saveScreenshot();3338 return assert.strictEqual(platform, "", e);3339 }3340});3341When(/^I swipe down the calender$/, async () => {3342 try {3343 switch (platform) {3344 case "android":3345 // android operation3346 browser.execute("mobile: swipe", { direction: "up" });3347 ////browser.saveScreenshot();3348 break;3349 case "ios":3350 browser.execute("mobile: swipe", { direction: "up" });3351 ////browser.saveScreenshot();3352 break;3353 case "web":3354 // perform operation on web element3355 break;3356 default:3357 break;3358 }3359 } catch (e) {3360 console.error(` Cannot swipe ${e}`);3361 //browser.saveScreenshot();3362 return assert.strictEqual(platform, "", e);3363 }3364});3365When(/^I swipe up the calender$/, async () => {3366 try {3367 switch (platform) {3368 case "android":3369 browser.execute("mobile: swipe", { direction: "down" });3370 ////browser.saveScreenshot();3371 break;3372 case "ios":3373 browser.execute("mobile: swipe", { direction: "down" });3374 ////browser.saveScreenshot();3375 break;3376 case "web":3377 // perform operation on web element3378 break;3379 default:3380 break;3381 }3382 } catch (e) {3383 console.error(` Cannot swipe ${e}`);3384 //browser.saveScreenshot();3385 return assert.strictEqual(platform, "", e);3386 }3387});3388When(/^I should see "([^"]*)" (?:card|cards) added$/, async object => {3389 try {3390 switch (platform) {3391 case "android":3392 browser.waitUntil(3393 () =>3394 browser3395 .element(`${fileutils.readPropertyFile(platform, object)}`)3396 .isVisible(),3397 timeOutinMs,3398 "Element not found"3399 );3400 console.log(`${object} screen is displayed`);3401 ////browser.saveScreenshot();3402 break;3403 case "ios":3404 const exists = browser.waitUntil(3405 () =>3406 browser3407 .elements(`${fileutils.readPropertyFile(platform, object)}`)3408 .isVisible(),3409 timeOutinMs,3410 "Element not found"3411 );3412 if (exists) {3413 const cardname = appconfig.verifyTextFromConfig(object);3414 browser3415 .elements(`${fileutils.readPropertyFile(platform, object)}`)3416 .value.forEach(element => {3417 for (let i = 0; i < cardname.length; i += 1) {3418 if (3419 cardname[i] === browser.elementIdText(element.ELEMENT).value3420 ) {3421 return console.log(`${cardname[i]} card is displayed`);3422 }3423 }3424 });3425 }3426 ////browser.saveScreenshot();3427 break;3428 case "web":3429 // web operation3430 break;3431 default:3432 break;3433 }3434 } catch (e) {3435 console.error(`${object} card is not displayed`);3436 //browser.saveScreenshot();3437 return assert.strictEqual(platform, "", e);3438 }3439});3440When(/^the "([^"]*)" on card should be current time$/, async object => {3441 try {3442 switch (platform) {3443 case "android":3444 browser.waitUntil(3445 () =>3446 browser3447 .element(`${fileutils.readPropertyFile(platform, object)}`)3448 .isVisible(),3449 timeOutinMs,3450 "Element not found"3451 );3452 console.log(`${object} screen is displayed`);3453 ////browser.saveScreenshot();3454 break;3455 case "ios":3456 const exists = browser.waitUntil(3457 () =>3458 browser3459 .element(`${fileutils.readPropertyFile(platform, object)}`)3460 .isVisible(),3461 timeOutinMs,3462 "Element not found"3463 );3464 if (exists) {3465 const textmessage = browser3466 .element(`${fileutils.readPropertyFile(platform, object)}`)3467 .getText();3468 const currentime = utils.getcurrenttime();3469 if (currentime === textmessage) {3470 console.log(`${object} is displayed ${currentime}`);3471 break;3472 } else {3473 console.log(`Time displayed: ${textmessage}`);3474 }3475 }3476 ////browser.saveScreenshot();3477 break;3478 case "web":3479 // web operation3480 break;3481 default:3482 break;3483 }3484 } catch (e) {3485 console.error(`${object} card is not displayed`);3486 //browser.saveScreenshot();3487 return assert.strictEqual(platform, "", e);3488 }3489});3490When(3491 /^I move the "([^"]*)" card towards "([^"]*)"$/,3492 async (slider, swipedirection) => {3493 try {3494 switch (platform) {3495 case "android":3496 // android code here3497 break;3498 case "ios":3499 const check = browser.waitUntil(3500 () =>3501 browser3502 .element(`${fileutils.readPropertyFile(platform, slider)}`)3503 .isVisible(),3504 timeOutinMs,3505 "Element not found"3506 );3507 if (check) {3508 const cardname = slider.replace(/\./g, " ");3509 browser3510 .elements(`${fileutils.readPropertyFile(platform, slider)}`)3511 .value.forEach(element => {3512 const val = browser.elementIdText(element.ELEMENT).value;3513 if (val === cardname) {3514 return browser.execute("mobile: swipe", {3515 direction: swipedirection,3516 element: element.value.ELEMENT3517 });3518 }3519 });3520 ////browser.saveScreenshot();3521 break;3522 }3523 break;3524 case "web":3525 // perform operation on web element3526 break;3527 default:3528 break;3529 }3530 } catch (e) {3531 console.error(` Cannot slide ${e}`);3532 //browser.saveScreenshot();3533 return assert.strictEqual(platform, "", e);3534 }3535 }3536);3537When(/^I select "([^"]*)" card$/, async object => {3538 try {3539 switch (platform) {3540 case "android":3541 browser.waitUntil(3542 () =>3543 browser3544 .element(`${fileutils.readPropertyFile(platform, object)}`)3545 .isVisible(),3546 timeOutinMs,3547 "Element not found"3548 );3549 console.log(`${object} screen is displayed`);3550 ////browser.saveScreenshot();3551 break;3552 case "ios":3553 const exists = browser.waitUntil(3554 () =>3555 browser3556 .elements(`${fileutils.readPropertyFile(platform, object)}`)3557 .isVisible(),3558 timeOutinMs,3559 "Element not found"3560 );3561 if (exists) {3562 const cardname = object.replace(/\./g, " ");3563 browser3564 .elements(`${fileutils.readPropertyFile(platform, object)}`)3565 .value.forEach(element => {3566 if (3567 `${cardname}` === browser.elementIdText(element.ELEMENT).value3568 ) {3569 return browser.elementIdClick(element.ELEMENT);3570 }3571 });3572 }3573 ////browser.saveScreenshot();3574 break;3575 case "web":3576 // web operation3577 break;3578 default:3579 break;3580 }3581 } catch (e) {3582 console.error(`${object} card is not displayed`);3583 //browser.saveScreenshot();3584 return assert.strictEqual(platform, "", e);3585 }3586});3587When(/^I should see correct order of "([^"]*)" cards$/, async object => {3588 try {3589 switch (platform) {3590 case "android":3591 ////browser.saveScreenshot();3592 break;3593 case "ios":3594 const exists = browser.waitUntil(3595 () =>3596 browser3597 .elements(`${fileutils.readPropertyFile(platform, object)}`)3598 .isVisible(),3599 timeOutinMs,3600 "Element not found"3601 );3602 if (exists) {3603 const apparray = [];3604 browser3605 .elements(`${fileutils.readPropertyFile(platform, object)}`)3606 .value.forEach(element =>3607 apparray.push(`${browser.elementIdText(element.ELEMENT).value}`)3608 );3609 const migraineposition = apparray.indexOf("Describe Migraine");3610 const medicationpos = apparray.indexOf("Describe Medication");3611 if (migraineposition < medicationpos) {3612 console.log("Migraine card appears above medication cards");3613 }3614 }3615 ////browser.saveScreenshot();3616 break;3617 case "web":3618 // web operation3619 break;3620 default:3621 break;3622 }3623 } catch (e) {3624 console.error("Migraine card do not appear above medication cards");3625 //browser.saveScreenshot();3626 return assert.strictEqual(platform, "", e);3627 }3628});3629When(/^medication cards should be ordered by "([^"]*)"$/, async object => {3630 try {3631 switch (platform) {3632 case "android":3633 ////browser.saveScreenshot();3634 break;3635 case "ios":3636 const exists = browser.waitUntil(3637 () =>3638 browser3639 .elements(`${fileutils.readPropertyFile(platform, object)}`)3640 .isVisible(),3641 timeOutinMs,3642 "Element not found"3643 );3644 if (exists) {3645 const timearray = [];3646 browser3647 .elements(`${fileutils.readPropertyFile(platform, object)}`)3648 .value.forEach(element => {3649 const time = `${browser.elementIdText(element.ELEMENT).value}`;3650 return timearray.push(`${time}`);3651 });3652 const boolean = utils.isarraysorted(timearray, timearray);3653 if (boolean) {3654 console.log("Medication cards are ordered as per time");3655 } else {3656 console.log("Medication cards are not ordered as per time");3657 }3658 }3659 ////browser.saveScreenshot();3660 break;3661 case "web":3662 // web operation3663 break;3664 default:3665 break;3666 }3667 } catch (e) {3668 console.error("Migraine card do not appear above medication cards");3669 //browser.saveScreenshot();3670 return assert.strictEqual(platform, "", e);3671 }3672});3673When(/^I should see correct order of "([^"]*)" tabs$/, async object => {3674 try {3675 switch (platform) {3676 case "android":3677 ////browser.saveScreenshot();3678 break;3679 case "ios":3680 const exists = browser.waitUntil(3681 () =>3682 browser3683 .elements(`${fileutils.readPropertyFile(platform, object)}`)3684 .isVisible(),3685 timeOutinMs,3686 "Element not found"3687 );3688 if (exists) {3689 const apparray = [];3690 const positionarray = appconfig.verifyTextFromConfig(object);3691 browser3692 .elements(`${fileutils.readPropertyFile(platform, object)}`)3693 .value.forEach(element =>3694 apparray.push(`${browser.elementIdText(element.ELEMENT).value}`)3695 );3696 const isequal =3697 positionarray.length === apparray.length &&3698 positionarray.every(3699 (element, index) => element === apparray[index]3700 );3701 if (isequal) {3702 console.log(3703 `Order of tabs is correct \n Expected order : ${positionarray} \n Actual Order: ${apparray}`3704 );3705 } else {3706 console.log(3707 `Order of tabs is not correct \n Expected order : ${positionarray} \n Actual Order: ${apparray}`3708 );3709 }3710 }3711 ////browser.saveScreenshot();3712 break;3713 case "web":3714 // web operation3715 break;3716 default:3717 break;3718 }3719 } catch (e) {3720 console.error("Migraine card do not appear above medication cards");3721 //browser.saveScreenshot();3722 return assert.strictEqual(platform, "", e);3723 }3724});3725When(/^I tap on a "([^"]*)" date$/, async object => {3726 try {3727 let date;3728 switch (platform) {3729 case "android":3730 // android code here3731 break;3732 case "ios":3733 if (object === "past") {3734 date = new Date().getDate() - 1;3735 date = date.toString();3736 } else {3737 date = new Date().getDate() + 1;3738 date = date.toString();3739 }3740 browser.pause(7000);3741 const exists = browser.waitUntil(3742 () => browser.elements("~calendar_daylabel_text").isEnabled(),3743 timeOutinMs,3744 "Error: Element not found"3745 );3746 if (exists) {3747 browser3748 .elements(3749 "//XCUIElementTypeStaticText[@name='calendar_daylabel_text']"3750 )3751 .value.forEach(element => {3752 const val = browser.elementIdText(element.ELEMENT).value;3753 if (date === val) {3754 const { x } = browser.elementIdLocation(element.ELEMENT).value;3755 const { y } = browser.elementIdLocation(element.ELEMENT).value;3756 return mobileElementAction.tapByCoordinates(x, y);3757 }3758 });3759 console.log(`Clicked on ${object} date`);3760 browser.saveScreenshot("CurrentDate");3761 }3762 break;3763 case "web":3764 // perform operation on web element3765 break;3766 default:3767 break;3768 }3769 } catch (e) {3770 console.error(`Date is not clicked ${e}`);3771 //browser.saveScreenshot();3772 return assert.strictEqual(platform, "ios", " Cannot find date");3773 }3774});3775When(3776 /^I select "([^"]*)" card number "([^"]*)"$/,3777 async (object, cardnumber) => {3778 try {3779 switch (platform) {3780 case "android":3781 browser.waitUntil(3782 () =>3783 browser3784 .element(`${fileutils.readPropertyFile(platform, object)}`)3785 .isVisible(),3786 timeOutinMs,3787 "Element not found"3788 );3789 console.log(`${object} screen is displayed`);3790 ////browser.saveScreenshot();3791 break;3792 case "ios":3793 const exists = browser.waitUntil(3794 () =>3795 browser3796 .elements(`${fileutils.readPropertyFile(platform, object)}`)3797 .isVisible(),3798 timeOutinMs,3799 "Element not found"3800 );3801 if (exists) {3802 const xpath = `(//XCUIElementTypeStaticText[@name='${fileutils.readPropertyFile(3803 platform,3804 object3805 )}'])`;3806 const arr = browser3807 .elements(`${fileutils.readPropertyFile(platform, object)}`)3808 .getText();3809 for (let i = 0; i < arr.length; i += 1) {3810 const j = i + 1;3811 if (`${j}` === `${cardnumber}`) {3812 console.log(`${xpath}[${j}]`);3813 globalvar = browser.element(`${xpath}[${j}]`).getText();3814 browser.element(`${xpath}[${j}]`).click();3815 ////browser.saveScreenshot();3816 break;3817 }3818 }3819 }3820 break;3821 case "web":3822 // web operation3823 break;3824 default:3825 break;3826 }3827 } catch (e) {3828 console.error(`Cannot select ${object} card`);3829 //browser.saveScreenshot();3830 return assert.strictEqual(3831 platform,3832 "ios",3833 `Cannot select ${object} card`3834 );3835 }3836 }3837);3838When(3839 /^I (?:select|unselect) "([^"]*)" option on "([^"]*)"$/,3840 async (symptom, listName) => {3841 try {3842 switch (platform) {3843 case "android":3844 // android code here3845 break;3846 case "ios":3847 const exists = browser.waitUntil(3848 () =>3849 browser3850 .elements("~widget_symptomslistcomponentlabel_text")3851 .isVisible(),3852 timeOutinMs,3853 "Element not found"3854 );3855 if (exists) {3856 browser3857 .elements("~widget_symptomslistcomponentlabel_text")3858 .value.forEach(element => {3859 if (3860 browser.elementIdText(element.ELEMENT).value === `${symptom}`3861 ) {3862 return browser.elementIdClick(element.ELEMENT);3863 }3864 });3865 }3866 ////browser.saveScreenshot();3867 break;3868 case "web":3869 // web operation3870 break;3871 default:3872 break;3873 }3874 } catch (e) {3875 console.error(`${listName} is never displayed`);3876 //browser.saveScreenshot();3877 return assert.strictEqual(platform, "", e);3878 }3879 }3880);3881When(/^I should see "([^"]*)" based on time of the day$/, async object => {3882 try {3883 switch (platform) {3884 case "android":3885 // android code here3886 break;3887 case "ios":3888 const exists = browser.waitUntil(3889 () =>3890 browser3891 .element(`${fileutils.readPropertyFile(platform, object)}`)3892 .isVisible(),3893 timeOutinMs,3894 "Element not found"3895 );3896 if (exists) {3897 let message = browser3898 .element(`${fileutils.readPropertyFile(platform, object)}`)3899 .getText();3900 const textmap = appconfig.verifyTextFromConfig(object);3901 const day = "1/1/1970";3902 let currentime = utils.getcurrentampmtime();3903 currentime = Date.parse(`${day} ${currentime}`);3904 const m = message.split(" ")[0];3905 const n = message.split(" ")[1];3906 message = `${m} ${n}`;3907 textmap.forEach((value, key) => {3908 const starttime = Date.parse(`${day} ${key.split("-")[0]}`);3909 const endtime = Date.parse(`${day} ${key.split("-")[1]}`);3910 if (3911 `${currentime} >= ${starttime} && ${currentime} <= ${endtime}`3912 ) {3913 console.log(`${currentime}, ${starttime}, ${endtime}, ${value}`);3914 assert.strictEqual(3915 `${message}, ${value}, Welcome message: ${value}`3916 );3917 console.log(`Welcome message: ${value}`);3918 }3919 });3920 }3921 ////browser.saveScreenshot();3922 break;3923 case "web":3924 // web operation3925 break;3926 default:3927 break;3928 }3929 } catch (e) {3930 console.error(`${object} is never displayed`);3931 //browser.saveScreenshot();3932 return assert.strictEqual(platform, "", e);3933 }3934});3935When(/^I select a "([^"]*)" from "([^"]*)"$/, async (contentType, object) => {3936 try {3937 switch (platform) {3938 case "android":3939 browser.waitUntil(3940 () =>3941 browser3942 .element(`${fileutils.readPropertyFile(platform, object)}`)3943 .isVisible(),3944 timeOutinMs,3945 "Element not found"3946 );3947 console.log(`${object} screen is displayed`);3948 ////browser.saveScreenshot();3949 break;3950 case "ios":3951 const exists = browser.waitUntil(3952 () =>3953 browser3954 .elements(`${fileutils.readPropertyFile(platform, object)}`)3955 .isVisible(),3956 timeOutinMs,3957 "Element not found"3958 );3959 if (exists) {3960 const text = browser.elements(3961 `${fileutils.readPropertyFile(platform, object)}`3962 ).value.length;3963 console.log(`total${text}`);3964 const rand = Math.floor(Math.random() * text) + 1;3965 console.log(rand);3966 const xpath = `(//XCUIElementTypeStaticText[@name='${fileutils.readPropertyFile(3967 platform,3968 object3969 )}'])`;3970 while (!browser.element(`${xpath}[${rand}]`).isVisible()) {3971 mobileactions.swipeDown(0.35);3972 }3973 await browser.element(`${xpath}[${rand}]`).click();3974 globalvar = await browser.element(`${xpath}[${rand}]`).getText();3975 console.log(`Global:${globalvar}`);3976 globalarr.push(globalvar);3977 console.log(`Globalarr:${globalarr}`);3978 ////browser.saveScreenshot();3979 }3980 break;3981 case "web":3982 // web operation3983 break;3984 default:3985 break;3986 }3987 } catch (e) {3988 console.error(`Cannot select ${object} card`);3989 //browser.saveScreenshot();3990 return assert.strictEqual(platform, "", e);3991 }3992});3993When(3994 /^I verify selected "([^"]*)" reflects in "([^"]*)"$/,3995 async (item, object) => {3996 try {3997 switch (platform) {3998 case "android":3999 // code4000 break;4001 case "ios":4002 const exists = browser.waitUntil(4003 () =>4004 browser4005 .elements(`${fileutils.readPropertyFile(platform, object)}`)4006 .isVisible(),4007 timeOutinMs,4008 "Element not found"4009 );4010 if (exists) {4011 console.log(`//*[@value='${globalvar}']`);4012 if (4013 await browser.element(`//*[@value='${globalvar}']`).isVisible()4014 ) {4015 console.log(`Pass: ${item} : ${globalvar} is selected`);4016 ////browser.saveScreenshot();4017 } else {4018 }4019 }4020 break;4021 case "web":4022 // web operation4023 break;4024 default:4025 break;4026 }4027 } catch (e) {4028 console.error(e);4029 //browser.saveScreenshot();4030 return assert.strictEqual(4031 platform,4032 "ios",4033 `Cannot select ${object} card`4034 );4035 }4036 }4037);4038Then(4039 /^I verify "([^"]*)" selected in "([^"]*)" reflects in "([^"]*)" screen$/,4040 async (item1, item2, object) => {4041 try {4042 switch (platform) {4043 case "android":4044 break;4045 case "ios":4046 let flag;4047 const valarr = [];4048 const uniquearray = [];4049 const check = browser.waitUntil(4050 () =>4051 browser4052 .elements(`${fileutils.readPropertyFile(platform, object)}`)4053 .isVisible(),4054 timeOutinMs,4055 "Element not found"4056 );4057 if (check) {4058 const xpath = fileutils.readPropertyFile(platform, object);4059 const len = browser.elements(`~${xpath}`).value.length;4060 for (let i = 1; i <= len; i += 1) {4061 const val = browser4062 .element(`(//*[@name='${xpath}'])[${i}]`)4063 .getText();4064 valarr.push(val);4065 }4066 valarr.sort();4067 globalarr.sort();4068 console.log(`Global vars: ${globalarr.sort()}`);4069 console.log(`valarr vars: ${valarr.sort()}`);4070 for (let h = 0; h < globalarr.length; h += 1) {4071 if (uniquearray.indexOf(globalarr[h]) === -1) {4072 uniquearray.push(globalarr[h]);4073 }4074 }4075 console.log(`uniquearray vars: ${uniquearray.sort()}`);4076 for (let j = 0; j < len; j += 1) {4077 if (valarr[j] === uniquearray[j]) {4078 flag = 1;4079 } else {4080 flag = 0;4081 break;4082 }4083 }4084 if (flag === 1) {4085 console.log(4086 `Pass: ${item1} selected in ${item2} reflects in ${object}`4087 );4088 } else {4089 console.log(4090 `Fail: ${item1} selected in ${item2} does not matches in ${object}`4091 );4092 }4093 }4094 ////browser.saveScreenshot();4095 break;4096 case "web":4097 // web operation4098 break;4099 default:4100 break;4101 }4102 } catch (e) {4103 console.error(`Cannot fetch contentful data: ${e}`);4104 }4105 }4106);4107When(4108 /^I swipe the "([^"]*)" towards "([^"]*)" and delete$/,4109 async (slider, swipedirection) => {4110 try {4111 switch (platform) {4112 case "android":4113 // android code here4114 break;4115 case "ios":4116 const check = browser.waitUntil(4117 () =>4118 browser4119 .elements(`${fileutils.readPropertyFile(platform, slider)}`)4120 .isVisible(),4121 timeOutinMs,4122 "Element not found"4123 );4124 if (check) {4125 globalarr.pop();4126 const xpath = `(//*[@name='${fileutils.readPropertyFile(4127 platform,4128 slider4129 )}'])`;4130 const len = browser.elements(xpath).value.length;4131 console.log(len);4132 const selector = browser.element(`${xpath}[${len}]`);4133 const textmessage = browser.element(`${xpath}[${len}]`).getText();4134 console.log(textmessage);4135 browser.execute("mobile: swipe", {4136 direction: swipedirection,4137 element: selector.value.ELEMENT4138 });4139 browser.element("~Delete").click();4140 if (!browser.element(`~${textmessage}`).isVisible()) {4141 console.log(`Pass:${textmessage} deleted successfully`);4142 ////browser.saveScreenshot();4143 } else {4144 console.log(`Fail:${textmessage} not deleted `);4145 }4146 ////browser.saveScreenshot();4147 }4148 break;4149 case "web":4150 // perform operation on web element4151 break;4152 default:4153 break;4154 }4155 } catch (e) {4156 console.error(` Cannot slide ${e}`);4157 //browser.saveScreenshot();4158 return assert.strictEqual(platform, "", e);4159 }4160 }4161);4162When(/^I reopen the app$/, async () => {4163 browser.execute("mobile: launchApp", { bundleId: "com.deloitte.lilly.vega" });4164 ////browser.saveScreenshot();4165 console.log("vega app re-opened");4166});4167When(4168 /^"([^"]*)" (?:link should be|should be) (?:disabled|enabled)$/,4169 async object => {4170 try {4171 switch (platform) {4172 case "android":4173 const exists1 = browser.waitUntil(4174 () =>4175 browser4176 .element(`${fileutils.readPropertyFile(platform, object)}`)4177 .isVisible(),4178 timeOutinMs,4179 "Error: Element not found"4180 );4181 if (exists1) {4182 if (object == "future.dates") {4183 const curdate = parseInt(utils.currentDate().split(" ")[0]);4184 console.log(curdate);4185 const isEnabled = mobileElementAction.verifyElementEnabled(4186 `${fileutils.readPropertyFile(platform, object)}`4187 );4188 if (isEnabled) {4189 console.log(`${object} is enabled`);4190 } else {4191 console.log(`${object} is disabled`);4192 }4193 } else {4194 const isEnabled = mobileElementAction.verifyElementEnabled(4195 `${fileutils.readPropertyFile(platform, object)}`4196 );4197 if (isEnabled) {4198 console.log(`${object} is enabled`);4199 } else {4200 console.log(`${object} is disabled`);4201 }4202 }4203 }4204 break;4205 case "ios":4206 const exists = browser.waitUntil(4207 () =>4208 browser4209 .element(`${fileutils.readPropertyFile(platform, object)}`)4210 .isVisible(),4211 timeOutinMs,4212 "Error: Element not found"4213 );4214 if (exists) {4215 const isEnabled = mobileElementAction.verifyElementEnabled(4216 `${fileutils.readPropertyFile(platform, object)}`4217 );4218 if (isEnabled) {4219 console.log(`${object} is enabled`);4220 } else {4221 console.log(`${object} is disabled`);4222 }4223 }4224 break;4225 case "web":4226 // perform operation on web element4227 break;4228 default:4229 break;4230 }4231 } catch (e) {4232 console.error(` Cannot find ${object}`);4233 //browser.saveScreenshot();4234 return assert.strictEqual(platform, "", e);4235 }4236 }4237);4238When(4239 /^I should see "([^"]*)" (?:button|field|link) is (?:disabled|enabled)$/,4240 async object => {4241 try {4242 switch (platform) {4243 case "android":4244 const exists1 = browser.waitUntil(4245 () =>4246 browser4247 .element(`${fileutils.readPropertyFile(platform, object)}`)4248 .isVisible(),4249 timeOutinMs,4250 "Error: Element not found"4251 );4252 if (exists1) {4253 const isEnabled = mobileElementAction.verifyElementEnabled(4254 `${fileutils.readPropertyFile(platform, object)}`4255 );4256 if (isEnabled) {4257 console.log(`${object} is enabled`);4258 } else {4259 console.log(`${object} is disabled`);4260 }4261 }4262 break;4263 case "ios":4264 const exists = browser.waitUntil(4265 () =>4266 browser4267 .element(`${fileutils.readPropertyFile(platform, object)}`)4268 .isVisible(),4269 timeOutinMs,4270 "Error: Element not found"4271 );4272 if (exists) {4273 const isEnabled = mobileElementAction.verifyElementEnabled(4274 `${fileutils.readPropertyFile(platform, object)}`4275 );4276 if (isEnabled) {4277 console.log(`${object} is enabled`);4278 } else {4279 console.log(`${object} is disabled`);4280 }4281 }4282 break;4283 case "web":4284 // perform operation on web element4285 break;4286 default:4287 break;4288 }4289 } catch (e) {4290 console.error(` Cannot find ${object}`);4291 //browser.saveScreenshot();4292 return assert.strictEqual(platform, "", e);4293 }4294 }4295);4296When(4297 /^I should see "([^"]*)" field filled with registered Email ID$/,4298 async object => {4299 try {4300 switch (platform) {4301 case "android":4302 const exists1 = browser.waitUntil(4303 () =>4304 browser4305 .element(`${fileutils.readPropertyFile(platform, object)}`)4306 .isVisible(),4307 timeOutinMs,4308 "Error: Element not found"4309 );4310 if (exists1) {4311 let regEmailID = `${fileutils.readPropertyFile(4312 "data",4313 "emailaddress"4314 )}`;4315 let currentEmail = browser.getText(4316 fileutils.readPropertyFile(platform, object)4317 );4318 if (regEmailID == currentEmail) {4319 console.log(`${object} is displaying`);4320 } else {4321 console.log(`${object} is not displaying`);4322 }4323 }4324 break;4325 case "ios":4326 const exists = browser.waitUntil(4327 () =>4328 browser4329 .element(`${fileutils.readPropertyFile(platform, object)}`)4330 .isVisible(),4331 timeOutinMs,4332 "Error: Element not found"4333 );4334 if (exists) {4335 let regEmailID = `${fileutils.readPropertyFile(4336 "data",4337 "emailaddress"4338 )}`;4339 let currentEmail = browser.getText(4340 fileutils.readPropertyFile(platform, object)4341 );4342 if (regEmailID == currentEmail) {4343 console.log(`${object} is displaying`);4344 } else {4345 console.log(`${object} is not displaying`);4346 }4347 }4348 break;4349 case "web":4350 // perform operation on web element4351 break;4352 default:4353 break;4354 }4355 } catch (e) {4356 console.error(` Cannot find ${object}`);4357 //browser.saveScreenshot();4358 return assert.strictEqual(platform, "", e);4359 }4360 }4361);4362When(/^I should see empty "([^"]*)" field$/, async object => {4363 try {4364 switch (platform) {4365 case "android":4366 const exists1 = browser.waitUntil(4367 () =>4368 browser4369 .element(`${fileutils.readPropertyFile(platform, object)}`)4370 .isVisible(),4371 timeOutinMs,4372 "Error: Element not found"4373 );4374 if (exists1) {4375 if (object == "edit.screen.first.name") {4376 let fieldName = `${fileutils.readPropertyFile("data", object)}`;4377 let emptyfieldtext = browser.getText(4378 fileutils.readPropertyFile(platform, object)4379 );4380 if (fieldName === emptyfieldtext) {4381 console.log(`${object} is Empty`);4382 mobileactions.hideDeviceKeyboard();4383 } else {4384 console.log(`${object} is not Empty`);4385 mobileactions.hideDeviceKeyboard();4386 }4387 } else if (object == "edit.screen.last.name") {4388 let fieldName = `${fileutils.readPropertyFile("data", object)}`;4389 let emptyfieldtext = browser.getText(4390 fileutils.readPropertyFile(platform, object)4391 );4392 if (fieldName === emptyfieldtext) {4393 console.log(`${object} is Empty`);4394 mobileactions.hideDeviceKeyboard();4395 } else {4396 console.log(`${object} is not Empty`);4397 mobileactions.hideDeviceKeyboard();4398 }4399 } else {4400 let regEmailID1 = `${fileutils.readPropertyFile("data", object)}`;4401 // console.log(regEmailID1)4402 let currentEmail1 = browser.getText(4403 fileutils.readPropertyFile(platform, object)4404 );4405 if (regEmailID1 === currentEmail1) {4406 console.log(`${object} is Empty`);4407 mobileactions.hideDeviceKeyboard();4408 } else {4409 console.log(`${object} is not Empty`);4410 mobileactions.hideDeviceKeyboard();4411 }4412 }4413 }4414 break;4415 case "ios":4416 const exists = browser.waitUntil(4417 () =>4418 browser4419 .element(`${fileutils.readPropertyFile(platform, object)}`)4420 .isVisible(),4421 timeOutinMs,4422 "Error: Element not found"4423 );4424 if (exists) {4425 if (object == "edit.screen.first.name") {4426 let fieldName = `${fileutils.readPropertyFile("data", object)}`;4427 let emptyfieldtext = browser.getText(4428 fileutils.readPropertyFile(platform, object)4429 );4430 if (fieldName === emptyfieldtext) {4431 console.log(`${object} is Empty`);4432 } else {4433 console.log(`${object} is not Empty`);4434 }4435 } else if (object == "edit.screen.last.name") {4436 let fieldName = `${fileutils.readPropertyFile("data", object)}`;4437 let emptyfieldtext = browser.getText(4438 fileutils.readPropertyFile(platform, object)4439 );4440 if (fieldName === emptyfieldtext) {4441 console.log(`${object} is Empty`);4442 } else {4443 console.log(`${object} is not Empty`);4444 }4445 } else {4446 let regEmailID1 = `${fileutils.readPropertyFile("data", object)}`;4447 let currentEmail1 = browser.getText(4448 fileutils.readPropertyFile(platform, object)4449 );4450 if (regEmailID1 === currentEmail1) {4451 console.log(`${object} is Empty`);4452 } else {4453 console.log(`${object} is not Empty`);4454 }4455 }4456 }4457 // }4458 break;4459 case "web":4460 // perform operation on web element4461 break;4462 default:4463 break;4464 }4465 } catch (e) {4466 console.error(` Cannot find Empty ${object}`);4467 //browser.saveScreenshot();4468 return assert.strictEqual(platform, "", e);4469 }4470});4471When(4472 /^I should see "([^"]*)" (?:default value|value) in the field$/,4473 async object => {4474 try {4475 switch (platform) {4476 case "android":4477 const exists1 = browser.waitUntil(4478 () =>4479 browser4480 .element(`${fileutils.readPropertyFile(platform, object)}`)4481 .isVisible(),4482 timeOutinMs,4483 "Error: Element not found"4484 );4485 if (exists1) {4486 const isEnabled = mobileElementAction.verifyElementEnabled(4487 `${fileutils.readPropertyFile(platform, object)}`4488 );4489 if (isEnabled) {4490 console.log(`${object} is enabled`);4491 } else {4492 console.log(`${object} is disabled`);4493 }4494 }4495 break;4496 case "ios":4497 const exists = browser.waitUntil(4498 () =>4499 browser4500 .element(`${fileutils.readPropertyFile(platform, object)}`)4501 .isVisible(),4502 timeOutinMs,4503 "Error: Element not found"4504 );4505 if (exists) {4506 const isEnabled = mobileElementAction.verifyElementEnabled(4507 `${fileutils.readPropertyFile(platform, object)}`4508 );4509 if (isEnabled) {4510 console.log(`${object} is enabled`);4511 } else {4512 console.log(`${object} is disabled`);4513 }4514 }4515 break;4516 case "web":4517 // perform operation on web element4518 break;4519 default:4520 break;4521 }4522 } catch (e) {4523 console.error(` Cannot find ${object}`);4524 //browser.saveScreenshot();4525 return assert.strictEqual(platform, "", e);4526 }4527 }4528);4529When(4530 /^I should see "([^"]*)" (?:accepted|unaccepted) in "([^"]*)" field$/,4531 async (value, object) => {4532 try {4533 switch (platform) {4534 case "android":4535 const val = `${fileutils.readPropertyFile("data", value)}`;4536 const textmessage1 = browser.getText(4537 fileutils.readPropertyFile(platform, object)4538 );4539 if (val === textmessage1) {4540 console.log(`Accepted: ${val}`);4541 } else {4542 console.error(`Not accepts: ${val}`);4543 }4544 ////browser.saveScreenshot();4545 break;4546 case "ios":4547 const val1 = `${fileutils.readPropertyFile("data", value)}`;4548 browser4549 .element(`${fileutils.readPropertyFile(platform, object)}`)4550 .click();4551 const textmessage = browser.getText(4552 fileutils.readPropertyFile(platform, object)4553 );4554 if (val1 === textmessage) {4555 console.log(`Accepted: ${val1}`);4556 } else {4557 console.error(`Not accepts: ${val1}`);4558 }4559 ////browser.saveScreenshot();4560 break;4561 case "web":4562 // web operation4563 break;4564 default:4565 break;4566 }4567 } catch (e) {4568 console.error(`${object} is not displayed`);4569 //browser.saveScreenshot();4570 return assert.strictEqual(platform, "", e);4571 }4572 }4573);4574When(4575 /^I should see "([^"]*)" (?:masked|unmasked) in "([^"]*)" field$/,4576 async (value, object) => {4577 try {4578 switch (platform) {4579 case "android":4580 const textmessage1 = browser.getText(4581 fileutils.readPropertyFile(platform, object)4582 );4583 var k = 0;4584 for (var i = 0; i < textmessage1.length; i++) {4585 var j = textmessage1.charAt(i);4586 if (j === "•") {4587 k++;4588 }4589 }4590 if (k === textmessage1.length) {4591 console.log(`Password Text is masked: ${textmessage1}`);4592 } else {4593 console.log(`Password Text is unmasked: ${textmessage1}`);4594 }4595 break;4596 case "ios":4597 const textmessage = browser.getText(4598 fileutils.readPropertyFile(platform, object)4599 );4600 var k = 0;4601 for (var i = 0; i < textmessage.length; i++) {4602 var j = textmessage.charAt(i);4603 if (j === "•") {4604 k++;4605 }4606 }4607 if (k === textmessage.length) {4608 console.log(`Password Text is masked: ${textmessage}`);4609 } else {4610 console.log(`Password Text is unmasked: ${textmessage}`);4611 }4612 ////browser.saveScreenshot();4613 break;4614 case "web":4615 // web operation4616 break;4617 default:4618 break;4619 }4620 } catch (e) {4621 console.error(`${object} is not displayed`);4622 //browser.saveScreenshot();4623 return assert.strictEqual(platform, "", e);4624 }4625 }4626);4627When(4628 /^I should see "([^"]*)" in "([^"]*)" field in MM-DD-YYYY format$/,4629 async (value, object) => {4630 try {4631 switch (platform) {4632 case "android":4633 let appdate = browser4634 .element(`${fileutils.readPropertyFile(platform, object)}`)4635 .getAttribute("text");4636 let appvalue4637 if(value=='past.date'){4638 appvalue = pastDate;4639 }4640 else{4641 appvalue = fileutils.readPropertyFile("data", value);4642 }4643 if (appdate == appvalue) {4644 if (moment(appdate, "MM/DD/YYYY")) {4645 console.log(value+"-"+appvalue +"valid format");4646 } else {4647 console.log(value+"-"+appvalue +"invalid format");4648 }4649 } else {4650 console.log(value + " Not Entered");4651 }4652 ////browser.saveScreenshot();4653 break;4654 case "ios":4655 // ios code here4656 let appdate1 = browser4657 .element(`${fileutils.readPropertyFile(platform, object)}`)4658 .getText();4659 let appvalue14660 if(value=='past.date'){4661 appvalue1 = pastDate;4662 }4663 else{4664 appvalue1 = fileutils.readPropertyFile("data", value);4665 }4666 4667 console.log("App Date is " + appdate1);4668 if (appdate1 == appvalue1) {4669 if (moment(appdate1, "MM/DD/YYYY")) {4670 console.log(value+"-"+appvalue1 + " is in valid format");4671 } else {4672 console.log(value +"-"+appvalue1+ " is in invalid format");4673 }4674 } else {4675 console.log(value + " Not Entered");4676 }4677 ////browser.saveScreenshot();4678 break;4679 case "web":4680 // perform operation on web element4681 break;4682 default:4683 break;4684 }4685 } catch (e) {4686 console.error(" Cannot find date ");4687 //browser.saveScreenshot();4688 return assert.strictEqual(platform, "", e);4689 }4690 }4691);4692When(/^I should see "([^"]*)" in MM-DD-YYYY format$/, async object => {4693 try {4694 switch (platform) {4695 case "android":4696 let appdate = browser4697 .element(`${fileutils.readPropertyFile(platform, object)}`)4698 .getAttribute("text");4699 if (moment(appdate, "MM/DD/YYYY")) {4700 console.log("valid format");4701 } else {4702 console.log("invalid format");4703 }4704 ////browser.saveScreenshot();4705 break;4706 case "ios":4707 // ios code here4708 let appdate1 = browser4709 .element(`${fileutils.readPropertyFile(platform, object)}`)4710 .getText();4711 console.log("App Date is " + appdate1);4712 if (moment(appdate1, "MM/DD/YYYY")) {4713 console.log("valid format");4714 } else {4715 console.log("invalid format");4716 }4717 ////browser.saveScreenshot();4718 break;4719 case "web":4720 // perform operation on web element4721 break;4722 default:4723 break;4724 }4725 } catch (e) {4726 console.error(" Cannot find date ");4727 //browser.saveScreenshot();4728 return assert.strictEqual(platform, "ios", " Cannot find date");4729 }4730});4731When(/^I should see CurrentDate in "([^"]*)" field$/, async object => {4732 try {4733 switch (platform) {4734 case "android":4735 let splitcurrentDate = new Date()4736 .toISOString()4737 .slice(0, 10)4738 .split("-");4739 let currYear = splitcurrentDate[0];4740 let currMonth = splitcurrentDate[1];4741 let currDay = splitcurrentDate[2];4742 let appdate = browser4743 .element(`${fileutils.readPropertyFile(platform, object)}`)4744 .getAttribute("text");4745 console.log("App Date is " + appdate);4746 let splitappdate = appdate.split("/");4747 let appmonth = splitappdate[0];4748 let appday = splitappdate[1];4749 let appyear = splitappdate[2];4750 expect(appmonth).to.equal(currMonth);4751 expect(appday).to.equal(currDay);4752 expect(appyear).to.equal(currYear);4753 console.log("Verified current Date");4754 ////browser.saveScreenshot();4755 break;4756 case "ios":4757 // ios code here4758 let splitcurrentDate1 = new Date()4759 .toISOString()4760 .slice(0, 10)4761 .split("-");4762 let currYear1 = splitcurrentDate1[0];4763 let currMonth1 = splitcurrentDate1[1];4764 let currDay1 = splitcurrentDate1[2];4765 console.log(4766 "Current Date is " + currMonth1 + "/" + currDay1 + "/" + currYear14767 );4768 let appdate1 = browser4769 .element(`${fileutils.readPropertyFile(platform, object)}`)4770 .getAttribute("value");4771 console.log("App Date is " + appdate1);4772 let splitappdate1 = appdate1.split("/");4773 let appmonth1 = splitappdate1[0];4774 let appday1 = splitappdate1[1];4775 let appyear1 = splitappdate1[2];4776 expect(appmonth1).to.equal(currMonth1);4777 expect(appday1).to.equal(currDay1);4778 expect(appyear1).to.equal(currYear1);4779 console.log("Verified current Date");4780 ////browser.saveScreenshot();4781 break;4782 case "web":4783 // perform operation on web element4784 break;4785 default:4786 break;4787 }4788 } catch (e) {4789 console.error(" Cannot find date ");4790 //browser.saveScreenshot();4791 return assert.strictEqual(platform, "", e);4792 }4793});4794When(/^I select "([^"]*)" in "([^"]*)" List$/, async (value, object) => {4795 try {4796 switch (platform) {4797 case "android":4798 if (object === "year.of.birth") {4799 let reqYear = `${fileutils.readPropertyFile("data", value)}`;4800 let selectYear = browser.getText(4801 fileutils.readPropertyFile(platform, object)4802 );4803 let selectedYear = browser.getText(4804 fileutils.readPropertyFile(platform, "year")4805 );4806 if (selectedYear < reqYear) {4807 while (selectYear.indexOf(reqYear) == -1) {4808 mobileactions.swipe_down("datepicker.screen");4809 selectYear = browser.getText(4810 fileutils.readPropertyFile(platform, object)4811 );4812 }4813 let selYear = fileutils4814 .readPropertyFile(platform, "select.year")4815 .replace("2019", reqYear);4816 browser.element(selYear).click();4817 } else {4818 while (selectYear.indexOf(reqYear) == -1) {4819 mobileactions.swipe_up("datepicker.screen");4820 selectYear = browser.getText(4821 fileutils.readPropertyFile(platform, object)4822 );4823 }4824 let selYear = fileutils4825 .readPropertyFile(platform, "select.year")4826 .replace("2019", reqYear);4827 browser.element(selYear).click();4828 }4829 } else if (object === "month") {4830 let month = browser.getAttribute(4831 fileutils.readPropertyFile(platform, "month.text"),4832 "content-desc"4833 );4834 let val = `${fileutils.readPropertyFile("data", value)}`;4835 while (month.split(" ")[1] != val) {4836 browser4837 .element(fileutils.readPropertyFile(platform, "previous.month"))4838 .click();4839 month = browser.getAttribute(4840 fileutils.readPropertyFile(platform, "month.text"),4841 "content-desc"4842 );4843 }4844 } else if (object === "date") {4845 let reqDate = `${fileutils.readPropertyFile("data", object)}`;4846 let selDate = fileutils4847 .readPropertyFile(platform, object)4848 .replace("10", reqDate);4849 browser.element(selDate).click();4850 } else {4851 console.log(object + "not found");4852 }4853 break;4854 case "ios":4855 let exists = browser.waitUntil(4856 function() {4857 return browser4858 .element(fileutils.readPropertyFile(platform, object))4859 .click();4860 },4861 timeOutinMs,4862 "Element not found"4863 );4864 if (exists) {4865 console.log("Clicked on " + object);4866 ////browser.saveScreenshot();4867 }4868 if (object === "year") {4869 mobileElementAction.selectValueFromPicker(4870 fileutils.readPropertyFile(platform, object),4871 fileutils.readPropertyFile("data", value)4872 );4873 } else if (object === "month") {4874 mobileElementAction.selectValueFromPicker(4875 fileutils.readPropertyFile(platform, object),4876 fileutils.readPropertyFile("data", value)4877 );4878 } else if (object === "date") {4879 mobileElementAction.selectValueFromPicker(4880 fileutils.readPropertyFile(platform, object),4881 fileutils.readPropertyFile("data", object)4882 );4883 } else {4884 console.log(object + "not found");4885 }4886 break;4887 case "web":4888 // perform operation on web element4889 break;4890 }4891 } catch (e) {4892 console.error(" Cannot select " + object + e);4893 //browser.saveScreenshot();4894 return assert.strictEqual(platform, "", e);4895 }4896});4897When(/^I clear space$/, async () => {4898 try {4899 switch (platform) {4900 case "android":4901 mobileactions.hideDeviceKeyboard();4902 ////browser.saveScreenshot();4903 break;4904 case "ios":4905 browser4906 .element(`${fileutils.readPropertyFile(platform, "backspace")}`)4907 .click();4908 console.log(`cleared space`);4909 ////browser.saveScreenshot();4910 break;4911 case "web":4912 // perform operation on web element4913 break;4914 default:4915 break;4916 }4917 } catch (e) {4918 console.error(` Cannot find ${object}\n${e}`);4919 //browser.saveScreenshot();4920 return assert.strictEqual(platform, "", e);4921 }4922});4923When(4924 /^I tap on "([^"]*)" button on (?:Lilly Answer Center screen|Manufacturer screen|Unique Device Identifier screen|Login Instructions screen)$/,4925 async function(object) {4926 try {4927 switch (platform) {4928 case "android":4929 let exists1 = browser.waitUntil(4930 function() {4931 return browser4932 .element(fileutils.readPropertyFile(platform, object))4933 .click();4934 },4935 timeOutinMs,4936 "Element not found"4937 );4938 if (exists1) {4939 console.log("Clicked on " + object);4940 ////browser.saveScreenshot();4941 }4942 break;4943 case "ios":4944 let exists = browser.waitUntil(4945 function() {4946 return browser4947 .element(fileutils.readPropertyFile(platform, object))4948 .click();4949 },4950 timeOutinMs,4951 "Element not found"4952 );4953 if (exists) {4954 console.log("Clicked on " + object);4955 ////browser.saveScreenshot();4956 }4957 break;4958 case "web":4959 // perform operation on web element4960 break;4961 }4962 } catch (e) {4963 console.error(" Cannot click on " + object + e);4964 //browser.saveScreenshot();4965 return assert.strictEqual(platform, "", e);4966 }4967 }4968);4969When(/^I navigate to back application$/, async function() {4970 try {4971 switch (platform) {4972 case "android":4973 while (browser.getCurrentPackage() != "com.lilly.ddcs.madelyne") {4974 browser.pressKeycode(4);4975 }4976 break;4977 case "ios":4978 break;4979 case "web":4980 // perform operation on web element4981 break;4982 }4983 } catch (e) {4984 console.error(" Cannot BACK");4985 //browser.saveScreenshot();4986 return assert.strictEqual(platform, "", e);4987 }4988});4989When(/^I Swipe Down "([^"]*)"$/, async function(object) {4990 try {4991 switch (platform) {4992 case "android":4993 try {4994 while (4995 !browser.isVisible(fileutils.readPropertyFile(platform, object))4996 ) {4997 mobileactions.swipeDown(0.39);4998 }4999 if (browser.isVisible(fileutils.readPropertyFile(platform, object))) {5000 console.log("Object is found");5001 }5002 } catch (e) {5003 console.error(object + " is not displayed");5004 }5005 ////browser.saveScreenshot();5006 break;5007 case "ios":5008 try {5009 // mobileactions.swipeDown(0.40);5010 while (5011 !browser.isVisible(fileutils.readPropertyFile(platform, object))5012 ) {5013 // while (!browser.isVisible(`${fileutils.readPropertyFile(platform, 'you.have.reached.end')}`)){5014 mobileactions.swipeDown(0.4);5015 }5016 if (browser.isVisible(fileutils.readPropertyFile(platform, object))) {5017 console.log("Object is found");5018 }5019 } catch (e) {5020 console.error(object + " is not displayed");5021 }5022 ////browser.saveScreenshot();5023 break;5024 case "web":5025 // perform operation on web element5026 break;5027 }5028 } catch (e) {5029 console.error(" Cannot swipe " + e);5030 //browser.saveScreenshot();5031 return assert.strictEqual(platform, "", e);5032 }5033});5034When(/^I selected "([^"]*)"$/, async function(object) {5035 try {5036 switch (platform) {5037 case "android":5038 expect(5039 browser.element(fileutils.readPropertyFile(platform, object))5040 .isExisting5041 );5042 console.log(object + " is visible");5043 ////browser.saveScreenshot();5044 break;5045 case "ios":5046 let exits = browser.waitUntil(5047 function() {5048 return browser5049 .element(fileutils.readPropertyFile(platform, object))5050 .click();5051 },5052 timeOutinMs,5053 "Error: Element not found"5054 );5055 if (exits) {5056 console.log(object + " is selected");5057 } else {5058 console.log("Already selected");5059 }5060 break;5061 case "web":5062 break;5063 }5064 } catch (e) {5065 console.error(" Cannot find " + object);5066 //browser.saveScreenshot();5067 return assert.strictEqual(platform, "", e);5068 }5069});5070When(/^I unselected "([^"]*)"$/, async function(object) {5071 try {5072 switch (platform) {5073 case "android":5074 expect(5075 browser.element(fileutils.readPropertyFile(platform, object))5076 .isExisting5077 );5078 console.log(object + " is visible");5079 ////browser.saveScreenshot();5080 break;5081 case "ios":5082 let exits = browser.waitUntil(5083 function() {5084 return browser5085 .element(fileutils.readPropertyFile(platform, object))5086 .click();5087 },5088 timeOutinMs,5089 "Error: Element not found"5090 );5091 if (exits) {5092 console.log(object + " is unselected");5093 }5094 break;5095 case "web":5096 // perform operation on web element5097 break;5098 }5099 } catch (e) {5100 console.error(" Cannot find " + object);5101 //browser.saveScreenshot();5102 return assert.strictEqual(platform, "", e);5103 }5104});5105When(/^I select "([^"]*)" from picker$/, async function(object) {5106 try {5107 switch (platform) {5108 case "android":5109 let exists1 = browser.waitUntil(5110 function() {5111 return browser5112 .element(fileutils.readPropertyFile(platform, object))5113 .click();5114 },5115 timeOutinMs,5116 "Element not found"5117 );5118 if (exists1) {5119 console.log("Clicked on " + object);5120 ////browser.saveScreenshot();5121 }5122 break;5123 case "ios":5124 let breakfast = browser.element(5125 fileutils.readPropertyFile(platform, "breakfast")5126 );5127 let lunch = browser.element(5128 fileutils.readPropertyFile(platform, "lunch")5129 );5130 let dinner = browser.element(5131 fileutils.readPropertyFile(platform, "dinner")5132 );5133 let bedtime = browser.element(5134 fileutils.readPropertyFile(platform, "bedtime")5135 );5136 if (breakfast.isVisible()) {5137 mobileElementAction.selectValueFromPicker(5138 fileutils.readPropertyFile(platform, object),5139 "ap"5140 );5141 } else if (lunch.isVisible()) {5142 console.log("lunchtime");5143 mobileElementAction.selectValueFromPicker(5144 fileutils.readPropertyFile(platform, object),5145 "PM"5146 );5147 } else if (dinner.isVisible()) {5148 console.log("dinnertime");5149 mobileElementAction.selectValueFromPicker(5150 fileutils.readPropertyFile(platform, object),5151 "PM"5152 );5153 } else if (bedtime.isVisible()) {5154 console.log("bedtime");5155 mobileElementAction.selectValueFromPicker(5156 fileutils.readPropertyFile(platform, object),5157 "PM"5158 );5159 } else {5160 console.error("timeformat is" + "24 format");5161 }5162 break;5163 case "web":5164 // perform operation on web element5165 break;5166 }5167 } catch (e) {5168 console.error(" Cannot find " + object);5169 //browser.saveScreenshot();5170 return assert.strictEqual(platform, "", e);5171 }5172});5173When(/^I select "([^"]*)" from timepicker$/, async function(object) {5174 try {5175 switch (platform) {5176 case "android":5177 let exists1 = browser.waitUntil(5178 function() {5179 return browser5180 .element(fileutils.readPropertyFile(platform, object))5181 .click();5182 },5183 timeOutinMs,5184 "Element not found"5185 );5186 if (exists1) {5187 console.log("Clicked on " + object);5188 ////browser.saveScreenshot();5189 }5190 break;5191 case "ios":5192 let breakfast = browser.element(5193 fileutils.readPropertyFile(platform, "Breakfast")5194 );5195 let lunch = browser.element(5196 fileutils.readPropertyFile(platform, "Lunch")5197 );5198 let dinner = browser.element(5199 fileutils.readPropertyFile(platform, "Dinner")5200 );5201 let bedtime = browser.element(5202 fileutils.readPropertyFile(platform, "Bedtime")5203 );5204 if (breakfast.isVisible()) {5205 if (object === "Hour") {5206 mobileElementAction.selectValueFromPicker(5207 fileutils.readPropertyFile(platform, object),5208 fileutils.readPropertyFile("data", "breakfasthour")5209 );5210 } else if (object === "Minutes") {5211 mobileElementAction.selectValueFromPicker(5212 fileutils.readPropertyFile(platform, object),5213 fileutils.readPropertyFile("data", "breakfastminutes")5214 );5215 } else {5216 console.log("no breakfasttime");5217 }5218 } else if (lunch.isVisible()) {5219 if (object === "Hour") {5220 mobileElementAction.selectValueFromPicker(5221 fileutils.readPropertyFile(platform, object),5222 fileutils.readPropertyFile("data", "lunchtimehour")5223 );5224 } else if (object === "Minutes") {5225 mobileElementAction.selectValueFromPicker(5226 fileutils.readPropertyFile(platform, object),5227 fileutils.readPropertyFile("data", "lunchtimeminutes")5228 );5229 } else {5230 console.log("no lunchtime");5231 }5232 } else if (dinner.isVisible()) {5233 if (object === "Hour") {5234 mobileElementAction.selectValueFromPicker(5235 fileutils.readPropertyFile(platform, object),5236 fileutils.readPropertyFile("data", "dinnertimehour")5237 );5238 } else if (object === "Minutes") {5239 mobileElementAction.selectValueFromPicker(5240 fileutils.readPropertyFile(platform, object),5241 fileutils.readPropertyFile("data", "dinnertimeminutes")5242 );5243 } else {5244 }5245 } else if (bedtime.isVisible()) {5246 if (object === "Hour") {5247 mobileElementAction.selectValueFromPicker(5248 fileutils.readPropertyFile(platform, object),5249 fileutils.readPropertyFile("data", "bedtimehour")5250 );5251 } else if (object === "Minutes") {5252 mobileElementAction.selectValueFromPicker(5253 fileutils.readPropertyFile(platform, object),5254 fileutils.readPropertyFile("data", "bedtimeminutes")5255 );5256 } else {5257 }5258 } else {5259 console.log("object is not found");5260 }5261 break;5262 case "web":5263 // perform operation on web element5264 break;5265 }5266 } catch (e) {5267 console.error(" Cannot click on " + object + e);5268 //browser.saveScreenshot();5269 return assert.strictEqual(platform, "", e);5270 }5271});5272When(/^I select "([^"]*)" from timepicker24hrs$/, async function(object) {5273 try {5274 switch (platform) {5275 case "android":5276 let exists1 = browser.waitUntil(5277 function() {5278 return browser5279 .element(fileutils.readPropertyFile(platform, object))5280 .click();5281 },5282 timeOutinMs,5283 "Element not found"5284 );5285 if (exists1) {5286 console.log("Clicked on " + object);5287 ////browser.saveScreenshot();5288 }5289 break;5290 case "ios":5291 let breakfast = browser.element(5292 fileutils.readPropertyFile(platform, "Breakfast")5293 );5294 let lunch = browser.element(5295 fileutils.readPropertyFile(platform, "Lunch")5296 );5297 let dinner = browser.element(5298 fileutils.readPropertyFile(platform, "Dinner")5299 );5300 let bedtime = browser.element(5301 fileutils.readPropertyFile(platform, "Bedtime")5302 );5303 if (breakfast.isVisible()) {5304 if (object === "Hour") {5305 mobileElementAction.selectValueFromPicker(5306 fileutils.readPropertyFile(platform, object),5307 fileutils.readPropertyFile("data", "breakfasthour24")5308 );5309 } else if (object === "Minutes") {5310 mobileElementAction.selectValueFromPicker(5311 fileutils.readPropertyFile(platform, object),5312 fileutils.readPropertyFile("data", "breakfastminutes24")5313 );5314 } else {5315 console.log("no breakfasttime");5316 }5317 } else if (lunch.isVisible()) {5318 if (object === "Hour") {5319 mobileElementAction.selectValueFromPicker(5320 fileutils.readPropertyFile(platform, object),5321 fileutils.readPropertyFile("data", "lunchtimehour24")5322 );5323 } else if (object === "Minutes") {5324 mobileElementAction.selectValueFromPicker(5325 fileutils.readPropertyFile(platform, object),5326 fileutils.readPropertyFile("data", "lunchtimeminutes24")5327 );5328 } else {5329 console.log("no lunchtime");5330 }5331 } else if (dinner.isVisible()) {5332 if (object === "Hour") {5333 mobileElementAction.selectValueFromPicker(5334 fileutils.readPropertyFile(platform, object),5335 fileutils.readPropertyFile("data", "dinnertimehour24")5336 );5337 } else if (object === "Minutes") {5338 mobileElementAction.selectValueFromPicker(5339 fileutils.readPropertyFile(platform, object),5340 fileutils.readPropertyFile("data", "dinnertimeminutes24")5341 );5342 } else {5343 }5344 } else if (bedtime.isVisible()) {5345 if (object === "Hour") {5346 mobileElementAction.selectValueFromPicker(5347 fileutils.readPropertyFile(platform, object),5348 fileutils.readPropertyFile("data", "bedtimehour24")5349 );5350 } else if (object === "Minutes") {5351 mobileElementAction.selectValueFromPicker(5352 fileutils.readPropertyFile(platform, object),5353 fileutils.readPropertyFile("data", "bedtimeminutes24")5354 );5355 } else {5356 }5357 } else {5358 console.log("object is not found");5359 }5360 break;5361 case "web":5362 // perform operation on web element5363 break;5364 }5365 } catch (e) {5366 console.error(" Cannot click on " + object + e);5367 //browser.saveScreenshot();5368 return assert.strictEqual(platform, "", e);5369 }5370});5371When(/^I select "([^"]*)" from reminderpicker$/, async function(object) {5372 try {5373 switch (platform) {5374 case "android":5375 let exists1 = browser.waitUntil(5376 function() {},5377 timeOutinMs,5378 "Element not found"5379 );5380 if (exists1) {5381 ////browser.saveScreenshot();5382 }5383 break;5384 case "ios":5385 let breakfast = browser.element(5386 fileutils.readPropertyFile(platform, "Breakfast")5387 );5388 let lunch = browser.element(5389 fileutils.readPropertyFile(platform, "Lunch")5390 );5391 let dinner = browser.element(5392 fileutils.readPropertyFile(platform, "Dinner")5393 );5394 let bedtime = browser.element(5395 fileutils.readPropertyFile(platform, "Bedtime")5396 );5397 if (breakfast.isVisible()) {5398 if (5399 fileutils.readPropertyFile("data", "breakfastreminder") ===5400 "5 minutes before"5401 ) {5402 console.log("breakfast reminder");5403 mobileElementAction.selectValueFromPicker(5404 fileutils.readPropertyFile(platform, object),5405 fileutils.readPropertyFile("data", "breakfastreminder")5406 );5407 }5408 } else if (lunch.isVisible()) {5409 if (5410 fileutils.readPropertyFile("data", "lunchreminder") ===5411 "15 minutes before"5412 ) {5413 console.log("lunch reminder");5414 mobileElementAction.selectValueFromPicker(5415 fileutils.readPropertyFile(platform, object),5416 fileutils.readPropertyFile("data", "lunchreminder")5417 );5418 }5419 } else if (dinner.isVisible()) {5420 if (5421 fileutils.readPropertyFile("data", "dinnerreminder") ===5422 "30 minutes before"5423 ) {5424 console.log("dinner reminder");5425 mobileElementAction.selectValueFromPicker(5426 fileutils.readPropertyFile(platform, object),5427 fileutils.readPropertyFile("data", "dinnerreminder")5428 );5429 }5430 } else if (bedtime.isVisible()) {5431 if (5432 fileutils.readPropertyFile("data", "bedtimereminder") ===5433 "1 Hour before"5434 ) {5435 console.log("bedtime reminder");5436 mobileElementAction.selectValueFromPicker(5437 fileutils.readPropertyFile(platform, object),5438 fileutils.readPropertyFile("data", "bedtimereminder")5439 );5440 }5441 } else {5442 console.log("no reminder");5443 }5444 browser.pause(1000);5445 break;5446 case "web":5447 // perform operation on web element5448 break;5449 }5450 } catch (e) {5451 //browser.saveScreenshot();5452 return assert.strictEqual(platform, "", e);5453 }5454});5455When(5456 /^I select "([^"]*)" in "([^"]*)" field in "([^"]*)" block$/,5457 async (value, object, block) => {5458 try {5459 switch (platform) {5460 case "android":5461 //android code here5462 case "ios":5463 let exists = browser.waitUntil(5464 function() {5465 return browser5466 .element(fileutils.readPropertyFile(platform, block))5467 .isVisible();5468 },5469 timeOutinMs,5470 "Element not found"5471 );5472 if (exists) {5473 if (5474 `${fileutils.readPropertyFile("data", value)}`.indexOf('"') == -15475 ) {5476 mobileElementAction.selectValueFromPicker(5477 fileutils.readPropertyFile(platform, object),5478 fileutils.readPropertyFile("data", value)5479 );5480 console.log(5481 "Selected " +5482 fileutils.readPropertyFile("data", value) +5483 " in " +5484 object +5485 " field"5486 );5487 ////browser.saveScreenshot();5488 } else {5489 let data = `${fileutils.readPropertyFile("data", value)}`.replace(5490 /"/g,5491 ""5492 );5493 mobileElementAction.selectValueFromPicker(5494 fileutils.readPropertyFile(platform, object),5495 data5496 );5497 console.log("Selected " + data + " in " + object + " field");5498 ////browser.saveScreenshot();5499 }5500 }5501 break;5502 case "web":5503 // perform operation on web element5504 break;5505 }5506 } catch (e) {5507 console.error(" Cannot select " + object + e);5508 //browser.saveScreenshot();5509 return assert.strictEqual(platform, "", e);5510 }5511 }5512);5513When(/^I hide device keyboard$/, async () => {5514 try {5515 switch (platform) {5516 case "android":5517 if (browser.isKeyboardShown()) {5518 console.log("keyboard is shown");5519 mobileactions.hideDeviceKeyboard();5520 console.log("hidden");5521 } else {5522 console.log("no keyboard");5523 }5524 break;5525 case "ios":5526 if (browser.isKeyboardShown()) {5527 console.log("keyboard is shown");5528 mobileactions.hideDeviceKeyboardIOS();5529 console.log("hidden");5530 } else {5531 console.log("no keyboard");5532 }5533 break;5534 }5535 } catch (e) {5536 console.log("Cannot hide keyboard" + e);5537 //browser.saveScreenshot();5538 return assert.strictEqual(platform, "", e);5539 }5540});5541When(/^I choose "([^"]*)" option as "([^"]*)"$/, async (object, value) => {5542 try {5543 switch (platform) {5544 case "android":5545 browser.waitUntil(5546 function() {5547 return browser5548 .element(fileutils.readPropertyFile(platform, object))5549 .isVisible();5550 },5551 timeOutinMs,5552 "Element not found"5553 );5554 let list = $$(fileutils.readPropertyFile(platform, "list.item"));5555 var index;5556 for (index = 0; index < list.length; index++) {5557 if (index == value) {5558 list[index].click();5559 break;5560 }5561 }5562 break;5563 case "ios":5564 break;5565 case "web":5566 // perform operation on web element5567 break;5568 }5569 } catch (e) {5570 console.error(" Cannot choose " + object + e);5571 //browser.saveScreenshot();5572 return assert.strictEqual(platform, "", e);5573 }5574});5575When(/^I should clear "([^"]*)" in field$/, async object => {5576 try {5577 switch (platform) {5578 case "android":5579 browser.waitUntil(5580 () =>5581 browser5582 .element(`${fileutils.readPropertyFile(platform, object)}`)5583 .isVisible(),5584 timeOutinMs,5585 "Element not found"5586 );5587 mobileElementAction.clearTextBox(5588 `${fileutils.readPropertyFile(platform, object)}`5589 );5590 ////browser.saveScreenshot();5591 break;5592 case "ios":5593 break;5594 case "web":5595 // perform operation on web element5596 break;5597 default:5598 break;5599 }5600 } catch (e) {5601 console.error(` Cannot clear ${object}\n${e}`);5602 //browser.saveScreenshot();5603 return assert.strictEqual(platform, "", e);5604 }5605});5606When(/^I select "([^"]*)" in "([^"]*)" block$/, async (text, checkbox) => {5607 try {5608 switch (platform) {5609 case "android":5610 let exists1 = browser.waitUntil(5611 function() {5612 return browser5613 .element(fileutils.readPropertyFile(platform, text))5614 .isVisible();5615 },5616 timeOutinMs,5617 "Element not found"5618 );5619 if (exists1) {5620 if (5621 browser5622 .element(fileutils.readPropertyFile(platform, object))5623 .getAttribute("checked") == "true"5624 ) {5625 console.log(5626 object + "is already Selected " + " in " + block + " field"5627 );5628 ////browser.saveScreenshot();5629 } else {5630 $(fileutils.readPropertyFile(platform, object)).click();5631 console.log("Selected " + object + " in " + block + " field");5632 ////browser.saveScreenshot();5633 }5634 }5635 case "ios":5636 break;5637 case "web":5638 // perform operation on web element5639 break;5640 }5641 } catch (e) {5642 console.error(" Cannot click on " + object + e);5643 //browser.saveScreenshot();5644 return assert.strictEqual(platform, "", e);5645 }5646});5647When(/^I Swipe Down till "([^"]*)" in "([^"]*)"$/, async function(5648 object,5649 value5650) {5651 try {5652 switch (platform) {5653 case "android":5654 try {5655 while (5656 !browser.isVisible(fileutils.readPropertyFile(platform, object))5657 ) {5658 mobileactions.swipe_down(value);5659 }5660 } catch (e) {5661 console.error(object + " is not displayed");5662 }5663 mobileactions.swipe_down(value);5664 console.log(object + " is found");5665 ////browser.saveScreenshot();5666 break;5667 case "ios":5668 try {5669 //mobileactions.swipeDown(0.60);5670 while (5671 !browser.isVisible(fileutils.readPropertyFile(platform, object))5672 ) {5673 mobileactions.swipeDown(0.4);5674 }5675 if (browser.isVisible(fileutils.readPropertyFile(platform, object))) {5676 console.log("Object is found");5677 }5678 } catch (e) {5679 console.error(object + " is not displayed");5680 }5681 ////browser.saveScreenshot();5682 break;5683 case "web":5684 // perform operation on web element5685 break;5686 }5687 } catch (e) {5688 console.error(" Cannot swipe " + e);5689 //browser.saveScreenshot();5690 return assert.strictEqual(platform, "", e);5691 }5692});5693When(/^I uninstall app$/, async () => {5694 try {5695 switch (platform) {5696 case "android":5697 while (browser.getCurrentPackage() == "com.lilly.ddcs.madelyne") {5698 //browser.removeApp(bundleId);5699 browser.removeApp("com.lilly.ddcs.madelyne");5700 }5701 console.log("Uninstalled application ");5702 break;5703 case "ios":5704 const exists = browser.waitUntil(5705 () => browser.execute("mobile: activateApp", { bundleId: bundleid }),5706 timeOutinMs,5707 "Error: App not found"5708 );5709 if (exists) {5710 console.log(" Launched application ");5711 ////browser.saveScreenshot();5712 }5713 break;5714 case "web":5715 // perform operation on web5716 break;5717 default:5718 break;5719 }5720 } catch (e) {5721 console.error("Cannot Activate Application");5722 //browser.saveScreenshot();5723 return assert.strictEqual(platform, "", e);5724 }5725});5726When(/^I reinstall app$/, async () => {5727 try {5728 switch (platform) {5729 case "android":5730 while (browser.getCurrentPackage() != "com.lilly.ddcs.madelyne") {5731 //browser.installApp(path);5732 browser.installApp(5733 "/Users/sureshvpatil/Downloads/Lilly_Framework/apps/Tempo_0.3.1.apk"5734 );5735 browser.pause(2000);5736 console.log("Reinstalled application ");5737 browser.launch();5738 // browser.acceptAlert();5739 // browser.element(fileutils.readPropertyFile(platform, "allow.notification")).click();5740 console.log("Launched the application ");5741 browser.pause(5000);5742 // browser.startActivity("com.google.android.packageinstaller", "com.android.packageinstaller.permission.ui.GrantPermissionsActivity");5743 // browser.element(fileutils.readPropertyFile(platform, "allow.notification")).click();5744 }5745 console.log("Clicked on Allow button");5746 break;5747 case "ios":5748 const exists = browser.waitUntil(5749 () => browser.execute("mobile: activateApp", { bundleId: bundleid }),5750 timeOutinMs,5751 "Error: App not found"5752 );5753 if (exists) {5754 console.log(" Launched application ");5755 ////browser.saveScreenshot();5756 }5757 break;5758 case "web":5759 // perform operation on web5760 break;5761 default:5762 break;5763 }5764 } catch (e) {5765 console.error("Cannot Activate Application");5766 //browser.saveScreenshot();5767 return assert.strictEqual(platform, "", e);5768 }5769});5770When(/^I should see CurrentTime in "([^"]*)" field$/, async object => {5771 try {5772 switch (platform) {5773 case "android":5774 let currenttime1 = utils.getcurrenttime1();5775 let ampm = currenttime1.split(" ")[1];5776 let curtime = currenttime1.replace(ampm, ampm.toLocaleLowerCase());5777 let apptime1 = browser5778 .element(`${fileutils.readPropertyFile(platform, object)}`)5779 .getAttribute("text");5780 console.log(apptime1 + " " + curtime);5781 if (curtime === apptime1) {5782 console.log("current time is displayed");5783 } else {5784 console.log("current time not displayed");5785 }5786 ////browser.saveScreenshot();5787 break;5788 case "ios":5789 // ios code here5790 let currenttime = utils.getcurrenttime1();5791 let ampm1 = currenttime.split(" ")[1];5792 let curtime1 = currenttime.replace(ampm1, ampm1.toLocaleLowerCase());5793 let apptime = browser5794 .element(`${fileutils.readPropertyFile(platform, object)}`)5795 .getAttribute("value");5796 console.log(apptime + " " + curtime1);5797 if (curtime1 === apptime) {5798 console.log("current time is displayed");5799 } else {5800 console.log("current time not displayed");5801 }5802 ////browser.saveScreenshot();5803 break;5804 case "web":5805 // perform operation on web element5806 break;5807 default:5808 break;5809 }5810 } catch (e) {5811 console.error(" Cannot find date ");5812 //browser.saveScreenshot();5813 return assert.strictEqual(platform, "", e);5814 }5815});5816When(5817 /^I should see CurrentTime in 24 hour format in "([^"]*)" field$/,5818 async object => {5819 try {5820 switch (platform) {5821 case "android":5822 let currenttime1 = utils.getcurrenttime24();5823 let apptime1 = browser5824 .element(`${fileutils.readPropertyFile(platform, object)}`)5825 .getAttribute("text");5826 console.log("Current time is displayed :" + apptime1);5827 ////browser.saveScreenshot();5828 break;5829 case "ios":5830 // ios code here5831 let currenttime = utils.getcurrenttime24();5832 let apptime = browser5833 .element(`${fileutils.readPropertyFile(platform, object)}`)5834 .getAttribute("value");5835 console.log(apptime + " " + currenttime);5836 if (currenttime === apptime) {5837 console.log("current time is displayed");5838 } else {5839 console.log("current time not displayed");5840 }5841 ////browser.saveScreenshot();5842 break;5843 case "web":5844 // perform operation on web element5845 break;5846 default:5847 break;5848 }5849 } catch (e) {5850 console.error(" Cannot find date ");5851 //browser.saveScreenshot();5852 return assert.strictEqual(platform, "", e);5853 }5854 }5855);5856When(/^I select CurrentYear in "([^"]*)" List$/, async object => {5857 try {5858 switch (platform) {5859 case "android":5860 break;5861 case "ios":5862 let CurrentYear = utils.getCurrentYear();5863 if (object === "year") {5864 mobileElementAction.selectValueFromPicker(5865 fileutils.readPropertyFile(platform, object),5866 CurrentYear5867 );5868 }5869 ////browser.saveScreenshot();5870 break;5871 case "web":5872 // perform operation on web element5873 break;5874 default:5875 break;5876 }5877 } catch (e) {5878 console.error(" Cannot find date ");5879 //browser.saveScreenshot();5880 return assert.strictEqual(platform, "", e);5881 }5882});5883When(5884 /^I should (?:not see|see) "([^"]*)" in "([^"]*)" field$/,5885 async (value, object) => {5886 try {5887 let val = value;5888 switch (platform) {5889 case "android":5890 const exists = browser.waitUntil(5891 () =>5892 browser5893 .element(`${fileutils.readPropertyFile(platform, object)}`)5894 .isVisible(),5895 timeOutinMs,5896 "Element not found"5897 );5898 if (exists) {5899 if (val == "space") {5900 const space = browser5901 .element(`${fileutils.readPropertyFile(platform, object)}`)5902 .getAttribute("text");5903 if (space === "\t") {5904 console.log(value + " entered in " + object + " field ");5905 } else {5906 console.log(value + " not entered in " + object + " field ");5907 }5908 ////browser.saveScreenshot();5909 } else if (value == "past.date") {5910 const enteredValue = browser5911 .element(`${fileutils.readPropertyFile(platform, object)}`)5912 .getAttribute("text");5913 if (enteredValue == pastDate) {5914 console.log(value + " entered in " + object + " field ");5915 } else {5916 console.log(value + " not entered in " + object + " field ");5917 }5918 ////browser.saveScreenshot();5919 } else if (object == "mg.dl.logbook.screen") {5920 // let val1=fileutils.readPropertyFile("data", value)5921 const enteredValue = browser5922 .element(`${fileutils.readPropertyFile(platform, object)}`)5923 .getAttribute("text");5924 if (enteredValue.indexOf(value) == -1) {5925 console.log(value + " not entered in " + object + " field ");5926 } else {5927 console.log(value + " entered in " + object + " field ");5928 }5929 ////browser.saveScreenshot();5930 } else if (object == "grams.logbook.screen") {5931 // let val1=fileutils.readPropertyFile("data", value)5932 const enteredValue = browser5933 .element(`${fileutils.readPropertyFile(platform, object)}`)5934 .getAttribute("text");5935 if (enteredValue.indexOf(value) == -1) {5936 console.log(value + " not entered in " + object + " field ");5937 } else {5938 console.log(value + " entered in " + object + " field ");5939 }5940 ////browser.saveScreenshot();5941 } else if (object == "mg.dl.logbook.screen1") {5942 // let val1=fileutils.readPropertyFile("data", value)5943 const enteredValue = browser5944 .element(`${fileutils.readPropertyFile(platform, object)}`)5945 .getAttribute("text");5946 if (enteredValue.indexOf(value) == -1) {5947 console.log(value + " not entered in " + object + " field ");5948 } else {5949 console.log(value + " entered in " + object + " field ");5950 }5951 ////browser.saveScreenshot();5952 } else if (object == "grams.logbook.screen1") {5953 // let val1=fileutils.readPropertyFile("data", value)5954 const enteredValue = browser5955 .element(`${fileutils.readPropertyFile(platform, object)}`)5956 .getAttribute("text");5957 if (enteredValue.indexOf(value) == -1) {5958 console.log(value + " not entered in " + object + " field ");5959 } else {5960 console.log(value + " entered in " + object + " field ");5961 }5962 ////browser.saveScreenshot();5963 } else if (object == "below.range") {5964 // let val1=fileutils.readPropertyFile("data", value)5965 const enteredValue = browser5966 .element(`${fileutils.readPropertyFile(platform, object)}`)5967 .getAttribute("text");5968 if (enteredValue.indexOf(value) == -1) {5969 console.log(value + " not entered in " + object + " field ");5970 } else {5971 console.log(value + " entered in " + object + " field ");5972 }5973 } else if (object == "mg.dl.logbook") {5974 // let val1=fileutils.readPropertyFile("data", value)5975 const enteredValue = browser5976 .element(`${fileutils.readPropertyFile(platform, object)}`)5977 .getAttribute("text");5978 if (enteredValue.indexOf(value) == -1) {5979 console.log(value + " not entered in " + object + " field ");5980 } else {5981 console.log(value + " entered in " + object + " field ");5982 }5983 } else if (object == "units") {5984 // let val1=fileutils.readPropertyFile("data", value)5985 const enteredValue = browser5986 .element(`${fileutils.readPropertyFile(platform, object)}`)5987 .getAttribute("text");5988 if (enteredValue.indexOf(value) == -1) {5989 console.log(value + " not entered in " + object + " field ");5990 } else {5991 console.log(value + " entered in " + object + " field ");5992 }5993 } else if (object == "longacting.units") {5994 // let val1=fileutils.readPropertyFile("data", value)5995 const enteredValue = browser5996 .element(`${fileutils.readPropertyFile(platform, object)}`)5997 .getAttribute("text");5998 if (enteredValue.indexOf(value) == -1) {5999 console.log(value + " not entered in " + object + " field ");6000 } else {6001 console.log(value + " entered in " + object + " field ");6002 }6003 } else if (object == "blood.sugar.home") {6004 // let val1=fileutils.readPropertyFile("data", value)6005 const enteredValue = browser6006 .element(`${fileutils.readPropertyFile(platform, object)}`)6007 .getAttribute("text");6008 if (enteredValue.indexOf(value) == -1) {6009 console.log(value + " not entered in " + object + " field ");6010 } else {6011 console.log(value + " entered in " + object + " field ");6012 }6013 } else if (object == "mealtime.insulin.home") {6014 // let val1=fileutils.readPropertyFile("data", value)6015 const enteredValue = browser6016 .element(`${fileutils.readPropertyFile(platform, object)}`)6017 .getAttribute("text");6018 if (enteredValue.indexOf(value) == -1) {6019 console.log(value + " not entered in " + object + " field ");6020 } else {6021 console.log(value + " entered in " + object + " field ");6022 }6023 } else if (object == "longacting.insulin.home") {6024 // let val1=fileutils.readPropertyFile("data", value)6025 const enteredValue = browser6026 .element(`${fileutils.readPropertyFile(platform, object)}`)6027 .getAttribute("text");6028 if (enteredValue.indexOf(value) == -1) {6029 console.log(value + " not entered in " + object + " field ");6030 } else {6031 console.log(value + " entered in " + object + " field ");6032 }6033 } else if (object == "carbs.intake.home") {6034 // let val1=fileutils.readPropertyFile("data", value)6035 const enteredValue = browser6036 .element(`${fileutils.readPropertyFile(platform, object)}`)6037 .getAttribute("text");6038 if (enteredValue.indexOf(value) == -1) {6039 console.log(value + " not entered in " + object + " field ");6040 } else {6041 console.log(value + " entered in " + object + " field ");6042 }6043 }6044 else if (object == "logbook.health.factors") {6045 let val1=fileutils.readPropertyFile("data", value)6046 const enteredValue = browser6047 .element(`${fileutils.readPropertyFile(platform, object)}`)6048 .getAttribute("text");6049 if (enteredValue == val1) {6050 console.log(value + " entered in " + object + " field ");6051 } else {6052 console.log(value + " not entered in " + object + " field ");6053 }6054 ////browser.saveScreenshot();6055 }6056 else if (object == "logbook.health.factors.date") {6057 // let val1=fileutils.readPropertyFile("data", value)6058 const enteredValue = browser6059 .element(`${fileutils.readPropertyFile(platform, object)}`)6060 .getAttribute("text");6061 if (enteredValue.indexOf(value) == -1) {6062 console.log(value + " entered in " + object + " field ");6063 } else {6064 console.log(value + " not entered in " + object + " field ");6065 }6066 ////browser.saveScreenshot();6067 }6068 else if (object == "logbook.health.factors.time") {6069 // let val1=fileutils.readPropertyFile("data", value)6070 const enteredValue = browser6071 .element(`${fileutils.readPropertyFile(platform, object)}`)6072 .getAttribute("text");6073 if (enteredValue.indexOf(value) == -1) {6074 console.log(value + " entered in " + object + " field ");6075 } else {6076 console.log(value + " not entered in " + object + " field ");6077 }6078 ////browser.saveScreenshot();6079 }6080 else if (object == "mealtime.popup.units") {6081 let val1=fileutils.readPropertyFile("data", value)6082 const enteredValue = browser6083 .element(`${fileutils.readPropertyFile(platform, object)}`)6084 .getAttribute("text");6085 if (enteredValue == val1) {6086 console.log(value + " entered in " + object + " field ");6087 } else {6088 console.log(value + " not entered in " + object + " field ");6089 }6090 ////browser.saveScreenshot();6091 }6092 else if (object == "longacting.popup.units") {6093 let val1=fileutils.readPropertyFile("data", value)6094 const enteredValue = browser6095 .element(`${fileutils.readPropertyFile(platform, object)}`)6096 .getAttribute("text");6097 if (enteredValue == val1) {6098 console.log(value + " entered in " + object + " field ");6099 } else {6100 console.log(value + " not entered in " + object + " field ");6101 }6102 ////browser.saveScreenshot();6103 }6104 else if (object == "blood.sugar.popup.mg.dl") {6105 let val1=fileutils.readPropertyFile("data", value)6106 const enteredValue = browser6107 .element(`${fileutils.readPropertyFile(platform, object)}`)6108 .getAttribute("text");6109 if (enteredValue == val1) {6110 console.log(value + " entered in " + object + " field ");6111 } else {6112 console.log(value + " not entered in " + object + " field ");6113 }6114 ////browser.saveScreenshot();6115 }6116 else if (object == "carb.intake.popup.grams") {6117 let val1=fileutils.readPropertyFile("data", value)6118 const enteredValue = browser6119 .element(`${fileutils.readPropertyFile(platform, object)}`)6120 .getAttribute("text");6121 if (enteredValue == val1) {6122 console.log(value + " entered in " + object + " field ");6123 } else {6124 console.log(value + " not entered in " + object + " field ");6125 }6126 ////browser.saveScreenshot();6127 }6128 else if (object == "grams") {6129 // let val1=fileutils.readPropertyFile("data", value)6130 const enteredValue = browser6131 .element(`${fileutils.readPropertyFile(platform, object)}`)6132 .getAttribute("text");6133 if (enteredValue.indexOf(value) == -1) {6134 console.log(value + " not entered in " + object + " field ");6135 } else {6136 console.log(value + " entered in " + object + " field ");6137 }6138 } else if (object == "logbook.grams") {6139 // let val1=fileutils.readPropertyFile("data", value)6140 const enteredValue = browser6141 .element(`${fileutils.readPropertyFile(platform, object)}`)6142 .getAttribute("text");6143 if (enteredValue.indexOf(value) == -1) {6144 console.log(value + " not entered in " + object + " field ");6145 } else {6146 console.log(value + " entered in " + object + " field ");6147 }6148 } else if (value == "past.time") {6149 // let finaldata2 = new Date().getHours();6150 if (pastHour >= 12) {6151 pastTime = pastHour + ":" + pastMinute + " pm";6152 console.log(pastTime);6153 } else {6154 pastTime = pastHour + ":" + pastMinute + " am";6155 console.log(pastTime);6156 }6157 const enteredValue1 = browser6158 .element(`${fileutils.readPropertyFile(platform, object)}`)6159 .getAttribute("text");6160 console.log(enteredValue1);6161 if (enteredValue1 == pastTime) {6162 console.log(value + " entered in " + object + " field ");6163 } else {6164 console.log(value + " not entered in " + object + " field ");6165 }6166 ////browser.saveScreenshot();6167 } 6168 else if (value == 'device.past.time') {6169 // let finaldata2 = new Date().getHours();6170 if (pastHour >= 12) {6171 pastTime = pastHour + ":" + pastMinute + " pm"6172 console.log(pastTime)6173 }6174 else {6175 pastTime = pastHour + ":" + pastMinute + " am"6176 console.log(pastTime)6177 }6178 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('text');6179 console.log(enteredValue1)6180 if (enteredValue1 == pastTime) {6181 console.log(value + " entered in " + object + " field ");6182 }6183 else {6184 console.log(value + " not entered in " + object + " field ");6185 }6186 ////browser.saveScreenshot();6187 }6188 6189 else if (value == "past.time.24") {6190 let finaldata2 = new Date().getHours();6191 if (pastHour <= 9) {6192 pastTime = "0" + pastHour + ":" + pastMinute;6193 console.log(pastTime);6194 } else {6195 pastTime = pastHour + ":" + pastMinute;6196 console.log(pastTime);6197 }6198 const enteredValue1 = browser6199 .element(`${fileutils.readPropertyFile(platform, object)}`)6200 .getAttribute("text");6201 console.log(enteredValue1);6202 if (enteredValue1 == pastTime) {6203 console.log(value + " entered in " + object + " field ");6204 } else {6205 console.log(value + " not entered in " + object + " field ");6206 }6207 ////browser.saveScreenshot();6208 } 6209 else if (object == "reminders.activity") {6210 let val1=fileutils.readPropertyFile("data", value)6211 const enteredValue = browser6212 .element(`${fileutils.readPropertyFile(platform, object)}`)6213 .getAttribute("text");6214 if (enteredValue == val1) {6215 console.log(value + " entered in " + object + " field ");6216 } else {6217 console.log(value + " not entered in " + object + " field ");6218 }6219 ////browser.saveScreenshot();6220 }6221 else if (object == "time.of.daily.reminder") {6222 let val1=fileutils.readPropertyFile("data", value)6223 const enteredValue = browser6224 .element(`${fileutils.readPropertyFile(platform, object)}`)6225 .getAttribute("text");6226 if (enteredValue == val1) {6227 console.log(value + " entered in " + object + " field ");6228 } else {6229 console.log(value + " not entered in " + object + " field ");6230 }6231 ////browser.saveScreenshot();6232 }6233 else if (value == 'device.past.time.24') {6234 // let finaldata2 = new Date().getHours();6235 if (pastHour <= 9) {6236 pastTime = "0" + pastHour + ":" + pastMinute6237 console.log(pastTime)6238 }6239 else {6240 pastTime = pastHour + ":" + pastMinute6241 console.log(pastTime)6242 }6243 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('text');6244 console.log(enteredValue1)6245 if (enteredValue1 == pastTime) {6246 console.log(value + " entered in " + object + " field ");6247 }6248 else {6249 console.log(value + " not entered in " + object + " field ");6250 }6251 ////browser.saveScreenshot();6252 }6253 6254 6255 else {6256 let val = value;6257 val = `${fileutils.readPropertyFile("data", value)}`;6258 const obj1 = browser6259 .element(`${fileutils.readPropertyFile(platform, object)}`)6260 .getText();6261 if (obj1 === val) {6262 console.log(val + " entered in " + object + " field ");6263 } else {6264 console.log(val + " not entered in " + object + " field ");6265 }6266 ////browser.saveScreenshot();6267 }6268 }6269 break;6270 case "ios":6271 browser.pause(2000);6272 if (val == "space") {6273 const space = browser6274 .element(`${fileutils.readPropertyFile(platform, object)}`)6275 .getAttribute("value");6276 if (space === "\t") {6277 console.log(value + " entered in " + object + " field ");6278 } else {6279 console.log(value + " not entered in " + object + " field ");6280 }6281 ////browser.saveScreenshot();6282 } else if (object == "mg.dl.logbook.screen") {6283 // let val1=fileutils.readPropertyFile("data", value)6284 const enteredValue = browser6285 .element(`${fileutils.readPropertyFile(platform, object)}`)6286 .getAttribute("value");6287 if (enteredValue.indexOf(value) == -1) {6288 console.log(enteredValue);6289 console.log(value + " not entered in " + object + " field ");6290 } else {6291 console.log(value + " entered in " + object + " field ");6292 }6293 ////browser.saveScreenshot();6294 } else if (object == "grams.logbook.screen") {6295 // let val1=fileutils.readPropertyFile("data", value)6296 const enteredValue = browser6297 .element(`${fileutils.readPropertyFile(platform, object)}`)6298 .getAttribute("value");6299 if (enteredValue.indexOf(value) == -1) {6300 console.log(enteredValue);6301 console.log(value + " not entered in " + object + " field ");6302 } else {6303 console.log(value + " entered in " + object + " field ");6304 }6305 ////browser.saveScreenshot();6306 } else if (object == "grams.logbook.screen1") {6307 // let val1=fileutils.readPropertyFile("data", value)6308 const enteredValue = browser6309 .element(`${fileutils.readPropertyFile(platform, object)}`)6310 .getAttribute("value");6311 if (enteredValue.indexOf(value) == -1) {6312 console.log(enteredValue);6313 console.log(value + " not entered in " + object + " field ");6314 } else {6315 console.log(value + " entered in " + object + " field ");6316 }6317 ////browser.saveScreenshot();6318 } else if (object == "grams.logbook.screen2") {6319 // let val1=fileutils.readPropertyFile("data", value)6320 const enteredValue = browser6321 .element(`${fileutils.readPropertyFile(platform, object)}`)6322 .getAttribute("value");6323 if (enteredValue.indexOf(value) == -1) {6324 console.log(enteredValue);6325 console.log(value + " not entered in " + object + " field ");6326 } else {6327 console.log(value + " entered in " + object + " field ");6328 }6329 ////browser.saveScreenshot();6330 } else if (object == "time.logbook.screen") {6331 // let val1=fileutils.readPropertyFile("data", value)6332 const enteredValue = browser6333 .element(`${fileutils.readPropertyFile(platform, object)}`)6334 .getAttribute("value");6335 if (enteredValue.indexOf(value) == -1) {6336 console.log(enteredValue);6337 console.log(value + " not entered in " + object + " field ");6338 } else {6339 console.log(value + " entered in " + object + " field ");6340 }6341 ////browser.saveScreenshot();6342 } else if (object == "time.logbook.screen1") {6343 // let val1=fileutils.readPropertyFile("data", value)6344 const enteredValue = browser6345 .element(`${fileutils.readPropertyFile(platform, object)}`)6346 .getAttribute("value");6347 if (enteredValue.indexOf(value) == -1) {6348 console.log(enteredValue);6349 console.log(value + " not entered in " + object + " field ");6350 } else {6351 console.log(value + " entered in " + object + " field ");6352 }6353 ////browser.saveScreenshot();6354 } else if (object == "time.logbook.screen2") {6355 // let val1=fileutils.readPropertyFile("data", value)6356 const enteredValue = browser6357 .element(`${fileutils.readPropertyFile(platform, object)}`)6358 .getAttribute("value");6359 if (enteredValue.indexOf(value) == -1) {6360 console.log(enteredValue);6361 console.log(value + " not entered in " + object + " field ");6362 } else {6363 console.log(value + " entered in " + object + " field ");6364 }6365 ////browser.saveScreenshot();6366 } else if (object == "blood.sugar.home") {6367 // let val1=fileutils.readPropertyFile("data", value)6368 const enteredValue = browser6369 .element(`${fileutils.readPropertyFile(platform, object)}`)6370 .getAttribute("value");6371 if (enteredValue.indexOf(value) == -1) {6372 console.log(enteredValue);6373 console.log(value + " not entered in " + object + " field ");6374 } else {6375 console.log(value + " entered in " + object + " field ");6376 }6377 ////browser.saveScreenshot();6378 } else if (object == "mealtime.insulin.home") {6379 // let val1=fileutils.readPropertyFile("data", value)6380 const enteredValue = browser6381 .element(`${fileutils.readPropertyFile(platform, object)}`)6382 .getAttribute("value");6383 if (enteredValue.indexOf(value) == -1) {6384 console.log(enteredValue);6385 console.log(value + " not entered in " + object + " field ");6386 } else {6387 console.log(value + " entered in " + object + " field ");6388 }6389 ////browser.saveScreenshot();6390 } else if (object == "longacting.insulin.home") {6391 // let val1=fileutils.readPropertyFile("data", value)6392 const enteredValue = browser6393 .element(`${fileutils.readPropertyFile(platform, object)}`)6394 .getAttribute("value");6395 if (enteredValue.indexOf(value) == -1) {6396 console.log(enteredValue);6397 console.log(value + " not entered in " + object + " field ");6398 } else {6399 console.log(value + " entered in " + object + " field ");6400 }6401 ////browser.saveScreenshot();6402 } else if (object == "carbs.intake.home") {6403 // let val1=fileutils.readPropertyFile("data", value)6404 const enteredValue = browser6405 .element(`${fileutils.readPropertyFile(platform, object)}`)6406 .getAttribute("value");6407 if (enteredValue.indexOf(value) == -1) {6408 console.log(enteredValue);6409 console.log(value + " not entered in " + object + " field ");6410 } else {6411 console.log(value + " entered in " + object + " field ");6412 }6413 ////browser.saveScreenshot();6414 }else if (object == "confirm.long-acting.units") {6415 // let val1=fileutils.readPropertyFile("data", value)6416 const enteredValue = browser6417 .element(`${fileutils.readPropertyFile(platform, object)}`)6418 .getAttribute("value");6419 if (enteredValue.indexOf(value) == -1) {6420 console.log(enteredValue);6421 console.log(value + " not entered in " + object + " field ");6422 } else {6423 console.log(value + " entered in " + object + " field ");6424 }6425 }6426 else if (object == "carbs.intake.home.1") {6427 // let val1=fileutils.readPropertyFile("data", value)6428 const enteredValue = browser6429 .element(`${fileutils.readPropertyFile(platform, object)}`)6430 .getAttribute("value");6431 if (enteredValue.indexOf(value) == -1) {6432 console.log(enteredValue);6433 console.log(value + " not entered in " + object + " field ");6434 } else {6435 console.log(value + " entered in " + object + " field ");6436 }6437 ////browser.saveScreenshot();6438 } else if (object == "mg.dl.logbook.screen1") {6439 // let val1=fileutils.readPropertyFile("data", value)6440 const enteredValue = browser6441 .element(`${fileutils.readPropertyFile(platform, object)}`)6442 .getAttribute("value");6443 if (enteredValue.indexOf(value) == -1) {6444 console.log(enteredValue);6445 console.log(value + " not entered in " + object + " field ");6446 } else {6447 console.log(value + " entered in " + object + " field ");6448 }6449 ////browser.saveScreenshot();6450 } else if (value == "past.time") {6451 const enteredValue1 = browser6452 .element(`${fileutils.readPropertyFile(platform, object)}`)6453 .getAttribute("value");6454 if (enteredValue1 == pastTime) {6455 console.log(value + " entered in " + object + " field ");6456 } else {6457 console.log(value + " not entered in " + object + " field ");6458 }6459 ////browser.saveScreenshot();6460 } 6461 6462 else if (value == 'device.past.time') {6463 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value');6464 if (enteredValue1 == pastTime) {6465 console.log(value + " entered in " + object + " field ");6466 }6467 else {6468 console.log(value + " not entered in " + object + " field ");6469 }6470 ////browser.saveScreenshot();6471 }6472 else if (value == 'device.current.time') {6473 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value');6474 if (enteredValue1 == currentTime) {6475 console.log(value + " entered in " + object + " field ");6476 }6477 else {6478 console.log(value + " not entered in " + object + " field ");6479 }6480 ////browser.saveScreenshot();6481 }6482 else if (value == 'device.past.time.24') {6483 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value');6484 if (enteredValue1 == pastTime24) {6485 console.log(value + " entered in " + object + " field ");6486 }6487 else {6488 console.log(value + " not entered in " + object + " field ");6489 }6490 ////browser.saveScreenshot();6491 }6492 else if (value == 'device.current.time.24') {6493 const enteredValue1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value');6494 if (enteredValue1 == currentTime24) {6495 console.log(value + " entered in " + object + " field ");6496 }6497 else {6498 console.log(value + " not entered in " + object + " field ");6499 }6500 ////browser.saveScreenshot();6501 }6502 else if (value == "past.time.24") {6503 const enteredValue1 = browser6504 .element(`${fileutils.readPropertyFile(platform, object)}`)6505 .getAttribute("value");6506 if (enteredValue1 == pastTime24) {6507 console.log(value + " entered in " + object + " field ");6508 } else {6509 console.log(value + " not entered in " + object + " field ");6510 }6511 ////browser.saveScreenshot();6512 } else if (value == "past.date") {6513 const enteredValue = browser6514 .element(`${fileutils.readPropertyFile(platform, object)}`)6515 .getAttribute("value");6516 if (enteredValue == pastDate) {6517 console.log(value + " entered in " + object + " field ");6518 } else {6519 console.log(value + " not entered in " + object + " field ");6520 }6521 ////browser.saveScreenshot();6522 } else if (object == "logbook.health.factors") {6523 let val1 = fileutils.readPropertyFile("data", value);6524 const enteredValue = browser6525 .element(`${fileutils.readPropertyFile(platform, object)}`)6526 .getAttribute("value");6527 if (enteredValue.indexOf(val1) == -1) {6528 console.log(enteredValue);6529 console.log(val1);6530 console.log(val1 + " not entered in " + object + " field ");6531 } else {6532 console.log(val1 + " entered in " + object + " field ");6533 }6534 ////browser.saveScreenshot();6535 } else {6536 let valu = value;6537 valu = `${fileutils.readPropertyFile("data", value)}`;6538 const objios = browser6539 .element(`${fileutils.readPropertyFile(platform, object)}`)6540 .getAttribute("value");6541 if (objios === valu) {6542 console.log(value + " entered in " + object + " field ");6543 } else {6544 console.log(value + " not entered in " + object + " field ");6545 }6546 ////browser.saveScreenshot();6547 }6548 break;6549 case "Web":6550 break;6551 default:6552 break;6553 }6554 } catch (e) {6555 console.error(`${object} is not displayed`);6556 //browser.saveScreenshot();6557 return assert.strictEqual(platform, "", e);6558 }6559 }6560);6561When(6562 /^I select "([^"]*)" in "([^"]*)" settingsfield$/,6563 async (value, object) => {6564 try {6565 switch (platform) {6566 case "android":6567 switch (deviceName) {6568 case "Pixel2xl":6569 // if (browser.element(fileutils.readPropertyFile(platform, "year")).isVisible()) {6570 // browser.element(fileutils.readPropertyFile(platform, "year")).click();6571 // }6572 let data = `${fileutils.readPropertyFile("data", value)}`;6573 if (object === "year") {6574 if (6575 browser6576 .element(fileutils.readPropertyFile(platform, "year"))6577 .isVisible()6578 ) {6579 browser6580 .element(fileutils.readPropertyFile(platform, "year"))6581 .click();6582 }6583 let reqYear = `${fileutils.readPropertyFile("data", value)}`;6584 let selectYear = browser.getText(6585 fileutils.readPropertyFile(platform, "required.year")6586 );6587 while (selectYear.indexOf(reqYear) == -1) {6588 mobileactions.swipe_up("datepicker.screen");6589 selectYear = browser.getText(6590 fileutils.readPropertyFile(platform, "required.year")6591 );6592 }6593 let selYear = fileutils6594 .readPropertyFile(platform, "select.year")6595 .replace("2019", reqYear);6596 browser.element(selYear).click();6597 //}6598 if (6599 browser6600 .element(6601 fileutils.readPropertyFile(platform, "ok.pixel2xl")6602 )6603 .isVisible()6604 ) {6605 browser6606 .element(6607 fileutils.readPropertyFile(platform, "ok.pixel2xl")6608 )6609 .click();6610 }6611 } else if (object === "month") {6612 let month = browser.getAttribute(6613 fileutils.readPropertyFile(platform, "month.text"),6614 "content-desc"6615 );6616 let reqMonth = `${fileutils.readPropertyFile("data", value)}`;6617 console.log(reqMonth + " " + month);6618 while (month.split(" ")[1] != reqMonth) {6619 browser6620 .element(6621 fileutils.readPropertyFile(platform, "previous.month")6622 )6623 .click();6624 month = browser.getAttribute(6625 fileutils.readPropertyFile(platform, "month.text"),6626 "content-desc"6627 );6628 console.log(reqMonth + " " + month);6629 }6630 } else if (object === "date") {6631 let reqDate = `${fileutils.readPropertyFile("data", value)}`;6632 let selDate = fileutils6633 .readPropertyFile(platform, object)6634 .replace("10", reqDate);6635 browser.element(selDate).click();6636 // if (browser.element(fileutils.readPropertyFile(platform, "ok.pixel2xl")).isVisible()) {6637 // browser.element(fileutils.readPropertyFile(platform, "ok.pixel2xl")).click();6638 // }6639 }6640 break;6641 case "Pixel3":6642 // }6643 if (6644 browser6645 .element(6646 fileutils.readPropertyFile(platform, "set.date.pixel3")6647 )6648 .isVisible()6649 ) {6650 browser6651 .element(6652 fileutils.readPropertyFile(platform, "set.date.pixel3")6653 )6654 .click();6655 }6656 let data1 = `${fileutils.readPropertyFile("data", value)}`;6657 if (object === "year") {6658 if (6659 browser6660 .element(fileutils.readPropertyFile(platform, "year"))6661 .isVisible()6662 ) {6663 browser6664 .element(fileutils.readPropertyFile(platform, "year"))6665 .click();6666 }6667 let reqYear1 = `${fileutils.readPropertyFile("data", value)}`;6668 let selectYear1 = browser.getText(6669 fileutils.readPropertyFile(platform, "required.year")6670 );6671 while (selectYear1.indexOf(reqYear1) == -1) {6672 mobileactions.swipe_up("datepicker.screen");6673 selectYear1 = browser.getText(6674 fileutils.readPropertyFile(platform, "required.year")6675 );6676 }6677 let selYear1 = fileutils6678 .readPropertyFile(platform, "select.year")6679 .replace("2019", reqYear1);6680 browser.element(selYear1).click();6681 if (6682 browser6683 .element(fileutils.readPropertyFile(platform, "ok.pixel3"))6684 .isVisible()6685 ) {6686 browser6687 .element(fileutils.readPropertyFile(platform, "ok.pixel3"))6688 .click();6689 }6690 } else if (object === "month") {6691 let month1 = browser.getAttribute(6692 fileutils.readPropertyFile(platform, "month.text"),6693 "content-desc"6694 );6695 let reqMonth1 = `${fileutils.readPropertyFile("data", value)}`;6696 while (month1.split(" ")[1] != reqMonth1) {6697 browser6698 .element(6699 fileutils.readPropertyFile(platform, "previous.month")6700 )6701 .click();6702 month1 = browser.getAttribute(6703 fileutils.readPropertyFile(platform, "month.text"),6704 "content-desc"6705 );6706 }6707 } else if (object === "date") {6708 let reqDate1 = `${fileutils.readPropertyFile("data", value)}`;6709 let selDate1 = fileutils6710 .readPropertyFile(platform, object)6711 .replace("10", reqDate1);6712 browser.element(selDate1).click();6713 if (6714 browser6715 .element(fileutils.readPropertyFile(platform, "ok.pixel3"))6716 .isVisible()6717 ) {6718 browser6719 .element(fileutils.readPropertyFile(platform, "ok.pixel3"))6720 .click();6721 }6722 }6723 break;6724 case "samsungS9plus":6725 let data2 = `${fileutils.readPropertyFile("data", value)}`;6726 if (object === "Year") {6727 let reqYear2 = `${fileutils.readPropertyFile("data", object)}`;6728 let selectYear2 = browser.getText(6729 fileutils.readPropertyFile(platform, "Required.Year")6730 );6731 while (selectYear2.indexOf(reqYear2) == -1) {6732 mobileactions.swipe_up("datepicker.screen");6733 selectYear2 = browser.getText(6734 fileutils.readPropertyFile(platform, "Required.Year")6735 );6736 }6737 let selYear2 = fileutils6738 .readPropertyFile(platform, "Year.samsungsj3")6739 .replace("2019", reqYear2);6740 browser.element(selYear2).click();6741 if (6742 browser6743 .element(6744 fileutils.readPropertyFile(platform, "Done.samsungsj3")6745 )6746 .isVisible()6747 ) {6748 browser6749 .element(6750 fileutils.readPropertyFile(platform, "Done.samsungsj3")6751 )6752 .click();6753 }6754 } else if (object === "Month") {6755 let month2 = browser.getAttribute(6756 fileutils.readPropertyFile(platform, "Month.text"),6757 "content-desc"6758 );6759 // let month3=(month2.split(',')[1]).split(' ')[2]6760 // console.log(month3);6761 let reqMonth2 = `${fileutils.readPropertyFile("data", object)}`;6762 while (month2.split(",")[1].split(" ")[2] != reqMonth2) {6763 console.log(month2);6764 browser6765 .element(6766 fileutils.readPropertyFile(6767 platform,6768 "PreviousMonth.samsung"6769 )6770 )6771 .click();6772 month2 = browser.getAttribute(6773 fileutils.readPropertyFile(platform, "Month.text"),6774 "content-desc"6775 );6776 console.log(month2);6777 }6778 } else if (object === "Date") {6779 let reqDate2 = `${fileutils.readPropertyFile("data", object)}`;6780 let selDate2 = fileutils6781 .readPropertyFile(platform, "Date.samsung")6782 .replace("10", reqDate2);6783 browser.element(selDate2).click();6784 if (6785 browser6786 .element(6787 fileutils.readPropertyFile(platform, "Done.samsungsj3")6788 )6789 .isVisible()6790 ) {6791 browser6792 .element(6793 fileutils.readPropertyFile(platform, "Done.samsungsj3")6794 )6795 .click();6796 }6797 }6798 break;6799 case "samsungS9":6800 if (6801 browser6802 .element(6803 fileutils.readPropertyFile(platform, "set.date.samsungs9")6804 )6805 .isVisible()6806 ) {6807 browser6808 .element(6809 fileutils.readPropertyFile(platform, "set.date.samsungs9")6810 )6811 .click();6812 }6813 let data21 = `${fileutils.readPropertyFile("data", value)}`;6814 if (object === "year") {6815 if (6816 browser6817 .element(6818 fileutils.readPropertyFile(platform, "set.date.samsungs9")6819 )6820 .isVisible()6821 ) {6822 browser6823 .element(6824 fileutils.readPropertyFile(platform, "set.date.samsungs9")6825 )6826 .click();6827 }6828 if (6829 browser6830 .element(6831 fileutils.readPropertyFile(platform, "year.samsungs9")6832 )6833 .isVisible()6834 ) {6835 browser6836 .element(6837 fileutils.readPropertyFile(platform, "year.samsungs9")6838 )6839 .click();6840 }6841 if (6842 browser6843 .element(6844 fileutils.readPropertyFile(6845 platform,6846 "required.year.samsumgs9"6847 )6848 )6849 .isVisible()6850 ) {6851 browser6852 .element(6853 fileutils.readPropertyFile(6854 platform,6855 "required.year.samsumgs9"6856 )6857 )6858 .click();6859 }6860 // let reqYear21 = `${fileutils.readPropertyFile('data', value)}`;6861 // let selectYear21 = browser.getText(fileutils.readPropertyFile(platform, "required.year.samsumgs9"));6862 // while (selectYear21.indexOf(reqYear21) == -1) {6863 // mobileactions.swipe_up("datepicker.screen");6864 // selectYear21 = browser.getText(fileutils.readPropertyFile(platform, "required.year.samsungs9"));6865 // }6866 // let selYear21 = fileutils.readPropertyFile(platform, 'year.samsungs9').replace('2019', reqYear21);6867 // browser.element(selYear21).click();6868 if (6869 browser6870 .element(6871 fileutils.readPropertyFile(platform, "done.samsungs9")6872 )6873 .isVisible()6874 ) {6875 browser6876 .element(6877 fileutils.readPropertyFile(platform, "done.samsungs9")6878 )6879 .click();6880 }6881 } else if (object === "month") {6882 let month21 = browser.getAttribute(6883 fileutils.readPropertyFile(platform, "month.text"),6884 "content-desc"6885 );6886 // let month3=(month2.split(',')[1]).split(' ')[2]6887 console.log(month21);6888 let reqMonth21 = `${fileutils.readPropertyFile("data", value)}`;6889 while (month21.split(",")[1].split(" ")[2] != reqMonth21) {6890 console.log(month21);6891 browser6892 .element(6893 fileutils.readPropertyFile(6894 platform,6895 "previousmonth.samsungs9"6896 )6897 )6898 .click();6899 month21 = browser.getAttribute(6900 fileutils.readPropertyFile(platform, "month.text"),6901 "content-desc"6902 );6903 console.log(month21);6904 }6905 } else if (object === "date") {6906 let reqDate21 = `${fileutils.readPropertyFile("data", value)}`;6907 let selDate21 = fileutils6908 .readPropertyFile(platform, "date.samsungs9")6909 .replace("10", reqDate21);6910 browser.element(selDate21).click();6911 if (6912 browser6913 .element(6914 fileutils.readPropertyFile(platform, "done.samsungs9")6915 )6916 .isVisible()6917 ) {6918 browser6919 .element(6920 fileutils.readPropertyFile(platform, "done.samsungs9")6921 )6922 .click();6923 }6924 }6925 break;6926 case "LGThinQ":6927 if (6928 browser6929 .element(6930 fileutils.readPropertyFile(platform, "set.date.lgthinq")6931 )6932 .isVisible()6933 ) {6934 browser6935 .element(6936 fileutils.readPropertyFile(platform, "set.date.lgthinq")6937 )6938 .click();6939 }6940 let data3 = `${fileutils.readPropertyFile("data", value)}`;6941 if (object === "year") {6942 if (6943 browser6944 .element(6945 fileutils.readPropertyFile(platform, "year.lgthinq")6946 )6947 .isVisible()6948 ) {6949 browser6950 .element(6951 fileutils.readPropertyFile(platform, "year.lgthinq")6952 )6953 .click();6954 }6955 if (6956 browser6957 .element(6958 fileutils.readPropertyFile(platform, "year.lgthinq.2018")6959 )6960 .isVisible()6961 ) {6962 browser6963 .element(6964 fileutils.readPropertyFile(platform, "year.lgthinq.2018")6965 )6966 .click();6967 }6968 // let reqYear3 = `${fileutils.readPropertyFile('data', value)}`;6969 // //let selectYear3 = browser.getText(fileutils.readPropertyFile(platform, "required.year"));6970 // let selectYear3 = browser.getText(fileutils.readPropertyFile(platform, "required.year"));6971 // console.log(selectYear3)6972 // while (selectYear3.indexOf(reqYear3) == -1) {6973 // mobileactions.swipe_up("datepicker.screen");6974 // // selectYear3 = browser.getText(fileutils.readPropertyFile(platform, "required.year"));6975 // selectYear3 = browser.getText(fileutils.readPropertyFile(platform, "required.year"));6976 // }6977 // //let selYear3 = fileutils.readPropertyFile(platform, 'select.year.lgthinkq').replace('2019', reqYear3);6978 // let selYear3 = fileutils.readPropertyFile(platform, 'select.year.lgthinkq').replace('2019', reqYear3);6979 // browser.element(selYear3).click();6980 if (6981 browser6982 .element(6983 fileutils.readPropertyFile(platform, "ok.lgthinkq")6984 )6985 .isVisible()6986 ) {6987 browser6988 .element(6989 fileutils.readPropertyFile(platform, "ok.lgthinkq")6990 )6991 .click();6992 }6993 } else if (object === "month") {6994 let month3 = browser.getAttribute(6995 fileutils.readPropertyFile(platform, "lgthinq.month.text"),6996 "content-desc"6997 );6998 // let month34 =(month3.split(',')[1]).split(' ')[2]6999 console.log(month3);7000 let reqMonth3 = `${fileutils.readPropertyFile("data", value)}`;7001 while (month3.split(",")[1].split(" ")[2] != reqMonth3) {7002 console.log(month3);7003 browser7004 .element(7005 fileutils.readPropertyFile(7006 platform,7007 "lgthniq.Previous.btn"7008 )7009 )7010 .click();7011 month3 = browser.getAttribute(7012 fileutils.readPropertyFile(platform, "lgthinq.month.text"),7013 "content-desc"7014 );7015 console.log(month3);7016 }7017 } else if (object === "date") {7018 let reqDate3 = `${fileutils.readPropertyFile("data", value)}`;7019 let selDate3 = fileutils7020 .readPropertyFile(platform, "date.lgthinkq")7021 .replace("10", reqDate3);7022 browser.element(selDate3).click();7023 if (7024 browser7025 .element(7026 fileutils.readPropertyFile(platform, "ok.lgthinkq")7027 )7028 .isVisible()7029 ) {7030 browser7031 .element(7032 fileutils.readPropertyFile(platform, "ok.lgthinkq")7033 )7034 .click();7035 }7036 }7037 break;7038 case "motoZ2":7039 let data4 = `${fileutils.readPropertyFile("data", value)}`;7040 if (object === "Year") {7041 let reqYear4 = `${fileutils.readPropertyFile("data", object)}`;7042 let selectYear4 = browser.getText(7043 fileutils.readPropertyFile(platform, "Required.Year")7044 );7045 while (selectYear4.indexOf(reqYear4) == -1) {7046 mobileactions.swipe_up("datepicker.screen");7047 selectYear4 = browser.getText(7048 fileutils.readPropertyFile(platform, "Required.Year")7049 );7050 }7051 let selYear4 = fileutils7052 .readPropertyFile(platform, "Year.moto")7053 .replace("2019", reqYear4);7054 browser.element(selYear4).click();7055 if (7056 browser7057 .element(fileutils.readPropertyFile(platform, "ok.moto"))7058 .isVisible()7059 ) {7060 browser7061 .element(fileutils.readPropertyFile(platform, "ok.moto"))7062 .click();7063 }7064 } else if (object === "Month") {7065 let month4 = browser.getAttribute(7066 fileutils.readPropertyFile(platform, "Month.text"),7067 "content-desc"7068 );7069 // let month3=(month2.split(',')[1]).split(' ')[2]7070 // console.log(month3);7071 let reqMonth4 = `${fileutils.readPropertyFile("data", object)}`;7072 while (month4.split(" ")[1] != reqMonth4) {7073 console.log(month4);7074 browser7075 .element(7076 fileutils.readPropertyFile(platform, "PreviousMonth.moto")7077 )7078 .click();7079 month4 = browser.getAttribute(7080 fileutils.readPropertyFile(platform, "Month.text"),7081 "content-desc"7082 );7083 console.log(month4);7084 }7085 } else if (object === "Date") {7086 let reqDate4 = `${fileutils.readPropertyFile("data", object)}`;7087 let selDate4 = fileutils7088 .readPropertyFile(platform, "Date.moto")7089 .replace("10", reqDate4);7090 browser.element(selDate4).click();7091 if (7092 browser7093 .element(fileutils.readPropertyFile(platform, "ok.moto"))7094 .isVisible()7095 ) {7096 browser7097 .element(fileutils.readPropertyFile(platform, "ok.moto"))7098 .click();7099 }7100 }7101 break;7102 case "SAMSUNG-SM-J327A":7103 let data5 = `${fileutils.readPropertyFile("data", value)}`;7104 if (object === "Year") {7105 let reqYear5 = `${fileutils.readPropertyFile("data", object)}`;7106 let selectYear5 = browser.getText(7107 fileutils.readPropertyFile(platform, "Required.Year")7108 );7109 while (selectYear5.indexOf(reqYear5) == -1) {7110 mobileactions.swipe_up("datepicker.screen");7111 selectYear5 = browser.getText(7112 fileutils.readPropertyFile(platform, "Required.Year")7113 );7114 }7115 let selYear5 = fileutils7116 .readPropertyFile(platform, "Year.samsungsj3")7117 .replace("2019", reqYear5);7118 browser.element(selYear5).click();7119 if (7120 browser7121 .element(7122 fileutils.readPropertyFile(platform, "Done.samsungsj3")7123 )7124 .isVisible()7125 ) {7126 browser7127 .element(7128 fileutils.readPropertyFile(platform, "Done.samsungsj3")7129 )7130 .click();7131 }7132 } else if (object === "Month") {7133 let month5 = browser.getAttribute(7134 fileutils.readPropertyFile(platform, "Month.text"),7135 "content-desc"7136 );7137 let month_3 = month5.split(",")[1];7138 console.log(month_3);7139 let reqMonth5 = `${fileutils.readPropertyFile("data", object)}`;7140 // let req_date = `${fileutils.readPropertyFile('data', object)}`;7141 // // while ((month5.split(',')[1]).split(' ')[2] != reqMonth5) {7142 while (month5.split(" ")[1] != reqMonth5) {7143 console.log(month5);7144 browser7145 .element(7146 fileutils.readPropertyFile(7147 platform,7148 "PreviousMonth.samsungj3"7149 )7150 )7151 .click();7152 if ((month5.split(",")[1].split(" ")[2] = "Month.text")) {7153 // console.log(month5);7154 month5 = browser.getAttribute(7155 fileutils.readPropertyFile(platform, "Month.text"),7156 "content-desc"7157 );7158 // //console.log(month5);7159 }7160 //}7161 }7162 } else if (object === "Date") {7163 let reqDate5 = `${fileutils.readPropertyFile("data", object)}`;7164 let selDate5 = fileutils7165 .readPropertyFile(platform, "Date.samsungj3")7166 .replace("10", reqDate5);7167 browser.element(selDate5).click();7168 if (7169 browser7170 .element(7171 fileutils.readPropertyFile(platform, "Done.samsungsj3")7172 )7173 .isVisible()7174 ) {7175 browser7176 .element(7177 fileutils.readPropertyFile(platform, "Done.samsungsj3")7178 )7179 .click();7180 }7181 }7182 break;7183 case "ZTE":7184 let data6 = `${fileutils.readPropertyFile("data", value)}`;7185 if (object === "Year") {7186 let reqYear6 = `${fileutils.readPropertyFile("data", object)}`;7187 let selectYear6 = browser.getText(7188 fileutils.readPropertyFile(platform, "Required.Year")7189 );7190 while (selectYear6.indexOf(reqYear6) == -1) {7191 mobileactions.swipe_up("datepicker.screen");7192 selectYear6 = browser.getText(7193 fileutils.readPropertyFile(platform, "Required.Year")7194 );7195 }7196 let selYear6 = fileutils7197 .readPropertyFile(platform, "Year.ZTE")7198 .replace("2019", reqYear6);7199 browser.element(selYear6).click();7200 if (7201 browser7202 .element(fileutils.readPropertyFile(platform, "OK.ZTE"))7203 .isVisible()7204 ) {7205 browser7206 .element(fileutils.readPropertyFile(platform, "OK.ZTE"))7207 .click();7208 }7209 } else if (object === "Month") {7210 let month6 = browser.element(7211 fileutils.readPropertyFile(platform, "Month.text"),7212 "content-desc"7213 );7214 console.log(month6);7215 let reqMonth6 = `${fileutils.readPropertyFile("data", object)}`;7216 while (month6.split(" ")[1] != reqMonth6) {7217 console.log(month6);7218 browser.pause(5000);7219 if (7220 browser7221 .element(7222 fileutils.readPropertyFile(7223 platform,7224 "PreviousMonth.ZTE"7225 )7226 )7227 .isVisible()7228 )7229 browser.element(platform, "~Previous month").click();7230 month6 = browser.getAttribute(7231 fileutils.readPropertyFile(platform, "Month.text"),7232 "content-desc"7233 );7234 }7235 } else if (object === "Date") {7236 let reqDate6 = `${fileutils.readPropertyFile("data", object)}`;7237 let selDate6 = fileutils7238 .readPropertyFile(platform, "Date.ZTE")7239 .replace("10", reqDate6);7240 browser.element(selDate6).click();7241 if (7242 browser7243 .element(fileutils.readPropertyFile(platform, "OK.ZTE"))7244 .isVisible()7245 ) {7246 browser7247 .element(fileutils.readPropertyFile(platform, "OK.ZTE"))7248 .click();7249 }7250 }7251 break;7252 default:7253 break;7254 }7255 break;7256 case "ios":7257 let exists = browser.waitUntil(7258 function() {7259 return browser7260 .element(fileutils.readPropertyFile(platform, object))7261 .isVisible();7262 },7263 timeOutinMs,7264 "Element not found"7265 );7266 if (exists) {7267 mobileElementAction.selectValueFromPicker(7268 fileutils.readPropertyFile(platform, object),7269 fileutils.readPropertyFile("data", value)7270 );7271 console.log("Selected " + value + " from " + object + " field");7272 ////browser.saveScreenshot();7273 }7274 break;7275 default:7276 break;7277 case "web":7278 // perform operation on web element7279 break;7280 }7281 } catch (e) {7282 console.error(" Cannot Select " + object + e);7283 //browser.saveScreenshot();7284 return assert.strictEqual(platform, "", e);7285 }7286 }7287);7288When(7289 /^I should see CurrentDate in "([^"]*)" field in MM-DD-YYYY format$/,7290 async object => {7291 try {7292 switch (platform) {7293 case "android":7294 let splitcurrentDate = new Date()7295 .toISOString()7296 .slice(0, 10)7297 .split("-");7298 let currYear = splitcurrentDate[0];7299 let currMonth = splitcurrentDate[1];7300 let currDay = splitcurrentDate[2];7301 let appdate = browser7302 .element(`${fileutils.readPropertyFile(platform, object)}`)7303 .getAttribute("text");7304 console.log("App Date is " + appdate);7305 let splitappdate = appdate.split("/");7306 let appmonth = splitappdate[0];7307 let appday = splitappdate[1];7308 let appyear = splitappdate[2];7309 expect(appmonth).to.equal(currMonth);7310 expect(appday).to.equal(currDay);7311 expect(appyear).to.equal(currYear);7312 console.log("Verified current Date");7313 ////browser.saveScreenshot();7314 if (moment(appdate, "MM/DD/YYYY")) {7315 console.log("valid format");7316 } else {7317 console.log("invalid format");7318 }7319 ////browser.saveScreenshot();7320 break;7321 case "ios":7322 // ios code here7323 let appdate1 = browser7324 .element(`${fileutils.readPropertyFile(platform, object)}`)7325 .getText();7326 console.log("App Date is " + appdate1);7327 if (moment(appdate1, "MM/DD/YYYY")) {7328 console.log("valid format");7329 } else {7330 console.log("invalid format");7331 }7332 ////browser.saveScreenshot();7333 break;7334 case "web":7335 // perform operation on web element7336 break;7337 default:7338 break;7339 }7340 } catch (e) {7341 console.error(" Cannot find date ");7342 //browser.saveScreenshot();7343 return assert.strictEqual(platform, "ios", " Cannot find date");7344 }7345 }7346);7347When(/^I should see device CurrentTime in "([^"]*)" field$/, async (object) => {7348 try {7349 switch (platform) {7350 case 'android':7351 let currenttime1 = utils.getdevicecurrenttime1();7352 let ampm = currenttime1.split(" ")[1];7353 let curtime = currenttime1.replace(ampm, ampm.toLocaleLowerCase())7354 let apptime1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('text')7355 console.log(apptime1 + " " + curtime)7356 if (curtime === apptime1) {7357 console.log("current time is displayed")7358 }7359 else {7360 console.log("current time not displayed")7361 }7362 ////browser.saveScreenshot();7363 break;7364 case 'ios':7365 // ios code here7366 let currenttime = utils.getdevicecurrenttime();7367 let ampm1 = currenttime.split(" ")[1];7368 let curtime1 = currenttime.replace(ampm1, ampm1.toLocaleLowerCase())7369 let apptime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value')7370 console.log(apptime + " " + curtime1)7371 if (curtime1 === apptime) {7372 console.log("current time is displayed")7373 }7374 else {7375 console.log("current time not displayed")7376 }7377 ////browser.saveScreenshot();7378 break;7379 case 'web':7380 // perform operation on web element7381 break;7382 default: break7383 }7384 } catch (e) {7385 console.error(' Cannot find date ');7386 //browser.saveScreenshot();7387 return assert.strictEqual(platform, '', e);7388 }7389});7390When(/^I should see device CurrentTime in 24 hour format in "([^"]*)" field$/, async (object) => {7391 try {7392 switch (platform) {7393 case 'android':7394 let currenttime1 = utils.getdevicecurrenttime24();7395 let apptime1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('text');7396 console.log(apptime1 + " " + currenttime1)7397 if (currenttime1 === apptime1) {7398 console.log("current time is displayed")7399 }7400 else {7401 console.log("current time not displayed")7402 }7403 7404 ////browser.saveScreenshot();7405 break;7406 case 'ios':7407 // ios code here7408 let currenttime = utils.getdevicecurrenttime24();7409 let apptime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value')7410 console.log(apptime + " " + currenttime)7411 if (currenttime === apptime) {7412 console.log("current time is displayed")7413 }7414 else {7415 console.log("current time not displayed")7416 }7417 ////browser.saveScreenshot();7418 break;7419 case 'web':7420 // perform operation on web element7421 break;7422 default: break7423 }7424 } catch (e) {7425 console.error(' Cannot find date ');7426 //browser.saveScreenshot();7427 return assert.strictEqual(platform, '', e);7428 }7429});7430When(/^I tap on Back button of device$/,7431 async object => {7432 try {7433 switch (platform) {7434 case "android":7435 browser.pressKeycode(4);7436 console.log("Tapped on back button");7437 // android code7438 break;7439 case "ios":7440 mobileElementAction.tapOutsideElement();7441 console.log(` Focussed out of ${object}`);7442 ////browser.saveScreenshot();7443 break;7444 case "web":7445 // perform operation on web element7446 break;7447 default:7448 break;7449 }7450 } catch (e) {7451 console.error(` Cannot Tap outside ${object}`);7452 //browser.saveScreenshot();7453 return assert.strictEqual(platform, "", e);7454 }7455 }7456);7457When(/^I select the "([^"]*)" in "([^"]*)" field$/, async (value, object) => {7458 try {7459 switch (platform) {7460 case "android":7461 let exists = browser.waitUntil(7462 function() {7463 return browser7464 .element(fileutils.readPropertyFile(platform, object))7465 .click();7466 },7467 timeOutinMs,7468 "Element not found"7469 );7470 if (exists) {7471 console.log("Clicked on " + object);7472 ////browser.saveScreenshot();7473 if (object === "date.picker.year") {7474 let val1 = `${fileutils.readPropertyFile("data", value)}`;7475 browser7476 .element(`${fileutils.readPropertyFile(platform, object)}`)7477 .setValue(val1);7478 console.log(`Selected ${value} in ${object} field`);7479 browser.pause(1000);7480 7481 } else if (object === "date.picker.month") {7482 let val2 = `${fileutils.readPropertyFile("data", value)}`;7483 browser7484 .element(`${fileutils.readPropertyFile(platform, object)}`)7485 .setValue(val2);7486 console.log(`Selected ${value} in ${object} field`);7487 browser.pause(1000);7488 } else if (object === "date.picker.date") {7489 7490 let val3 = `${fileutils.readPropertyFile("data", value)}`;7491 browser7492 .element(`${fileutils.readPropertyFile(platform, object)}`)7493 .setValue(val3);7494 console.log(`Selected ${value} in ${object} field`);7495 browser.pause(1000);7496 } else {7497 console.log(object + "not found");7498 }7499 7500 }7501 break;7502 case "ios":7503 break;7504 case "web":7505 // perform operation on web element7506 break;7507 }7508 } catch (e) {7509 console.error(" Cannot select " + object + e);7510 //browser.saveScreenshot();7511 return assert.strictEqual(platform, "", e);7512 }7513});7514When(7515 /^I turn ON Bluetooth$/, async() => {7516 try {7517 switch (platform) {7518 case "android":7519 switch (deviceName) {7520 case 'Pixel3':7521 browser.startActivity("com.android.settings", "com.android.settings.Settings");7522 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.search")).click();7523 browser.pause(4000)7524 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.searchbox")).setValue("Bluetooth");7525 browser.pause(2000)7526 browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth")).click();7527 const exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth")).isVisible(), timeOutinMs, 'Error: Element not found');7528 if (exists1) {7529 let checked = browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.bluetooth.auto.toggle")).getAttribute('checked')7530 if (checked == 'false') {7531 console.log("Bluetooth is OFF");7532 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.bluetooth.auto.toggle")).click();7533 console.log("Bluetooth is now turned ON");7534 }7535 else {7536 console.log("Bluetooth is already ON");7537 7538 }7539 }7540 break;7541 case 'OnePlus7Pro':7542 browser.startActivity("com.android.settings", "com.android.settings.Settings");7543 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.search")).click();7544 browser.pause(4000)7545 browser.element(fileutils.readPropertyFile(platform, "pixel2xl.settings.searchbox")).setValue("Bluetooth");7546 browser.pause(2000)7547 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth")).click();7548 const exists2 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth")).isVisible(), timeOutinMs, 'Error: Element not found');7549 if (exists2) {7550 let checked = browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth.auto.toggle")).getAttribute('checked')7551 if (checked == 'false') {7552 console.log("Bluetooth is OFF");7553 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth.auto.toggle")).click();7554 console.log("Bluetooth is now turned ON");7555 }7556 else {7557 console.log("Bluetooth is already ON");7558 7559 }7560 }7561 break;7562 }7563 while (browser.getCurrentPackage() != 'com.lilly.ddcs.madelyne') {7564 browser.pressKeycode(4);7565 }7566 7567 break;7568 case "ios":7569 try {7570 const exists = browser.waitUntil(() => browser.execute('mobile: launchApp', { bundleId: settingsApp }), timeOutinMs, 'Error: App not found');7571 if (exists) {7572 console.log('Launched Settings application ');7573 ////browser.saveScreenshot();7574 }7575 browser.pause(1000)7576 browser.execute('mobile: terminateApp', { bundleId: settingsApp })7577 browser.pause(1000)7578 browser.execute('mobile: launchApp', { bundleId: settingsApp });7579 mobileactions.mobileScroll('up')7580 7581 let search = browser.element(`${fileutils.readPropertyFile(platform, 'settings.search')}`)7582 search.click();7583 const exists0 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "settings.search")}`).isVisible(), timeOutinMs, 'Error: Element not found');7584 if (exists0) {7585 search.setValue("Bluetooth");7586 browser.pause(2000);7587 browser.element('(//XCUIElementTypeStaticText[@name=\"Bluetooth\"])[1]').click();7588 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")}`).isVisible(), timeOutinMs, 'Error: Element not found');7589 if (exists1) {7590 let value = browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")).getAttribute('value')7591 console.log(value)7592 if (value == 1) {7593 console.log('Already Bluetooth is ON');7594 }7595 else {7596 browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")).click();7597 console.log("Bluetooth is now ON")7598 }7599 }7600 }7601 browser.execute('mobile: activateApp', { bundleId: bundleid });7602 browser.pause(3000);7603 }7604 7605 catch (e) {7606 console.error('Cannot set bluetooth', e);7607 //browser.saveScreenshot();7608 }7609 7610 break;7611 case "web":7612 // perform operation on web element7613 break;7614 default:7615 break;7616 }7617 } catch (e) {7618 console.error(" Cannot find Bluetooth ");7619 browser.saveScreenshot();7620 return assert.strictEqual(platform, '', " Cannot find bluetooth");7621 }7622 }7623);7624When(7625 /^I turn OFF Bluetooth$/, async() => {7626 try {7627 switch (platform) {7628 case "android":7629 switch (deviceName) {7630 case 'Pixel3':7631 browser.startActivity("com.android.settings", "com.android.settings.Settings");7632 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.search")).click();7633 browser.pause(4000)7634 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.searchbox")).setValue("Bluetooth");7635 browser.pause(2000)7636 browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth")).click();7637 const exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth")).isVisible(), timeOutinMs, 'Error: Element not found');7638 if (exists1) {7639 let checked = browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.bluetooth.auto.toggle")).getAttribute('checked')7640 if (checked == 'true') {7641 console.log("Bluetooth is ON");7642 browser.element(fileutils.readPropertyFile(platform, "pixel3.settings.bluetooth.auto.toggle")).click();7643 console.log("Bluetooth is now turned OFF");7644 }7645 else {7646 console.log("Bluetooth is already OFF");7647 7648 }7649 }7650 7651 break;7652 case 'OnePlus7Pro':7653 browser.startActivity("com.android.settings", "com.android.settings.Settings");7654 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.search")).click();7655 browser.pause(4000)7656 browser.element(fileutils.readPropertyFile(platform, "pixel2xl.settings.searchbox")).setValue("Bluetooth");7657 browser.pause(2000)7658 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth")).click();7659 const exists2 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth")).isVisible(), timeOutinMs, 'Error: Element not found');7660 if (exists2) {7661 let checked = browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth.auto.toggle")).getAttribute('checked')7662 if (checked == 'true') {7663 console.log("Bluetooth is ON");7664 browser.element(fileutils.readPropertyFile(platform, "oneplus7pro.settings.bluetooth.auto.toggle")).click();7665 console.log("Bluetooth is now turned OFF");7666 }7667 else {7668 console.log("Bluetooth is already OFF");7669 7670 }7671 }7672 break;7673 }7674 while (browser.getCurrentPackage() != 'com.lilly.ddcs.madelyne') {7675 browser.pressKeycode(4);7676 }7677 7678 break;7679 case "ios":7680 try {7681 const exists = browser.waitUntil(() => browser.execute('mobile: launchApp', { bundleId: settingsApp }), timeOutinMs, 'Error: App not found');7682 if (exists) {7683 console.log('Launched Settings application ');7684 ////browser.saveScreenshot();7685 }7686 browser.pause(1000)7687 browser.execute('mobile: terminateApp', { bundleId: settingsApp })7688 browser.pause(1000)7689 browser.execute('mobile: launchApp', { bundleId: settingsApp });7690 mobileactions.mobileScroll('up')7691 7692 let search = browser.element(`${fileutils.readPropertyFile(platform, 'settings.search')}`)7693 search.click();7694 const exists0 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "settings.search")}`).isVisible(), timeOutinMs, 'Error: Element not found');7695 if (exists0) {7696 search.setValue("Bluetooth");7697 browser.pause(2000);7698 browser.element('(//XCUIElementTypeStaticText[@name=\"Bluetooth\"])[1]').click();7699 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")}`).isVisible(), timeOutinMs, 'Error: Element not found');7700 if (exists1) {7701 let value = browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")).getAttribute('value')7702 console.log(value)7703 if (value == 0) {7704 console.log('Already Bluetooth is OFF');7705 }7706 else {7707 browser.element(fileutils.readPropertyFile(platform, "settings.bluetooth.auto.toggle")).click();7708 console.log("Bluetooth is now OFF")7709 }7710 }7711 }7712 browser.execute('mobile: activateApp', { bundleId: bundleid });7713 browser.pause(3000);7714 }7715 7716 catch (e) {7717 console.error('Cannot set bluetooth', e);7718 //browser.saveScreenshot();7719 }7720 7721 break;7722 case "web":7723 // perform operation on web element7724 break;7725 default:7726 break;7727 }7728 } catch (e) {7729 console.error(" Cannot find Bluetooth ");7730 browser.saveScreenshot();7731 return assert.strictEqual(platform, '', " Cannot find bluetooth");7732 }7733 }...

Full Screen

Full Screen

then.js

Source:then.js Github

copy

Full Screen

...38 let obj1 = object39 console.log(`${object} is displayed`);40 obj1 = obj1.replace(/\./g, '_');41 const filePath = `${screenshotPath + obj1}.png`;42 //browser.saveScreenshot(filePath);43 }44 break;45 case 'ios':46 browser.pause(3000);47 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');48 if (exists) {49 let obj = object50 console.log(`${object} is displayed`);51 obj = obj.replace(/\./g, '_');52 const filePath = `${screenshotPath + obj}.png`;53 ////browser.saveScreenshot(filePath);54 }55 break;56 case 'web':57 // web operation58 break;59 default: break60 }61 } catch (e) {62 console.error(`${object} is not displayed`);63 //browser.saveScreenshot();64 return assert.strictEqual(platform, '', e);65 }66});67Then(/^I should see "([^"]*)"$/, async (object) => {68 try {69 switch (platform) {70 case 'android':71 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');72 if (check) {73 let obj = object74 console.log(`${obj} is displayed`);75 obj = obj.replace(/\./g, '_');76 const filePath = `${screenshotPath + obj}.png`;77 ////browser.saveScreenshot(filePath);78 }79 break;80 case 'ios':81 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');82 if (exists) {83 let obj = object84 console.log(`${object} is displayed`);85 obj = obj.replace(/\./g, '_');86 const filePath = `${screenshotPath + obj}.png`;87 //browser.saveScreenshot(filePath);88 }89 break;90 case 'web':91 // web operation92 break;93 default: break94 }95 } catch (e) {96 console.error(`${object} is not displayed`);97 //browser.saveScreenshot();98 return assert.strictEqual(platform, '', e);99 }100});101Then(/^I should see elements in "([^"]*)"$/, async (object) => {102 try {103 switch (platform) {104 case 'android':105 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');106 if (check) {107 let obj = object108 console.log(`${obj} is displayed`);109 console.log(browser.elements(`${fileutils.readPropertyFile(platform, object)}`))110 obj = obj.replace(/\./g, '_');111 const filePath = `${screenshotPath + obj}.png`;112 ////browser.saveScreenshot(filePath);113 }114 break;115 case 'ios':116 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');117 if (exists) {118 let obj = object119 console.log(`${object} is displayed`);120 console.log(browser.elements(`${fileutils.readPropertyFile(platform, object)}`))121 obj = obj.replace(/\./g, '_');122 const filePath = `${screenshotPath + obj}.png`;123 ////browser.saveScreenshot(filePath);124 }125 break;126 case 'web':127 // web operation128 break;129 default: break130 }131 } catch (e) {132 console.error(`${object} is not displayed`);133 //browser.saveScreenshot();134 return assert.strictEqual(platform, '', e);135 }136});137Then(/^I should see "([^"]*)" with toggle action which is OFF by default$/, async (object) => {138 try {139 switch (platform) {140 case 'android':141 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');142 if (check) {143 let obj = object144 console.log(`${obj} is displayed`);145 obj = obj.replace(/\./g, '_');146 const filePath = `${screenshotPath + obj}.png`;147 //browser.saveScreenshot(filePath);148 }149 break;150 case 'ios':151 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');152 if (exists) {153 let obj = object154 console.log(`${object} is displayed`);155 obj = obj.replace(/\./g, '_');156 const filePath = `${screenshotPath + obj}.png`;157 ////browser.saveScreenshot(filePath);158 }159 break;160 case 'web':161 // web operation162 break;163 default: break164 }165 } catch (e) {166 console.error(`${object} is not displayed`);167 //browser.saveScreenshot();168 return assert.strictEqual(platform, '', e);169 }170});171Then(/^I should see summary for "([^"]*)"$/, async (object) => {172 try {173 switch (platform) {174 case 'android':175 // android code here176 break;177 case 'ios':178 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');179 if (exists) {180 const string = mobileElementAction.getElementText(browser.element(`${fileutils.readPropertyFile(platform, object)}`));181 let obj = object182 obj = object.replace('.and.', ' & ');183 if (obj === string) {184 console.log(`${obj} is displayed`);185 obj = obj.replace(/\./g, '_');186 const filePath = `${screenshotPath + obj}.png`;187 //browser.saveScreenshot(filePath);188 }189 }190 break;191 case 'web':192 // web operation193 break;194 default: break195 }196 } catch (e) {197 console.error(`${object} is not displayed`);198 //browser.saveScreenshot();199 return assert.strictEqual(platform, '', e);200 }201});202Then(/^I should see "([^"]*)" (?:confirmation pop-up|pop-up)$/, async (object) => {203 try {204 switch (platform) {205 case 'android':206 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');207 if (check) {208 console.log(`${object} screen is displayed`);209 ////browser.saveScreenshot();210 }211 break;212 case 'ios':213 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object)).isVisible(), timeOutinMs, 'Element not found');214 if (exists) {215 console.log(`${object} popup is displayed`);216 ////browser.saveScreenshot();217 }218 break;219 case 'web':220 // web operation221 break;222 default: break223 }224 } catch (e) {225 console.error(`${object} pop-up is not displayed`);226 //browser.saveScreenshot();227 return assert.strictEqual(platform, '', e);228 }229});230Then(/^I should see "([^"]*)" (?:text|errormessage)$/, async (object) => {231 try {232 switch (platform) {233 case 'android':234 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');235 if (exists1) {236 console.log(`${object} is displayed`);237 const textmessage1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();238 console.log(`${'Validation Message/Text Display:'}${textmessage1}`);239 browser.pause(1000);240 ////browser.saveScreenshot();241 break;242 }243 break;244 case 'ios':245 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');246 if (exists) {247 console.log(`${object} is displayed`);248 const textmessage = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();249 console.log(`${'Validation Message/Text Display:'}${textmessage}`);250 ////browser.saveScreenshot();251 break;252 }253 break;254 case 'Web':255 // web operation256 break;257 default: break;258 }259 } catch (e) {260 console.error(`${object} is not displayed`);261 //browser.saveScreenshot();262 return assert.strictEqual(platform, '', e);263 }264});265Then(/^I should see "([^"]*)" content$/, async (object) => {266 try {267 switch (platform) {268 case 'android':269 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');270 const validText1 = "Mauris non tempor quam, et lacinia sapien. Mauris accumsan eros eget libero posuere vulputate. Etiam elit elit, elementum sed varius at, adipiscing vitae est. Sed nec felis pellentesque, lacinia dui sed, ultricies sapien. Pellentesque orci lectus, consectetur vel posuere posuere, rutrum eu ipsum.Aliquam eget odio sed ligula iaculis consequat at eget orci. Mauris molestie sit amet metus mattis varius. Donec sit amet ligula eget nisi sodales egestas.Aliquam interdum dolor aliquet dolor sollicitudin fermentum. Donec congue lorem a molestie bibendum. Etiam nisi ante, consectetur eget placerat a, tempus a neque. Donec ut elit urna. Etiam venenatis eleifend urna eget scelerisque. Aliquam in nunc quis dui sollicitudin ornare ac vitae lectus.Mauris non tempor quam, et lacinia sapien. Mauris accumsan eros eget libero posuere vulputate. Etiam elit elit, elementum sed varius at, adipiscing vitae est. Sed nec felis pellentesque, lacinia dui sed, ultricies sapien. Pellentesque orci lectus, consectetur vel posuere posuere, rutrum eu ipsum. Aliquam eget odio sed ligula iaculis consequat at eget orci. Mauris molestie sit amet metus mattis varius. Donec sit amet ligula eget nisi sodales egestas. Aliquam interdum dolor aliquet dolor sollicitudin fermentum. Donec congue lorem a molestie bibendum. Etiam nisi ante, consectetur eget placerat a, tempus a neque. Donec ut elit urna. Etiam venenatis eleifend urna eget scelerisque. Aliquam in nunc quis dui sollicitudin ornare ac vitae lectus."271 if (exists1) {272 console.log(`${object} screen is displayed`);273 const textmessage1 = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();274 console.log(textmessage1)275 console.log(`${'Validation Message/Text Display:'}${textmessage1}`);276 assert.strictEqual(validText1, mobileElementAction.getElementText(browser.element(`${fileutils.readPropertyFile(platform, object)}`)));277 ////browser.saveScreenshot();278 break;279 }280 break;281 case 'ios':282 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');283 if (exists) {284 console.log(`${object} screen is displayed`);285 const textmessage = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();286 assert.strictEqual(textmessage, "Mauris non tempor quam, et lacinia sapien. Mauris accumsan eros eget libero posuere vulputate. Etiam elit elit, elementum sed varius at, adipiscing vitae est. Sed nec felis pellentesque, lacinia dui sed, ultricies sapien. Pellentesque orci lectus, consectetur vel posuere posuere, rutrum eu ipsum.Aliquam eget odio sed ligula iaculis consequat at eget orci. Mauris molestie sit amet metus mattis varius. Donec sit amet ligula eget nisi sodales egestas.Aliquam interdum dolor aliquet dolor sollicitudin fermentum. Donec congue lorem a molestie bibendum. Etiam nisi ante, consectetur eget placerat a, tempus a neque. Donec ut elit urna. Etiam venenatis eleifend urna eget scelerisque. Aliquam in nunc quis dui sollicitudin ornare ac vitae lectus.Mauris non tempor quam, et lacinia sapien. Mauris accumsan eros eget libero posuere vulputate. Etiam elit elit, elementum sed varius at, adipiscing vitae est. Sed nec felis pellentesque, lacinia dui sed, ultricies sapien. Pellentesque orci lectus, consectetur vel posuere posuere, rutrum eu ipsum. Aliquam eget odio sed ligula iaculis consequat at eget orci. Mauris molestie sit amet metus mattis varius. Donec sit amet ligula eget nisi sodales egestas. Aliquam interdum dolor aliquet dolor sollicitudin fermentum. Donec congue lorem a molestie bibendum. Etiam nisi ante, consectetur eget placerat a, tempus a neque. Donec ut elit urna. Etiam venenatis eleifend urna eget scelerisque. Aliquam in nunc quis dui sollicitudin ornare ac vitae lectus.", `${object} Verified`);287 ////browser.saveScreenshot();288 break;289 }290 break;291 case 'Web':292 // web operation293 break;294 default: break;295 }296 } catch (e) {297 console.error(`${object} is not displayed`);298 //browser.saveScreenshot();299 return assert.strictEqual(platform, '', e);300 }301});302Then(/^I should see "([^"]*)" error$/, async (object) => {303 try {304 switch (platform) {305 case 'android':306 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');307 console.log(`${object} screen is displayed`);308 ////browser.saveScreenshot();309 break;310 case 'ios':311 const visiblecheck = browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible();312 if (visiblecheck) {313 const errormessage = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();314 console.log(`The Error message displayed is: ${errormessage}`);315 } else {316 console.log(`${object}`, 'is not visible on screen');317 }318 break;319 case 'Web':320 // web operation321 break;322 default: break323 }324 } catch (e) {325 console.error(`${object} is not displayed`);326 //browser.saveScreenshot();327 return assert.strictEqual(platform, '', e);328 }329});330/*331Then statement to clear text field for First name, Last name, Email Id, and Password ---->332*/333Then(/^I clear "([^"]*)" (?:textbox|field)$/, async (object) => {334 try {335 switch (platform) {336 case 'android':337 browser.clearElement(`${fileutils.readPropertyFile(platform, object)}`);338 console.log(object+" is cleared")339 ////browser.saveScreenshot();340 break;341 case 'ios':342 browser.clearElement(`${fileutils.readPropertyFile(platform, object)}`);343 console.log(object+" is cleared")344 ////browser.saveScreenshot();345 break;346 default: break;347 }348 } catch (e) {349 console.error(`${object} is not displayed`);350 //browser.saveScreenshot();351 return assert.strictEqual(platform, '', e);352 }353});354Then(/^I should see "([^"]*)" populated in the textbox$/, async (object) => {355 try {356 switch (platform) {357 case 'android':358 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');359 console.log(`${object} screen is displayed`);360 ////browser.saveScreenshot();361 break;362 case 'ios':363 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');364 if (exists) {365 console.log(`${object} screen is displayed`);366 const textmessage = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();367 console.log(`${'Validation Message/Text Display: '}${textmessage}`);368 ////browser.saveScreenshot();369 break;370 }371 break;372 case 'Web':373 // web operation374 break;375 default: break;376 }377 } catch (e) {378 console.error(`${object} is not displayed`);379 ////browser.saveScreenshot();380 return assert.strictEqual(platform, '', e);381 }382});383/*384Then statement to verify for the user first name in the calendar header text385*/386Then(/^I should see "([^"]*)" in the "([^"]*)" text$/, async (value, object) => {387 try {388 let val = value389 switch (platform) {390 case 'android':391 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');392 console.log(`${object} screen is displayed`);393 ////browser.saveScreenshot();394 break;395 case 'ios':396 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');397 if (exists) {398 val = UserFirstName;399 const wholetextmessage = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();400 console.log(`${'The complete text displayed is: '}${wholetextmessage}`);401 if (wholetextmessage.includes(val)) {402 console.log(`${'Users First name: '}${val} `, 'is displayed');403 } else {404 console.log(`${'Users First name:'}${val} `, 'is not displayed');405 }406 ////browser.saveScreenshot();407 break;408 }409 break;410 case 'Web':411 break;412 default: break413 }414 } catch (e) {415 console.error(`${object} is not displayed`);416 //browser.saveScreenshot();417 return assert.strictEqual(platform, '', e);418 }419});420When(/^I should see "([^"]*)" name$/, async (object) => {421 try {422 switch (platform) {423 case 'android':424 expect(browser.element(`${fileutils.readPropertyFile(platform, object)}`).isExisting);425 console.log(`${object} is visible`);426 ////browser.saveScreenshot();427 break;428 case 'ios':429 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isEnabled(), timeOutinMs, 'Error: Element not found');430 if (exists) {431 if (object === 'currentMonth') {432 const month = utils.getcurrentMonth();433 console.log(`Current month calendar: ${month}`);434 assert.strictEqual(month, mobileElementAction.getElementText(browser.element(`${fileutils.readPropertyFile(platform, object)}`)));435 } else if (object === 'previousMonth') {436 browser.pause(6000)437 const month = utils.getPrevMonth();438 const year = utils.getCurrentYear();439 const prevMonthYear = `${month} ${year}`;440 console.log(`Previous month calendar: ${prevMonthYear}`);441 assert.strictEqual(month, mobileElementAction.getElementText(browser.element(`${fileutils.readPropertyFile(platform, object)}`)));442 }443 ////browser.saveScreenshot();444 }445 break;446 case 'web':447 // perform operation on web element448 break;449 default: break;450 }451 } catch (e) {452 console.error(` Cannot find ${object}`);453 //browser.saveScreenshot();454 return assert.strictEqual(platform, '', e);455 }456});457Then(/^I should see "([^"]*)" in the calendar header$/, async (object) => {458 try {459 switch (platform) {460 case 'android':461 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');462 console.log(`${object} screen is displayed`);463 ////browser.saveScreenshot();464 break;465 case 'ios':466 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');467 if (exists) {468 console.log(`${object} screen is displayed`);469 const calendarsummarytext = browser.element(`${fileutils.readPropertyFile(platform, 'Calendar.Summary')}`).getText();470 const calendarsummaryheadertext = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();471 console.log('Calendar type displayed:', `${calendarsummarytext} ${calendarsummaryheadertext}`);472 ////browser.saveScreenshot();473 break;474 }475 break476 case 'Web':477 // web operation478 break;479 default: break480 }481 } catch (e) {482 console.error(`${object} is not displayed`);483 //browser.saveScreenshot();484 return assert.strictEqual(platform, '', e);485 }486});487/*488Then statement to verify for the date month in the calendar489*/490Then(/^I should see the same "([^"]*)" after toggle in the calendar summary$/, async (object) => {491 try {492 switch (platform) {493 case 'android':494 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');495 if (check) {496 console.log(`${object} screen is displayed`);497 ////browser.saveScreenshot();498 }499 break;500 case 'ios':501 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');502 if (exists) {503 const date = new Date();504 const currentmonth = date.getMonth();505 const calendarmonth = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();506 if (calendarmonth.includes(currentmonth)) {507 console.log(`Calendar Month displayed:${calendarmonth}`);508 ////browser.saveScreenshot();509 }510 }511 break;512 case 'web':513 // web operation514 break;515 default: break516 }517 } catch (e) {518 console.error(`${object} is not displayed`);519 //browser.saveScreenshot();520 return assert.strictEqual(platform, '', e);521 }522});523/*524Then statement to verify for email for forgot password525*/526Then(/^I should connect to email for registration verification$/, async () => {527 try {528 const emailwaitforregscreen = await emailUtilsforregscreen.readforregscreen();529 browser.pause(1000);530 return emailwaitforregscreen;531 } catch (e) {532 console.error('Cannot open mailbox', e);533 return assert.strictEqual(platform, '', e);534 }535});536/*537Then statement to verify for email538*/539Then(/^I should connect to email for resend registration verification$/, async () => {540 try {541 switch (platform) {542 case 'android':543 const emailwaitforregscreen1 = await emailUtilsforregscreen1.readforresendregscreen();544 browser.pause(1000);545 return emailwaitforregscreen1;546 break;547 case 'ios':548 const emailwaitforregscreen = await emailUtilsforregscreen.readforresendregscreen();549 browser.pause(1000);550 return emailwaitforregscreen;551 break;552 }553 } catch (e) {554 console.error('Cannot open mailbox', e);555 return assert.strictEqual(platform, '', e);556 }557});558Then(/^I should connect to email for forgot password verification$/, async () => {559 try {560 const emailwait = await emailUtilsforforgotpassword.readforforgotpassword();561 console.log("reset done");562 return emailwait;563 } catch (e) {564 console.error('Cannot open mailbox', e);565 return assert.strictEqual(platform, '', e);566 }567});568Then(/^I must be able to reset the password$/, async () => {569 fs.readFile('./test/testdata/codeforregscreen.txt', 'utf-8', (err, data) => {570 if (err) {571 console.error(err);572 }573 console.log('2nd time ------', data);574 browser.execute('mobile: launchApp', { bundleId: safaribrowserbundleid });575 const readurl = JSON.stringify(data);576 console.log(readurl);577 browser.url(readurl);578 });579 ////browser.saveScreenshot();580});581Then(/^I wait for recording$/, async () => {582 try {583 browser.pause(2000);584 } catch (e) {585 console.error('Cannot wait', e);586 return assert.strictEqual(platform, '', e);587 }588});589Then(/^I should see "([^"]*)" shortcut CTA$/, async (object) => {590 try {591 switch (platform) {592 case 'android':593 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');594 console.log(`${object} screen is displayed`);595 ////browser.saveScreenshot();596 break;597 case 'ios':598 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');599 if (exists) {600 console.log(`${object} shortcut is displayed`);601 ////browser.saveScreenshot();602 break;603 }604 break;605 case 'web':606 // web operation607 break;608 default:609 break;610 }611 } catch (e) {612 console.error(`${object} shortcut is not displayed`);613 ////browser.saveScreenshot();614 return assert.strictEqual(platform, '', e);615 }616});617/*618Then statement to verify for the calendar Medication & Migraine icons619*/620Then(/^I should view "([^"]*)" icons$/, async (object) => {621 try {622 switch (platform) {623 case 'android':624 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');625 if (check) {626 console.log(`${object} screen is displayed`);627 ////browser.saveScreenshot();628 }629 break;630 case 'ios':631 const calendarmonth = browser.element(`${fileutils.readPropertyFile(platform, 'Calendar.Month')}`).getText();632 console.log(`${object} `, 'exists for the month:', ` ${calendarmonth}`);633 const checklistofmedicationormigraineicons = browser.elements('//XCUIElementTypeImage[@name="calendar_icon_view"]').value.length;634 const list = [checklistofmedicationormigraineicons];635 each(list, (item) => {636 const datecheck = browser.elements('//XCUIElementTypeOther[XCUIElementTypeImage[@name="calendar_icon_view"]]/following-sibling::XCUIElementTypeStaticText[@name="calendar_daylabel_text"]').getText();637 console.log(`${'Total number of '}${object} `, 'displayed in the month of', ` ${calendarmonth} `, 'is', ` ${item}`);638 console.log(`${'The dates taken for'}${object} `, 'in the month of', ` ${calendarmonth} `, 'is', ` ${datecheck}`);639 })640 break;641 case 'web':642 // web operation643 break;644 default:645 break;646 }647 } catch (e) {648 console.error(`${object} screen is not displayed`);649 ////browser.saveScreenshot();650 return assert.strictEqual(platform, '', e);651 }652});653/*654Then statement to verify for dot present under the current date655*/656Then(/^I should see line under the "([^"]*)"$/, async (object) => {657 try {658 switch (platform) {659 case 'android':660 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');661 if (check) {662 console.log(`${object} screen is displayed`);663 ////browser.saveScreenshot();664 }665 break;666 case 'ios':667 const dateobj = new Date();668 const systemdate = dateobj.getDate();669 const calendardotcheck = browser.element(`${fileutils.readPropertyFile(platform, object)}`);670 const currentdateincalendar = $(fileutils.readPropertyFile(platform, 'CalendarCurrentDate')).getText();671 if (currentdateincalendar.includes(systemdate) && calendardotcheck.isEnabled()) {672 console.log(`${'Dot is present for the current date: '}${currentdateincalendar}`);673 } else {674 console.log(`${'Dot is missing for the current date:'}${currentdateincalendar}`);675 }676 break;677 case 'web':678 // web operation679 break;680 default:681 break;682 }683 } catch (e) {684 console.error(`${object} screen is not displayed`);685 ////browser.saveScreenshot();686 return assert.strictEqual(platform, '', e);687 }688});689/*690Then statement to verify for future months691*/692Then(/^I must not see the future date or month$/, async () => {693 try {694 switch (platform) {695 case 'android':696 break;697 case 'ios':698 const calendarmonth = browser.element(`${fileutils.readPropertyFile(platform, 'Calendar.Month')}`).getText();699 const futuremonth = moment().add(1, 'month').format('MMMM YYYY');700 console.log(`${'Future Month is: '}${futuremonth}`);701 if (calendarmonth.includes(futuremonth)) {702 console.log('Future month visible to log');703 } else {704 console.log('Future month not visible to log');705 }706 break;707 case 'web':708 // web operation709 break;710 default: break711 }712 } catch (e) {713 console.error('Unable to see the future date or month');714 //browser.saveScreenshot();715 return assert.strictEqual(platform, '', e);716 }717});718Then(/^I should see "([^"]*)" on "([^"]*)" screen$/, async (object, screen) => {719 try {720 let dotPosition721 let str722 switch (platform) {723 case 'android':724 // android code here----725 break;726 case 'ios':727 switch (screen) {728 case 'Empty.Migraine.Details':729 dotPosition = object.indexOf('.');730 str = object.substring(0, dotPosition);731 const iconsCount = browser.elements("//XCUIElementTypeImage[@name='addevent_image_view']").value.length;732 const list = [iconsCount];733 each(list, () => {734 const iconText = browser.elements("//XCUIElementTypeImage[@name='addevent_image_view']/following-sibling::XCUIElementTypeStaticText[@name='addevent_icontitle_text']").getText();735 iconText.forEach((value) => {736 if (str === value) {737 console.log(`${object} is displayed`);738 }739 });740 })741 ////browser.saveScreenshot();742 break;743 case 'MigraineSeverity':744 const additionalcardsdetails = browser.elements("//XCUIElementTypeStaticText[contains(@name,'Number of days')]").getText();745 const textfromconfig = appconfig.verifyTextFromConfig(screen);746 const result = [];747 each(textfromconfig, (value) => {748 result.push(value);749 });750 if ((additionalcardsdetails.some(ele => result.includes(ele)))) {751 console.log('---Additional cards are displayed---');752 console.log(`${result[5]} `, 'and', ` ${result[6]}`);753 console.log('------------------------------------');754 } else {755 console.log('Additional cards are not displayed');756 }757 break;758 default: break759 }760 break;761 case 'web':762 // web operation763 break;764 default: break765 }766 } catch (e) {767 console.error(`${object} is not displayed`);768 //browser.saveScreenshot();769 return assert.strictEqual(platform, '', e);770 }771});772Then(/^I should see "([^"]*)" text on "([^"]*)" screen$/, async (object, screen) => {773 try {774 switch (platform) {775 case 'android':776 // android code here----777 break;778 case 'ios':779 switch (screen) {780 case 'Empty.Migraine.Details':781 browser.elements("//XCUIElementTypeStaticText[@name='addevent_icontitle_text']").value.forEach((element) => {782 const val = browser.elementIdText(element.ELEMENT).value;783 if (val === object) {784 return console.log(`${object} text is displayed`);785 }786 });787 ////browser.saveScreenshot();788 break;789 default: break790 }791 break;792 case 'web':793 // web operation794 break;795 default: break796 }797 } catch (e) {798 console.error(`${object} is not displayed`);799 //browser.saveScreenshot();800 return assert.strictEqual(platform, '', e);801 }802});803When(/^I tap "([^"]*)" icon on "([^"]*)" screen$/, async (object, screen) => {804 try {805 switch (platform) {806 case 'android':807 // android code here----808 break;809 case 'ios':810 switch (screen) {811 case 'Empty.Migraine.Details':812 browser.elements('~addevent_icontitle_text').value.forEach((element) => {813 const val = browser.elementIdText(element.ELEMENT).value;814 if (val === object) {815 const { x } = browser.elementIdLocation(element.ELEMENT).value;816 const { y } = browser.elementIdLocation(element.ELEMENT).value;817 return mobileElementAction.tapByCoordinates(x, y);818 }819 });820 console.log(`Clicked on ${object}`);821 ////browser.saveScreenshot();822 break;823 default: break824 }825 break;826 case 'web':827 // web operation828 break;829 default: break830 }831 } catch (e) {832 console.error(`${object} is not displayed`);833 //browser.saveScreenshot();834 return assert.strictEqual(platform, '', e);835 }836});837Then(/^"([^"]*)" (?:symptom|symptoms) should (?:remain|get) selected on "([^"]*)" with a "([^"]*)"$/, async (count, listName, object) => {838 try {839 switch (platform) {840 case 'android':841 // android code here842 break;843 case 'ios':844 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');845 if (exists) {846 browser.elements("//XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']/following-sibling::XCUIElementTypeStaticText[@name='widget_symptomslistcomponentlabel_text']").value.forEach(element => console.log(`Symptom selected: ${browser.elementIdText(element.ELEMENT).value} ,tickmark is visible`));847 ////browser.saveScreenshot();848 break;849 }850 break851 case 'web':852 // web operation853 break;854 default: break855 }856 } catch (e) {857 console.error('Symptom is not selected');858 //browser.saveScreenshot();859 return assert.strictEqual(platform, '', e);860 }861});862Then(/^"([^"]*)" symptom should remain unselected on "([^"]*)"$/, async (count, listName) => {863 try {864 switch (platform) {865 case 'android':866 // android code here867 break;868 case 'ios':869 const exists = browser.waitUntil(() => browser.elements('~widget_symptomslistcomponentlabel_text').isVisible(), timeOutinMs, 'Element not found');870 if (exists) {871 const textFromConfig = appconfig.verifyTextFromConfig(listName);872 const selectedSymptoms = browser.elements("//XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']/following-sibling::XCUIElementTypeStaticText[@name='widget_symptomslistcomponentlabel_text']").getText();873 const unique = textFromConfig.filter(o => selectedSymptoms.indexOf(o) === -1);874 console.log(`Symptom not selected: ${unique}`);875 ////browser.saveScreenshot();876 break;877 }878 break879 case 'web':880 // web operation881 break;882 default: break883 }884 } catch (e) {885 console.error(`${listName} is not displayed`);886 //browser.saveScreenshot();887 return assert.strictEqual(platform, '', e);888 }889});890/*891Then statement to verify for migraine days card severity level892*/893Then(/^I must be able to verify the "([^"]*)" card for severity levels for "([^"]*)"$/, async (object, value) => {894 try {895 switch (platform) {896 case 'android':897 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');898 if (check) {899 console.log(`${object} screen is displayed`);900 ////browser.saveScreenshot();901 }902 break;903 case 'ios':904 let i905 const migrainedayscard = browser.element(`${fileutils.readPropertyFile(platform, object)}`);906 if (migrainedayscard.isVisible()) {907 const migrainedaystext = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();908 console.log(`${migrainedaystext} `, 'card is displayed for', `${value}`);909 const severity = browser.elements('//XCUIElementTypeStaticText[@name="migraine_attack_level"]').getText();910 const dayscount = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getText();911 const severityforintensityandimpairment = ['Mild', 'Moderate', 'Severe'];912 const severifyforimapirment = ['Able', 'Mild', 'Moderate', 'Severe'];913 if (value === 'Calendar.Intensity') {914 if (JSON.stringify(severity) === JSON.stringify(severityforintensityandimpairment)) {915 console.log('---Migraine Severity levels count---');916 for (i = 0; i < severity.length; i += 1) {917 console.log(`${severity[i]}:${dayscount[i]}`);918 }919 } else {920 console.log(`${'Severity levels not displayed proper for '}${value}`);921 console.log('Severity levels displayed for ', `${value}is`, `${severity[i]}`);922 }923 console.log('------------------------------------');924 } else if (value === 'Calendar.Intensity.and.Impairment') {925 console.log('---Migraine Severity levels count---');926 if (JSON.stringify(severity) === JSON.stringify(severityforintensityandimpairment)) {927 for (i = 0; i < severity.length; i += 1) {928 console.log(`${severity[i]}:${dayscount[i]}`);929 }930 } else {931 console.log('Severity levels not displayed proper for ', `${value}`);932 console.log('Severity levels displayed for ', `${value}is`, `${severity[i]}`);933 }934 console.log('------------------------------------');935 } else if (value === 'Calendar.Impairment') {936 console.log('---Migraine Severity levels count---');937 if (JSON.stringify(severity) === JSON.stringify(severifyforimapirment)) {938 for (i = 0; i < severity.length; i += 1) {939 console.log(`${severity[i]}:${dayscount[i]}`);940 }941 } else {942 console.log('Severity levels not displayed proper for', `${value}`);943 console.log('Severity levels displayed for', `${value}`, 'is', `${severity[i]}`);944 }945 console.log('------------------------------------');946 } else {947 console.log(`${value}`, 'isn\'t present among the list');948 }949 }950 break;951 case 'web':952 // web operation953 break;954 default: break955 }956 } catch (e) {957 console.error(`${object} screen is not displayed`);958 //browser.saveScreenshot();959 return assert.strictEqual(platform, '', e);960 }961});962/*963Then statement to capture the total count of migraine days964*/965Then(/^I must be able to verify the total days recorded for "([^"]*)" for "([^"]*)"$/, async (object, value) => {966 try {967 switch (platform) {968 case 'android':969 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');970 if (check) {971 console.log(`${object} screen is displayed`);972 ////browser.saveScreenshot();973 }974 break;975 case 'ios':976 const severitylabels = browser.elements('//XCUIElementTypeStaticText[@name="migraine_attack_level"]').getText();977 const migrainedayscount = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getText();978 const undetailedattackcount = browser.elements('//XCUIElementTypeImage[@name="calendar_icon_view"]').value.length;979 const arr = [undetailedattackcount];980 let sumofseverityinmigrainecard = 0;981 let sumofundetailedattack = 0;982 for (let i = 0; i < severitylabels.length; i += 1) {983 sumofseverityinmigrainecard += parseInt(migrainedayscount[i], 10);984 }985 console.log('Total count for severity levels in the migraine days card is: ', `${sumofseverityinmigrainecard}`);986 each(arr, (arrValue) => {987 sumofundetailedattack += parseInt(arrValue, 10);988 })989 console.log(`${'Total count for undetailed attack is:'}${sumofundetailedattack}`);990 const totalsum = sumofseverityinmigrainecard + sumofundetailedattack;991 const migrainetotaldays = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();992 const migrainetotaldaysnumber = parseInt(migrainetotaldays, 10);993 const calendarmonth = browser.element(`${fileutils.readPropertyFile(platform, 'Calendar.Month')}`).getText();994 if (migrainetotaldaysnumber === totalsum) {995 console.log('The total count of days is matching');996 console.log('Total count displayed on Migraine card for', `${value}`, 'is:', `${migrainetotaldaysnumber}`, 'for the month of', `${calendarmonth}`);997 console.log('Total count calculated for severity levels and undetailed attack for', `${value} `, 'is:', ` ${totalsum} `, 'for the month of', ` ${calendarmonth}`);998 } else {999 console.log('The total count of days is not matching');1000 console.log('Total count displayed on Migraine card for', `${value}`, 'is:', `${migrainetotaldaysnumber}`, 'for the month of', ` ${calendarmonth}`);1001 console.log('Total count calculated for severity levels and undetailed attack for', `${value}`, 'is:', `${totalsum}`, 'for the month of', `${calendarmonth}`);1002 }1003 break;1004 case 'web':1005 // web operation1006 break;1007 default: break1008 }1009 } catch (e) {1010 console.error(`${object} screen is not displayed`);1011 //browser.saveScreenshot();1012 return assert.strictEqual(platform, '', e);1013 }1014});1015/*1016Then statement to swipe up the migraine card1017*/1018Then(/^I must be able to swipe up the "([^"]*)" card$/, async (object) => {1019 try {1020 switch (platform) {1021 case 'android':1022 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1023 if (check) {1024 console.log(`${object} screen is displayed`);1025 ////browser.saveScreenshot();1026 }1027 break;1028 case 'ios':1029 const MigraineDaysCardX = $(fileutils.readPropertyFile(platform, 'Migraine.Days.for.XYcoordinate')).getLocation('x');1030 const MigraineDaysCardY = $(fileutils.readPropertyFile(platform, 'Migraine.Days.for.XYcoordinate')).getLocation('y');1031 const CalendarSummaryX = $(fileutils.readPropertyFile(platform, 'Calendar.summary.forXYcoordinate')).getLocation('x');1032 const CalendarSummaryY = $(fileutils.readPropertyFile(platform, 'Calendar.summary.forXYcoordinate')).getLocation('y');1033 browser.touchMultiPerform([1034 { action: 'press', options: { x: MigraineDaysCardX, y: MigraineDaysCardY } },1035 { action: 'wait', options: { ms: 2000 } },1036 { action: 'moveTo', options: { x: CalendarSummaryX, y: CalendarSummaryY } },1037 { action: 'release' },1038 ]);1039 ////browser.saveScreenshot();1040 break1041 case 'web':1042 // web operation1043 break;1044 default: break1045 }1046 } catch (e) {1047 console.error(`${object} screen is not displayed`);1048 //browser.saveScreenshot();1049 return assert.strictEqual(platform, '', e);1050 }1051});1052/*1053Then statement to verify the order of additional cards1054*/1055Then(/^I must verify the order of additional cards displayed$/, async () => {1056 try {1057 switch (platform) {1058 case 'android':1059 break;1060 case 'ios':1061 const additionalcardstext = browser.elements("//XCUIElementTypeStaticText[contains(@name,'Number of days')]").getText();1062 for (let i = 0; i < ((additionalcardstext.length) - 1); i += 1) {1063 const textindexforPain = additionalcardstext.indexOf(additionalcardstext[i]);1064 const textindexforImpact = additionalcardstext.indexOf(additionalcardstext[i + 1]);1065 if (textindexforPain < textindexforImpact) {1066 console.log(`${additionalcardstext[i]} `, 'is displayed first in the migraine days card');1067 console.log(`${additionalcardstext[i + 1]} `, 'is displayed second in the migraine days card');1068 } else {1069 console.log(`${additionalcardstext[i + 1]} `, 'is displayed first in the migraine days card');1070 console.log(`${additionalcardstext[i]} `, 'is displayed second in the migraine days card');1071 }1072 }1073 break1074 case 'web':1075 // web operation1076 break;1077 default: break1078 }1079 } catch (e) {1080 console.error('Cannot display the order of additional cards displayed');1081 //browser.saveScreenshot();1082 return assert.strictEqual(platform, '', e);1083 }1084});1085/*1086Then statement to see the days logged for additional card - Moderate to Severe Pain1087*/1088Then(/^I must be able to see the number of days logged for "([^"]*)" card$/, async (object) => {1089 try {1090 switch (platform) {1091 case 'android':1092 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1093 if (check) {1094 console.log(`${object} screen is displayed`);1095 ////browser.saveScreenshot();1096 }1097 break;1098 case 'ios':1099 if (object === 'Moderate.to.Severe.pain') {1100 const additionalcardspain = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Pain'));1101 if (additionalcardspain.isVisible()) {1102 const additionalcardspaintext = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Pain')).getText();1103 const moderatepaintext = $(fileutils.readPropertyFile(platform, 'Moderate.Pain')).getText();1104 const severepaintext = $(fileutils.readPropertyFile(platform, 'Severe.Pain')).getText();1105 const moderatepainvalue = $(fileutils.readPropertyFile(platform, 'Moderate.Pain.Days.Count')).getText();1106 const severepainvalue = $(fileutils.readPropertyFile(platform, 'Severe.Pain.Days.Count')).getText();1107 console.log(`${'First additional card is visible:'} ${additionalcardspaintext} `);1108 console.log(`${'---Severity days count for'} ${additionalcardspaintext} `, '---');1109 console.log(`${moderatepaintext}: `, ` ${moderatepainvalue} `);1110 console.log(`${severepaintext}: `, ` ${severepainvalue} `);1111 }1112 console.log(`${object} `, 'is displayed');1113 ////browser.saveScreenshot();1114 } else if (object === 'Moderate.to.Severe.impact') {1115 const additionalcardsimpact = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Impact'));1116 if (additionalcardsimpact.isVisible()) {1117 const additionalcardsimpacttext = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Impact')).getText();1118 const moderateimpairmenttext = $(fileutils.readPropertyFile(platform, 'Moderate.Impairment')).getText();1119 const severeimpairmenttext = $(fileutils.readPropertyFile(platform, 'Severe.Impairment')).getText();1120 const moderateimpairmentvalue = $(fileutils.readPropertyFile(platform, 'Moderate.Impairment.Days.Count')).getText();1121 const severeimpairmentvalue = $(fileutils.readPropertyFile(platform, 'Severe.Impairment.Days.Count')).getText();1122 console.log(`${'Second additional card is visible: '} ${additionalcardsimpacttext} `);1123 console.log(`${'---Severity days count for '} ${additionalcardsimpacttext} `, '---');1124 console.log(`${moderateimpairmenttext}: `, ` ${moderateimpairmentvalue} `);1125 console.log(`${severeimpairmenttext}: `, ` ${severeimpairmentvalue} `);1126 }1127 console.log(`${object} `, 'is displayed');1128 ////browser.saveScreenshot();1129 }1130 break1131 case 'web':1132 // web operation1133 break;1134 default: break1135 }1136 } catch (e) {1137 console.error(`${object} screen is not displayed`);1138 //browser.saveScreenshot();1139 return assert.strictEqual(platform, '', e);1140 }1141});1142/*1143Then statement to scroll up1144*/1145Then(/^I scroll up to view the rest of the migraine card details$/, async () => {1146 try {1147 switch (platform) {1148 case 'android':1149 break;1150 case 'ios':1151 const Xcoord = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Impact')).getLocation('x');1152 const Ycoord = $(fileutils.readPropertyFile(platform, 'Number.of.Days.M.to.S.Impact')).getLocation('y');1153 browser.touchMultiPerform([1154 { action: 'press', options: { x: Xcoord, y: Ycoord } },1155 { action: 'wait', options: { ms: 2000 } },1156 { action: 'moveTo', options: { x: 10, y: 10 } },1157 { action: 'release' },1158 ]);1159 ////browser.saveScreenshot();1160 break1161 case 'web':1162 // web operation1163 break1164 default: break1165 }1166 } catch (e) {1167 console.error('Cannot scroll up');1168 ////browser.saveScreenshot();1169 return assert.strictEqual(platform, '', e);1170 }1171});1172When(/^I should see all "([^"]*)" of the "([^"]*)"$/, async (count, object) => {1173 try {1174 switch (platform) {1175 case 'android':1176 // perform operation on android element1177 break;1178 case 'ios':1179 const verifyLabels = function verifyLabels(xpaths) {1180 const text = browser.elements(xpaths).getText();1181 console.log(text);1182 const textFromConfig = appconfig.verifyTextFromConfig(text);1183 console.log(textFromConfig);1184 if (text === textFromConfig) {1185 console.log('\n Actual and expected match \n', 'Actual :', `${text} \n`, 'Expected :', `${textFromConfig} `);1186 } else {1187 console.log('\n', 'Actual and expected do not match \n', 'Actual :', `${text} `, '\n Expected :', `${textFromConfig} `);1188 }1189 }1190 for (let i = 1; i <= count; i += 1) {1191 let xpath = fileutils.readPropertyFile(platform, object);1192 xpath = `${xpath} [${String(i)}]`;1193 console.log(xpath);1194 verifyLabels(xpath);1195 }1196 break;1197 case 'web':1198 // perform operation on web element1199 break;1200 default: break1201 }1202 } catch (e) {1203 console.error(` Cannot click on ${object} ${e} `);1204 //browser.saveScreenshot();1205 return assert.strictEqual(platform, '', e);1206 }1207});1208Then(/^I verify "([^"]*)" texts for "([^"]*)" (?:screen|field)$/, async (object, screen) => {1209 try {1210 switch (platform) {1211 case 'android':1212 // android here1213 break;1214 case 'ios':1215 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object)).isVisible(), timeOutinMs, 'Element not found');1216 if (exists) {1217 const textFromConfig = appconfig.verifyTextFromConfig(screen);1218 browser.elements('~impairment_detaillabel_text').value.forEach((element) => {1219 for (let i = 0; i < textFromConfig.length; i += 1) {1220 if (textFromConfig[i] === browser.elementIdText(element.ELEMENT).value) {1221 return console.log(`Labels Displayed and Matched: ${browser.elementIdText(element.ELEMENT).value} `);1222 }1223 }1224 });1225 ////browser.saveScreenshot();1226 break;1227 }1228 break1229 case 'web':1230 // web operation1231 break;1232 default: break1233 }1234 } catch (e) {1235 console.error(`${object} is not displayed`);1236 //browser.saveScreenshot();1237 return assert.strictEqual(platform, '', e);1238 }1239});1240// Matches Object Date with Current date in given format1241Then(/^I must verify "([^"]*)" matches in the "([^"]*)" (?:screen|field)$/, async (object, screen) => {1242 try {1243 switch (platform) {1244 case 'android':1245 // android here---1246 break;1247 case 'ios':1248 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1249 if (exists) {1250 const textFromConfig = appconfig.verifyTextFromConfig(screen);1251 const CurrentDate = moment().format(textFromConfig);1252 console.log(CurrentDate);1253 const ObjectDate = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1254 if (ObjectDate === CurrentDate) {1255 console.log(`Object Date matches current Date: ${ObjectDate} `);1256 } else {1257 console.log(`Object Date doesnt matches current Date: ${ObjectDate} `);1258 }1259 ////browser.saveScreenshot();1260 break;1261 }1262 break1263 case 'web':1264 // web operation1265 break;1266 default: break1267 }1268 } catch (e) {1269 console.error(`${object} screen is not displayed`);1270 //browser.saveScreenshot();1271 return assert.strictEqual(platform, '', e);1272 }1273});1274Then(/^I should not see "([^"]*)" (?:section|text|message|card)$/, async (object) => {1275 try {1276 switch (platform) {1277 case 'android':1278 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible() == false, timeOutinMs, `${object} not found`);1279 if (exists1) {1280 console.log(`${object} is not displayed`);1281 ////browser.saveScreenshot();1282 }1283 break1284 case 'ios':1285 try{1286 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, `${object} not found`);1287 if (exists) {1288 console.log(`${object} is displayed`);1289 ////browser.saveScreenshot();1290 }1291 }1292 catch(e){1293 console.log(`${object} is not displayed`);1294 }1295 break;1296 case 'Web':1297 // web operation1298 break;1299 default: break1300 }1301 } catch (e) {1302 console.error(`${object} is not displayed`);1303 //browser.saveScreenshot();1304 return assert.strictEqual(platform, '', e);1305 }1306});1307/*1308Then statement to mouse scroll up1309*/1310Then(/^I must be able to pull down the migraine card to view the "([^"]*)"$/, async (object) => {1311 try {1312 switch (platform) {1313 case 'android':1314 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1315 if (check) {1316 console.log(`${object} screen is displayed`);1317 ////browser.saveScreenshot();1318 }1319 break;1320 case 'ios':1321 mobileactions.mobileScroll('up');1322 const caldays = $(fileutils.readPropertyFile(platform, object));1323 if (caldays.isEnabled()) {1324 console.log('Calendar days are visible after pulling down the migraine card');1325 const caldaystext = browser.elements('//XCUIElementTypeStaticText[@name="calendar_weekday_text"]').getText();1326 for (let i = 0; i < caldaystext.length; i += 1) {1327 console.log(`${caldaystext[i]} `);1328 }1329 } else {1330 console.log('Unable to pull down the migraine card and the calendar days are not visible');1331 }1332 ////browser.saveScreenshot();1333 break;1334 case 'web':1335 // web operation1336 break;1337 default: break1338 }1339 } catch (e) {1340 console.error(`${object} screen is not displayed`);1341 //browser.saveScreenshot();1342 return assert.strictEqual(platform, '', e);1343 }1344});1345Then(/^I should not see tickmark beside symptoms$/, async () => {1346 try {1347 let count = 0;1348 switch (platform) {1349 case 'android':1350 // android code here1351 break;1352 case 'ios':1353 browser.elements("//XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']").value.forEach((element) => {1354 if (browser.elementIdDisplayed(element.ELEMENT)) {1355 count += 1;1356 }1357 });1358 if (count > 0) {1359 return console.log('Symptoms are not reset');1360 }1361 ////browser.saveScreenshot();1362 break;1363 case 'web':1364 // web operation1365 break;1366 default: break1367 }1368 } catch (e) {1369 console.error('Symptom selected');1370 //browser.saveScreenshot();1371 return assert.strictEqual(platform, '', e);1372 }1373});1374Then(/^I should enter HCPCode into "([^"]*)" field$/, async (object) => {1375 try {1376 let i;1377 switch (platform) {1378 case 'android':1379 // android code here1380 break;1381 case 'ios':1382 const xpath = "//*[@name='registrationcode_textfield_text']";1383 const arr = HCPCode.split('');1384 const check = browser.waitUntil(() => browser.elements(xpath).isVisible(), timeOutinMs, 'Element not found');1385 if (check) {1386 for (i = 0; i < arr.length; i += 1) {1387 const j = i + 1;1388 browser.element(`${xpath} [${j}]`).setValue(arr[i]);1389 }1390 }1391 console.log('Entered HCP code in ', object, ' field');1392 ////browser.saveScreenshot();1393 break;1394 case 'web':1395 break;1396 default: break1397 }1398 } catch (e) {1399 console.error('Cannot enter code');1400 //browser.saveScreenshot();1401 return assert.strictEqual(platform, '', e);1402 }1403});1404Then(/^I enter incorrect HCPCode into "([^"]*)" field$/, async (object) => {1405 try {1406 let i;1407 switch (platform) {1408 case 'android':1409 // android code here1410 break;1411 case 'ios':1412 const xpath = "//*[@name='registrationcode_textfield_text']";1413 const arr = IncorrectHCPCode.split('');1414 const check = browser.waitUntil(() => browser.elements(xpath).isVisible(), timeOutinMs, 'Element not found');1415 if (check) {1416 for (i = 0; i < arr.length; i += 1) {1417 const j = i + 1;1418 browser.element(`${xpath} [${j}]`).setValue(arr[i]);1419 }1420 }1421 console.log(`Entered incorrect HCP code in ${object} field`);1422 ////browser.saveScreenshot();1423 break;1424 case 'web':1425 break;1426 default: break1427 }1428 } catch (e) {1429 console.error('Cannot enter code');1430 //browser.saveScreenshot();1431 return assert.strictEqual(platform, '', e);1432 }1433});1434/*1435Then statement to verify for Reports folder1436*/1437Then(/^I verify for "([^"]*)" (?:tab|text)$/, async (object) => {1438 try {1439 switch (platform) {1440 case 'Android':1441 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1442 console.log(`${object} screen is displayed`);1443 ////browser.saveScreenshot();1444 break;1445 case 'ios':1446 const reportstab = $(fileutils.readPropertyFile(platform, object));1447 if (reportstab.isVisible()) {1448 const reportstabtext = $(fileutils.readPropertyFile(platform, object)).getText();1449 console.log(`${reportstabtext} `, 'is displayed');1450 } else {1451 console.log('Reports tab is not displayed');1452 }1453 break;1454 case 'Web':1455 // web operation1456 break;1457 }1458 } catch (e) {1459 console.error(`${object} screen is not displayed`);1460 //browser.saveScreenshot();1461 return assert.strictEqual(platform, '', e);1462 }1463});1464/*1465Then statement to verify for list of days and months displayed1466*/1467Then(/^I should see the list of "([^"]*)" tabs$/, async (object) => {1468 try {1469 switch (platform) {1470 case 'Android':1471 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1472 console.log(`${object} screen is displayed`);1473 ////browser.saveScreenshot();1474 break;1475 case 'ios':1476 const daysmonths = browser.elements('//XCUIElementTypeStaticText[@name="report_range_text"]').getText();1477 console.log('----Report days and months----');1478 for (let i = 0; i < daysmonths.length; i += 1) {1479 console.log(`${daysmonths[i]} `);1480 }1481 break1482 case 'Web':1483 // web operation1484 break;1485 default: break1486 }1487 } catch (e) {1488 console.error(`${object} screen is not displayed`);1489 //browser.saveScreenshot();1490 return assert.strictEqual(platform, '', e);1491 }1492});1493/*1494Then statement to verify for 30 days tab is selected by default1495*/1496Then(/^I must verify that "([^"]*)" tab is selected by default$/, async (object) => {1497 try {1498 switch (platform) {1499 case 'Android':1500 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1501 console.log(`${object} screen is displayed`);1502 ////browser.saveScreenshot();1503 break;1504 case 'ios':1505 const firsttabtext = $(fileutils.readPropertyFile(platform, object)).getText();1506 const Migraineattacktimeperiod = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();1507 const thirtydayslessthancurrentdate = moment().subtract(30, 'days').format('DD MMM YYYY');1508 const currentdate = moment().format('DD MMM YYYY');1509 const Migraineattackdateadd = `${thirtydayslessthancurrentdate} - ${currentdate} `;1510 if (Migraineattacktimeperiod === Migraineattackdateadd) {1511 console.log(`${firsttabtext} `, 'is selected by default');1512 console.log(`${'Migraine attack time: '} ${Migraineattacktimeperiod} `);1513 } else {1514 console.log(`${firsttabtext} `, 'is not selected by default');1515 }1516 break1517 case 'Web':1518 // web operation1519 break;1520 default: break1521 }1522 } catch (e) {1523 console.error(`${object} screen is not displayed`);1524 //browser.saveScreenshot();1525 return assert.strictEqual(platform, '', e);1526 }1527});1528/*1529Then statement to display the migraine attack period for every tab selected1530*/1531Then(/^I should see "([^"]*)" for every tab selected$/, { timeout: 60 * 1000 }, async (object) => {1532 try {1533 switch (platform) {1534 case 'Android':1535 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1536 console.log(`${object} screen is displayed`);1537 ////browser.saveScreenshot();1538 break;1539 case 'ios':1540 // Display Migraine attack period for 30 days tab1541 const firsttab = $(fileutils.readPropertyFile(platform, '30.Days'));1542 if (firsttab.isVisible()) {1543 const Migraineattacktimeperiodfirstab = $(fileutils1544 .readPropertyFile(platform, object)).getText();1545 const firsttabtext = $(fileutils.readPropertyFile(platform, '30.Days')).getText();1546 console.log(`${firsttabtext} `, 'tab, Migraine attack period is:', ` ${Migraineattacktimeperiodfirstab} `);1547 } else {1548 console.log(`${firsttab} `, 'is not visible');1549 }1550 // Display Migraine attack period for 90 days tab1551 const secondtab = $(fileutils.readPropertyFile(platform, '90.Days'));1552 if (secondtab.isVisible()) {1553 secondtab.click();1554 const Migraineattacktimeperiodsecondtab = $(fileutils1555 .readPropertyFile(platform, object)).getText();1556 const secondtabtext = $(fileutils.readPropertyFile(platform, '90.Days')).getText();1557 console.log(`${secondtabtext} `, 'tab, Migraine attack period is:', ` ${Migraineattacktimeperiodsecondtab} `);1558 } else {1559 console.log(`${secondtab} `, 'is not visible');1560 }1561 // Display Migraine attack period for 6 months tab1562 const thirdtab = $(fileutils.readPropertyFile(platform, '6.Months'));1563 if (thirdtab.isVisible()) {1564 thirdtab.click();1565 const Migraineattacktimeperiodthirdtab = $(fileutils1566 .readPropertyFile(platform, object)).getText();1567 const thirdtabtext = $(fileutils.readPropertyFile(platform, '6.Months')).getText();1568 console.log(`${thirdtabtext} `, 'tab,Migraine attack period is:', ` ${Migraineattacktimeperiodthirdtab} `);1569 } else {1570 console.log(`${thirdtab} `, 'is not visible');1571 }1572 // Swipe left to make 12 months tab also visible1573 const x = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('x');1574 const y = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('y');1575 const x1 = $(fileutils.readPropertyFile(platform, '90.Days')).getLocation('x');1576 const y1 = $(fileutils.readPropertyFile(platform, '90.Days')).getLocation('y');1577 browser.execute('mobile:dragFromToForDuration', {1578 element: thirdtab, duration: 0.5, fromX: x, fromY: y, toX: x1, toY: y1,1579 });1580 // Display Migraine attack period for 6 months tab1581 const fourthtab = $(fileutils.readPropertyFile(platform, '12.Months'));1582 if (fourthtab.isVisible()) {1583 fourthtab.click();1584 const Migraineattacktimeperiodfourthtab = $(fileutils1585 .readPropertyFile(platform, object)).getText();1586 const fourthtabtext = $(fileutils.readPropertyFile(platform, '12.Months')).getText();1587 console.log(`${fourthtabtext} `, 'tab, Migraine attack period is:', ` ${Migraineattacktimeperiodfourthtab} `);1588 } else {1589 console.log(`${fourthtab} `, 'is not visible');1590 }1591 break1592 case 'Web':1593 // web operation1594 break;1595 default: break1596 }1597 } catch (e) {1598 console.error(`${object} screen is not displayed`);1599 //browser.saveScreenshot();1600 return assert.strictEqual(platform, '', e);1601 }1602});1603/*1604Then statement to verify for generate pdf and hamburger menu icon1605*/1606Then(/^I must see "([^"]*)" and "([^"]*)" menu icons on the top$/, async (object, value) => {1607 try {1608 switch (platform) {1609 case 'Android':1610 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1611 console.log(`${object} screen is displayed`);1612 ////browser.saveScreenshot();1613 break;1614 case 'ios':1615 const genpdf = $(fileutils.readPropertyFile(platform, object));1616 const hamicon = browser.element(`${fileutils.readPropertyFile(platform, 'Hamburger')} `);1617 if (genpdf.isEnabled() && hamicon.isEnabled()) {1618 console.log(`${object} `, 'and', ` ${value} `, 'icons are present');1619 } else {1620 console.log(`${object} `, 'and', ` ${value} `, 'icons are not present');1621 }1622 break1623 case 'Web':1624 // web operation1625 break;1626 default: break1627 }1628 } catch (e) {1629 console.error(`${object} `, `or${value} screen is not displayed`);1630 //browser.saveScreenshot();1631 return assert.strictEqual(platform, '', e);1632 }1633});1634/*1635Then statement to verify that select comparison view is not selected buy default1636*/1637Then(/^I must verify that "([^"]*)" is not selected by default$/, async (object) => {1638 try {1639 switch (platform) {1640 case 'Android':1641 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1642 console.log(`${object} screen is displayed`);1643 ////browser.saveScreenshot();1644 break;1645 case 'ios':1646 const secompare = browser.element(`${fileutils.readPropertyFile(platform, object)}`);1647 if (secompare.isVisible()) {1648 const secomparevalue = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('value');1649 if (secomparevalue.includes('Please select a comparison view')) {1650 console.log(`${secomparevalue} `, 'is displayed by default');1651 } else {1652 console.log(`${secomparevalue} `, 'is displayed by default instead of the default \'Please select a comparison view\'');1653 }1654 } else {1655 console.log(`${secompare} `, 'is not visible');1656 }1657 break1658 case 'Web':1659 // web operation1660 break;1661 default: break1662 }1663 } catch (e) {1664 console.error(`${object} `, ' screen is not displayed');1665 //browser.saveScreenshot();1666 return assert.strictEqual(platform, '', e);1667 }1668});1669/*1670Then statement to display the number of days logged for Migraine1671*/1672Then(/^I should see the "([^"]*)" in each time period$/, async (object) => {1673 try {1674 switch (platform) {1675 case 'Android':1676 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1677 console.log(`${object} screen is displayed`);1678 ////browser.saveScreenshot();1679 break;1680 case 'ios':1681 const firsttab = $(fileutils.readPropertyFile(platform, '30.Days'));1682 if (firsttab.isVisible()) {1683 firsttab.click();1684 const firsttabtext = $(fileutils.readPropertyFile(platform, '30.Days')).getText();1685 const migrainedaysfirstab = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1686 console.log(`${firsttabtext} `, 'tab,number of Migraine days logged:', ` ${migrainedaysfirstab} `);1687 } else {1688 console.log(`${firsttab} `, 'is not visible');1689 }1690 const secondtab = $(fileutils.readPropertyFile(platform, '90.Days'));1691 if (secondtab.isVisible()) {1692 secondtab.click();1693 const secondtabtext = $(fileutils.readPropertyFile(platform, '90.Days')).getText();1694 const migrainedayssecondtab = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1695 console.log(`${secondtabtext} `, 'tab,number of Migraine days logged:', ` ${migrainedayssecondtab} `);1696 } else {1697 console.log(`${secondtab} `, 'is not visible');1698 }1699 const thirdtab = $(fileutils.readPropertyFile(platform, '6.Months'));1700 if (thirdtab.isVisible()) {1701 thirdtab.click();1702 const thirdtabtext = $(fileutils.readPropertyFile(platform, '6.Months')).getText();1703 const migrainedaysthirdtab = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1704 console.log(`${thirdtabtext} `, 'tab,number of Migraine days logged:', ` ${migrainedaysthirdtab} `);1705 } else {1706 console.log(`${thirdtab} `, 'is not visible');1707 }1708 // Swipe left to make 12 months tab also visible1709 const x = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('x');1710 const y = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('y');1711 const x1 = $(fileutils.readPropertyFile(platform, '90.Days')).getLocation('x');1712 const y1 = $(fileutils.readPropertyFile(platform, '90.Days')).getLocation('y');1713 browser.execute('mobile:dragFromToForDuration', {1714 element: thirdtab, duration: 0.5, fromX: x, fromY: y, toX: x1, toY: y1,1715 });1716 const fourthtab = $(fileutils.readPropertyFile(platform, '12.Months'));1717 if (fourthtab.isVisible()) {1718 fourthtab.click();1719 const fourthabtext = $(fileutils.readPropertyFile(platform, '12.Months')).getText();1720 const migrainedaysfourthtab = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1721 console.log(`${fourthabtext} `, 'tab,number of Migraine days logged:', ` ${migrainedaysfourthtab} `);1722 } else {1723 console.log(`${fourthtab} `, 'is not visible');1724 }1725 break1726 case 'Web':1727 // web operation1728 break;1729 default: break1730 }1731 } catch (e) {1732 console.error(`${object} `, ' screen is not displayed');1733 //browser.saveScreenshot();1734 return assert.strictEqual(platform, '', e);1735 }1736});1737/*1738Then statement to swipe up to the reports header1739*/1740Then(/^I swipe up to the Reports header$/, async () => {1741 try {1742 switch (platform) {1743 case 'Android':1744 // Perform for Android1745 break;1746 case 'ios':1747 browser.execute('mobile:swipe', { direction: 'down' });1748 browser.pause(1000);1749 browser.execute('mobile:swipe', { direction: 'down' });1750 break1751 case 'Web':1752 // web operation1753 break;1754 default: break1755 }1756 } catch (e) {1757 console.error('Unable to swipe up to the Reports header');1758 //browser.saveScreenshot();1759 return assert.strictEqual(platform, '', e);1760 }1761});1762/*1763Then statement to verify the days logged for each migraine card1764*/1765Then(/^I should see days logged for each card in "([^"]*)" tab$/, { timeout: 60 * 1000 }, async (object) => {1766 try {1767 switch (platform) {1768 case 'Android':1769 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1770 console.log(`${object} screen is displayed`);1771 ////browser.saveScreenshot();1772 break;1773 case 'ios':1774 const moderateseveredetails = function moderateseveredetails() {1775 const modtoseverepain = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Pain'));1776 if (modtoseverepain.isVisible()) {1777 const modetoseverepaintext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Pain')).getText();1778 const moderatetext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.Pain')).getText();1779 const moderatedaystext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.Pain.Days')).getText();1780 const severetext = $(fileutils.readPropertyFile(platform, 'Reports.Severe.Pain')).getText();1781 const severedaystext = $(fileutils.readPropertyFile(platform, 'Reports.Severe.Pain.Days')).getText();1782 console.log(`-- - ${modetoseverepaintext} --- `);1783 console.log(`${moderatetext}: `, ` ${moderatedaystext} `);1784 console.log(`${severetext}: `, ` ${severedaystext} `);1785 } else {1786 console.log(`${modtoseverepain} `, 'is not visible');1787 }1788 const xcoordforimpactcard = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Impact')).getLocation('x');1789 const ycoordforimpactcard = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Impact')).getLocation('y');1790 browser.execute('mobile:swipe', { direction: 'up', toX: xcoordforimpactcard, toY: ycoordforimpactcard });1791 const modtosevereimpact = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Impact'));1792 if (modtosevereimpact.isVisible()) {1793 const modetosevereimpacttext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.to.Severe.Impact')).getText();1794 const moderateimpacttext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.Impact')).getText();1795 const moderateimpactdaystext = $(fileutils.readPropertyFile(platform, 'Reports.Moderate.Impact.Days')).getText();1796 const severeimpacttext = $(fileutils.readPropertyFile(platform, 'Reports.Severe.Impact')).getText()1797 const severeimpactdaystext = $(fileutils.readPropertyFile(platform, 'Reports.Severe.Impact.Days')).getText()1798 console.log(`-- - ${modetosevereimpacttext} --- `);1799 console.log(`${moderateimpacttext}: ${moderateimpactdaystext} `);1800 console.log(`${severeimpacttext}: ${severeimpactdaystext} `);1801 } else {1802 console.log(`${modtosevereimpact} `, 'is not visible');1803 }1804 const medtaken = $(fileutils.readPropertyFile(platform, 'Medication.Taken'));1805 if (medtaken.isEnabled()) {1806 const medtakentext = $(fileutils.readPropertyFile(platform, 'Medication.Taken')).getText();1807 console.log(`${medtakentext} `, 'header is present');1808 const acard = $(fileutils.readPropertyFile(platform, 'Reports.Acute.Card')).getText();1809 const acarddaysdetails = browser.elements("//XCUIElementTypeCell[XCUIElementTypeStaticText[@value='preventative']]/preceding-sibling::XCUIElementTypeCell/XCUIElementTypeStaticText[contains(@value,'Medication')]/preceding-sibling::XCUIElementTypeStaticText").getText();1810 const acarddetails = browser.elements("//XCUIElementTypeCell[XCUIElementTypeStaticText[@value='preventative']]/preceding-sibling::XCUIElementTypeCell/XCUIElementTypeStaticText[contains(@value,'Medication')]").getText();1811 console.log(`-- - ${acard} --- `);1812 for (let i = 0; i < acarddetails.length; i += 1) {1813 console.log(`${acarddetails[i]}: ${acarddaysdetails[i]} `);1814 }1815 const pcard = $(fileutils.readPropertyFile(platform, 'Reports.Preventative.Card')).getText();1816 const pcarddaysdetails = browser.elements("//XCUIElementTypeCell[XCUIElementTypeStaticText[@value='preventative']]/following-sibling::XCUIElementTypeCell/XCUIElementTypeStaticText[contains(@value,'Medication')]/preceding-sibling::XCUIElementTypeStaticText").getText();1817 const pcarddetails = browser.elements("//XCUIElementTypeCell[XCUIElementTypeStaticText[@value='preventative']]/following-sibling::XCUIElementTypeCell/XCUIElementTypeStaticText[contains(@value,'Medication')]").getText();1818 console.log(`-- - ${pcard} --- `);1819 for (let j = 0; j < pcarddaysdetails.length; j += 1) {1820 console.log(`${pcarddetails[j]}: ${pcarddaysdetails[j]} `);1821 }1822 }1823 browser.execute('mobile:swipe', { direction: 'up' });1824 const detailstaken = $(fileutils.readPropertyFile(platform, 'Report.Details'));1825 if (detailstaken.isEnabled()) {1826 const detailstext = $(fileutils.readPropertyFile(platform, 'Report.Details')).getText();1827 console.log(`${detailstext} `, 'header is present');1828 const symptoms = browser.elements("//XCUIElementTypeOther[XCUIElementTypeOther[XCUIElementTypeStaticText[contains(@value,'Details')]]]/following-sibling:: XCUIElementTypeCell/XCUIElementTypeStaticText[@name='report_detailcoun_description_text']").getText();1829 const symptomsdetail = browser.elements("//XCUIElementTypeOther[XCUIElementTypeOther[XCUIElementTypeStaticText[contains(@value,'Details')]]]/following-sibling:: XCUIElementTypeCell/XCUIElementTypeStaticText[@name='report_detailcount_title_text']").getText();1830 console.log(`-- - ${detailstext} --- `);1831 for (let i = 0; i < symptoms.length; i += 1) {1832 console.log(`${symptoms[i]}: ${symptomsdetail[i]} `);1833 }1834 }1835 browser.execute('mobile:swipe', { direction: 'down' });1836 }1837 if (object === '30.Days') {1838 $(fileutils.readPropertyFile(platform, '30.Days')).click();1839 console.log(`${'Displaying the details for '} ${object} `, 'tab:');1840 const Migraineattacktimeperiodfirstab = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();1841 console.log(`${'Migraine Attack Period: '} ${Migraineattacktimeperiodfirstab} `);1842 moderateseveredetails();1843 } else if (object === '90.Days') {1844 $(fileutils.readPropertyFile(platform, '90.Days')).click();1845 console.log(`${'Displaying the details for '} ${object} `, 'tab:');1846 const Migraineattacktimeperiodsecondtab = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();1847 console.log(`${'Migraine Attack Period: '} ${Migraineattacktimeperiodsecondtab} `);1848 moderateseveredetails();1849 } else if (object === '6.Months') {1850 $(fileutils.readPropertyFile(platform, '6.Months')).click();1851 console.log(`${'Displaying the details for'} ${object} `, 'tab:');1852 const Migraineattacktimeperiodthirdtab = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();1853 console.log(`${'Migraine Attack Period: '} ${Migraineattacktimeperiodthirdtab} `);1854 moderateseveredetails();1855 } else if (object === '12.Months') {1856 const thirdtabx = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('x');1857 const thirdtaby = $(fileutils.readPropertyFile(platform, '6.Months')).getLocation('y');1858 browser.execute('mobile:swipe', {1859 direction: 'left', fromX: thirdtabx, fromY: thirdtaby, toX: 5, toY: 5,1860 });1861 $(fileutils.readPropertyFile(platform, '12.Months')).click();1862 console.log(`${'Displaying the details for '} ${object} `, 'tab:');1863 const Migraineattacktimeperiodfourthtab = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();1864 console.log(`${'Migraine Attack Period: '} ${Migraineattacktimeperiodfourthtab} `);1865 moderateseveredetails();1866 }1867 break1868 case 'Web':1869 // web operation1870 break;1871 default: break1872 }1873 } catch (e) {1874 console.error(`${object} `, ' screen is not displayed');1875 //browser.saveScreenshot();1876 return assert.strictEqual(platform, '', e);1877 }1878});1879/*1880Then statement to verify the days logged for each migraine card1881*/1882Then(/^I must be able to see the options present in the "([^"]*)"$/, async (object) => {1883 try {1884 switch (platform) {1885 case 'Android':1886 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1887 console.log(`${object} screen is displayed`);1888 ////browser.saveScreenshot();1889 break;1890 case 'ios':1891 const selectiosprop = fileutils.readPropertyFile(platform, object);1892 const selectlist = browser.elements(selectiosprop).getText();1893 console.log('Select Comparison View List:');1894 for (let i = 0; i < selectlist.length; i += 1) {1895 console.log(`${selectlist[i]} `);1896 }1897 break;1898 case 'Web':1899 // web operation1900 break;1901 default: break1902 }1903 } catch (e) {1904 console.error(`${object} `, ' screen is not displayed');1905 //browser.saveScreenshot();1906 return assert.strictEqual(platform, '', e);1907 }1908});1909/*1910Then statement to verify the days logged for each migraine card1911*/1912Then(/^I must verify for migraine attack dates displayed after selecting the "([^"]*)"$/, async (object) => {1913 try {1914 switch (platform) {1915 case 'Android':1916 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1917 console.log(`${object} screen is displayed`);1918 ////browser.saveScreenshot();1919 break;1920 case 'ios':1921 const reportcomparison = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();1922 console.log(`-- - ${reportcomparison}: `, '---');1923 const prioriosprop = fileutils.readPropertyFile(platform, 'Report.Days.Last');1924 const priortext = browser.element(prioriosprop);1925 if (priortext.isVisible()) {1926 const priortextstr = priortext.getText();1927 const priordate = browser.element(`${fileutils.readPropertyFile(platform, 'Report.Days.Last.Date')} `).getText();1928 console.log(`${priortextstr}: `, ` ${priordate} `);1929 } else {1930 console.log(`${priortext} `, 'is not visible');1931 }1932 const lateriosprop = fileutils.readPropertyFile(platform, 'Report.Days.Prior');1933 const latertext = browser.element(lateriosprop);1934 if (latertext.isVisible()) {1935 const latertextstr = latertext.getText();1936 const laterdate = browser.element(`${fileutils.readPropertyFile(platform, 'Report.Days.Prior.Date')} `).getText();1937 console.log(`${latertextstr}: ${laterdate} `);1938 } else {1939 console.log(`${latertext} `, 'is not visible');1940 }1941 break1942 case 'Web':1943 // web operation1944 break;1945 default: break1946 }1947 } catch (e) {1948 console.error(`${object} `, ' screen is not displayed');1949 //browser.saveScreenshot();1950 return assert.strictEqual(platform, '', e);1951 }1952});1953/*1954Then statement to swipe to the next card1955*/1956Then(/^I swipe up to the next card$/, async () => {1957 browser.execute('mobile:swipe', { direction: 'up', toX: 1, toY: 1 });1958});1959/*1960Then statement to display the migraine attacks for each card1961*/1962Then(/^I must be able to see the migraine attacks logged in "([^"]*)" card$/, async (object) => {1963 try {1964 let medicationtaken1965 switch (platform) {1966 case 'Android':1967 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');1968 console.log(`${object} screen is displayed`);1969 ////browser.saveScreenshot();1970 break;1971 case 'ios':1972 const lastdays = $(fileutils.readPropertyFile(platform, 'Report.Days.Last')).getText();1973 const priordays = $(fileutils.readPropertyFile(platform, 'Report.Days.Prior')).getText();1974 if (object === 'Report.Migraine.Days') {1975 const migrainedaystext = $(fileutils.readPropertyFile(platform, 'Report.Migraine.Days')).getText();1976 console.log(`-- - ${migrainedaystext} --- `);1977 const lastdaysformigraine = $(fileutils.readPropertyFile(platform, 'Report.Migraine.Days.Last.Event'));1978 const priordaysformigraine = $(fileutils.readPropertyFile(platform, 'Report.Migraine.Days.Prior.Event'));1979 if (lastdaysformigraine.isVisible() && priordaysformigraine.isVisible()) {1980 const lastdaysformigrainetext = $(fileutils.readPropertyFile(platform, 'Report.Migraine.Days.Last.Event')).getText();1981 const priordaysformigrainetext = $(fileutils.readPropertyFile(platform, 'Report.Migraine.Days.Prior.Event')).getText();1982 console.log(`${lastdays}: ${lastdaysformigrainetext} `);1983 console.log(`${priordays}: ${priordaysformigrainetext} `);1984 }1985 ////browser.saveScreenshot();1986 } else if (object === 'Report.Number.of.days.Moderate.to.Severe.Pain') {1987 const moderateseverepaintext = $(fileutils.readPropertyFile(platform, 'Report.Number.of.days.Moderate.to.Severe.Pain')).getText();1988 console.log(`-- - ${moderateseverepaintext} --- `);1989 const moderatepaindayslater = browser.element('(//XCUIElementTypeStaticText[@name="report_lastEvent_text"])[2]').getText();1990 const severepaindayslater = browser.element('(//XCUIElementTypeStaticText[@name="report_lastEvent_text"])[3]').getText();1991 const moderatepaindaysprior = browser.element('(//XCUIElementTypeStaticText[@name="report_priorEvent_text"])[2]').getText();1992 const severepaindaysprior = browser.element('(//XCUIElementTypeStaticText[@name="report_priorEvent_text"])[3]').getText();1993 console.log(`${'Moderate attacks for '} ${lastdays}: ${moderatepaindayslater} `);1994 console.log(`${'Severe attacks for '} ${lastdays}: ${severepaindayslater} `);1995 console.log(`${'Moderate attacks for '} ${priordays} : ${moderatepaindaysprior} `);1996 console.log(`${'Severe attacks for '} ${priordays} : ${severepaindaysprior} `);1997 ////browser.saveScreenshot();1998 } else if (object === 'Report.Number.of.days.Moderate.to.Severe.Impact') {1999 const moderatesevereimpacttext = $(fileutils.readPropertyFile(platform, 'Report.Number.of.days.Moderate.to.Severe.Impact')).getText();2000 console.log(`-- - ${moderatesevereimpacttext} --- `);2001 const moderateimpactdayslater = browser.element('(//XCUIElementTypeStaticText[@name="report_lastEvent_text"])[4]').getText();2002 const severeimpactdayslater = browser.element('(//XCUIElementTypeStaticText[@name="report_lastEvent_text"])[5]').getText();2003 const moderateimpactdaysprior = browser.element('(//XCUIElementTypeStaticText[@name="report_priorEvent_text"])[4]').getText();2004 const severeimpactdaysprior = browser.element('(//XCUIElementTypeStaticText[@name="report_priorEvent_text"])[5]').getText();2005 console.log(`${'Moderate attacks for '} ${lastdays}: ${moderateimpactdayslater} `);2006 console.log(`${'Severe attacks for '} ${lastdays}: ${severeimpactdayslater} `);2007 console.log(`${'Moderate attacks for '} ${priordays} : ${moderateimpactdaysprior} `);2008 console.log(`${'Severe attacks for '} ${priordays} : ${severeimpactdaysprior} `);2009 ////browser.saveScreenshot();2010 } else if (object === 'Report.Number.of.Medication.Taken') {2011 const medxpath = fileutils.readPropertyFile(platform, 'Report.Preventative.Acute.Medication');2012 const medlater = browser.elements('//XCUIElementTypeOther[@name="report_medication_headerText"]/preceding-sibling::XCUIElementTypeStaticText[1]').getText();2013 const medprior = browser.elements('//XCUIElementTypeOther[@name="report_medication_headerText"]/preceding-sibling::XCUIElementTypeStaticText[2]').getText();2014 medicationtaken = browser.elements(`~${medxpath} `).getText();2015 console.log(`${lastdays} `, 'details:');2016 for (let i = 0; i < medicationtaken.length; i += 1) {2017 console.log(`${medicationtaken[i]}: ${medlater[i]} `);2018 }2019 console.log(`${priordays} `, 'details:');2020 for (let i = 0; i < medicationtaken.length; i += 1) {2021 console.log(`${medicationtaken[i]}: ${medprior[i]} `);2022 }2023 ////browser.saveScreenshot();2024 }2025 break2026 case 'Web':2027 // web operation2028 break;2029 default: break2030 }2031 } catch (e) {2032 console.error(`${object} screen is not displayed`);2033 //browser.saveScreenshot();2034 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2035 }2036});2037/*2038Then statement to verify the days match with the tab selected2039*/2040Then(/^I must verify the dates displayed is as per the "([^"]*)" tab selected$/, { timeout: 60 * 1000 }, async (object) => {2041 try {2042 switch (platform) {2043 case 'Android':2044 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2045 console.log(`${object} screen is displayed`);2046 ////browser.saveScreenshot();2047 break;2048 case 'ios':2049 if (object === '30.Days') {2050 const firsttabtext = $(fileutils.readPropertyFile(platform, object)).getText();2051 const Migraineattacktimeperiod = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();2052 const thirtydayslessthancurrentdate = moment().subtract(30, 'days').format('DD MMM YYYY');2053 const currentdate = moment().format('DD MMM YYYY');2054 const Migraineattackdateadd = `${thirtydayslessthancurrentdate} - ${currentdate} `;2055 if (Migraineattacktimeperiod === Migraineattackdateadd) {2056 console.log('Days are matching with the tab selected');2057 console.log(`${firsttabtext} - ${Migraineattacktimeperiod} `);2058 } else {2059 console.log(`${firsttabtext} `, 'is not selected');2060 }2061 } else if (object === '90.Days') {2062 const secondtabtext = $(fileutils.readPropertyFile(platform, object)).getText();2063 const Migraineattacktimeperiod = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();2064 const ninetydayslessthancurrentdate = moment().subtract(90, 'days').format('DD MMM YYYY');2065 const currentdate = moment().format('DD MMM YYYY');2066 const Migraineattackdateadd = `${ninetydayslessthancurrentdate} - ${currentdate} `;2067 if (Migraineattacktimeperiod === Migraineattackdateadd) {2068 console.log('Days are matching with the tab selected');2069 console.log(`${secondtabtext}: `, ` ${Migraineattacktimeperiod} `);2070 } else {2071 console.log(`${secondtabtext} `, 'is not selected');2072 }2073 } else if (object === '6.Months') {2074 const thirdtabtext = $(fileutils.readPropertyFile(platform, object)).getText();2075 const Migraineattacktimeperiod = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();2076 const sixmonthslessthancurrentdate = moment().subtract(6, 'months').format('DD MMM YYYY');2077 const currentdate = moment().format('DD MMM YYYY');2078 const Migraineattackdateadd = `${sixmonthslessthancurrentdate} - ${currentdate} `;2079 if (Migraineattacktimeperiod === Migraineattackdateadd) {2080 console.log('Days are matching with the tab selected');2081 console.log(`${thirdtabtext} - ${Migraineattacktimeperiod} `);2082 } else {2083 console.log(`${thirdtabtext} `, 'is not selected');2084 }2085 } else if (object === '12.Months') {2086 const fourthtabtext = $(fileutils.readPropertyFile(platform, object)).getText();2087 const Migraineattacktimeperiod = $(fileutils.readPropertyFile(platform, 'Migraine.Attack.Period')).getText();2088 const twelvemonthslessthancurrentdate = moment().subtract(12, 'months').format('DD MMM YYYY');2089 const currentdate = moment().format('DD MMM YYYY');2090 const Migraineattackdateadd = `${twelvemonthslessthancurrentdate} -${currentdate} `;2091 if (Migraineattacktimeperiod === Migraineattackdateadd) {2092 console.log('Days are matching with the tab selected');2093 console.log(`${fourthtabtext}: `, ` ${Migraineattacktimeperiod} `);2094 } else {2095 console.log(`${fourthtabtext} `, 'is not selected');2096 }2097 }2098 break2099 case 'Web':2100 // web operation2101 break;2102 default: break2103 }2104 } catch (e) {2105 console.error(`${object} screen is not displayed`);2106 //browser.saveScreenshot();2107 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2108 }2109});2110/*2111Then statement to verify for medication icon present for the current date2112*/2113Then(/^I should be able to see the medication icon for the current date$/, async () => {2114 try {2115 switch (platform) {2116 case 'android':2117 break;2118 case 'ios':2119 const dateobj = new Date();2120 const systemdate = dateobj.getDate();2121 const medicationdotcheck = $(fileutils.readPropertyFile(platform, 'Quick.Entry.Current.Date.Icon'));2122 const currentdateincalendar = $(fileutils.readPropertyFile(platform, 'CalendarCurrentDate')).getText();2123 if (currentdateincalendar.includes(systemdate) && medicationdotcheck.isEnabled()) {2124 console.log(`${'Medication Icon is present for the current date: '} ${currentdateincalendar} `);2125 } else {2126 console.log(`${'Medication Icon is missing for the current date: '} ${currentdateincalendar} `);2127 }2128 break;2129 case 'web':2130 // web operation2131 break;2132 default: break2133 }2134 } catch (e) {2135 console.error('Screen is not displayed');2136 //browser.saveScreenshot();2137 return assert.strictEqual(platform, 'ios', 'Medication Icon is missing for the current date');2138 }2139});2140Then(/^I click on "([^"]*)"$/, async (object) => {2141 try {2142 switch (platform) {2143 case 'android':2144 const check = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2145 if (check) {2146 console.log(`${object} screen is displayed`);2147 ////browser.saveScreenshot();2148 }2149 break;2150 case 'ios':2151 const medlabel = $(fileutils.readPropertyFile(platform, 'Medication.Icon.Label'));2152 if (medlabel.isEnabled()) {2153 const medlabeltext = medlabel.getText();2154 console.log(`${'Clicking on '} ${medlabeltext} `);2155 $(fileutils.readPropertyFile(platform, object)).click();2156 } else {2157 console.log(`${'Unable to find the '} ${medlabel} `);2158 }2159 break;2160 case 'web':2161 // web operation2162 break;2163 default: break;2164 }2165 } catch (e) {2166 console.error(`${object} is not displayed`);2167 //browser.saveScreenshot();2168 return assert.strictEqual(platform, '', e);2169 }2170});2171/*2172 Then statement to verify for the migraine header with config data2173*/2174Then(/^I should verify "([^"]*)" matches in "([^"]*)" screen$/, async (object, screen) => {2175 try {2176 switch (platform) {2177 case 'android':2178 // android here---2179 break;2180 case 'ios':2181 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2182 if (exists) {2183 const textFromConfig = appconfig.verifyTextFromConfig(screen);2184 const migraineheadertext = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2185 if (textFromConfig === migraineheadertext) {2186 console.log('Migraine Header text matches');2187 console.log(`${'App: '} ${migraineheadertext} `);2188 console.log(`${'Config: '} ${textFromConfig} `);2189 } else {2190 console.log("Text doesn't match");2191 console.log(`${'App: '} ${migraineheadertext} `);2192 console.log(`${'Config: '} ${textFromConfig} `);2193 }2194 ////browser.saveScreenshot();2195 break;2196 }2197 break2198 case 'web':2199 // web operation2200 break;2201 default: break2202 }2203 } catch (e) {2204 console.error(`${object} screen is not displayed`);2205 //browser.saveScreenshot();2206 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2207 }2208});2209/*2210 Then statement to verify for the migraine header with config data2211*/2212Then(/^I should verify that medication is added for the current day and date under "([^"]*)" label$/, async (object) => {2213 try {2214 switch (platform) {2215 case 'android':2216 // android here---2217 break;2218 case 'ios':2219 const medcurrentdate = browser.element(`${fileutils.readPropertyFile(platform, 'Medication.Current.Date')} `).getText();2220 const datefromsystem = moment().format('ddd D MMM YY');2221 if (medcurrentdate === datefromsystem) {2222 console.log(`-- - ${object} --- `);2223 console.log(`${'Medication is being added for the current date: '} ${medcurrentdate} `);2224 } else {2225 console.log(`${'Medication is being added for a different date: '} ${medcurrentdate} `);2226 console.log(`${'Date displayed in app: '} ${medcurrentdate} `);2227 console.log(`${'System date: '} ${datefromsystem} `);2228 }2229 break2230 case 'web':2231 // web operation2232 break;2233 default: break2234 }2235 } catch (e) {2236 console.error(`${object} screen is not displayed`);2237 //browser.saveScreenshot();2238 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2239 }2240});2241/*2242 Then statement to verify for the medication time added2243*/2244Then(/^I should see the "([^"]*)" added$/, async (object) => {2245 try {2246 switch (platform) {2247 case 'android':2248 // android here---2249 break;2250 case 'ios':2251 const meddate = browser.element(`${fileutils.readPropertyFile(platform, 'Medication.Current.Date')} `).getText();2252 const medtime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2253 console.log(`${'Medication Date: '} ${meddate} `);2254 console.log(`${'Medication Time: '} ${medtime} `);2255 break;2256 case 'web':2257 // web operation2258 break;2259 default: break2260 }2261 } catch (e) {2262 console.error(`${object} screen is not displayed`);2263 //browser.saveScreenshot();2264 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2265 }2266});2267/*2268 Then statement to verify the alert description for time chosen from the pickerwheel2269*/2270Then(/^I must see the "([^"]*)" with the new time chosen from pickerwheel$/, async (object) => {2271 try {2272 switch (platform) {2273 case 'android':2274 // android here---2275 break;2276 case 'ios':2277 const alertdesctime = $(fileutils.readPropertyFile(platform, object)).getText();2278 const HourValue = Hour;2279 const MinuteValue = Minute;2280 const MeridienValue = TimeMeridien;2281 const timeadd = `0${HourValue}: ${MinuteValue} ${MeridienValue} `;2282 if (alertdesctime.includes(timeadd)) {2283 console.log(`${object} `, 'is displayed with the new time chosen from picker wheel');2284 console.log(`${'Alert Display: '} ${alertdesctime} `);2285 } else {2286 console.log('There is a difference in the time chosen and the alert displayed');2287 console.log(`${'Alert displayed: '} ${alertdesctime} `);2288 }2289 ////browser.saveScreenshot();2290 break2291 case 'web':2292 // web operation2293 break;2294 default: break2295 }2296 } catch (e) {2297 console.error(`${object} is not displayed`);2298 //browser.saveScreenshot();2299 return assert.strictEqual(platform, '', e);2300 }2301});2302/*2303 Then statement to display the new time added2304*/2305Then(/^I should see the new time displayed in the "([^"]*)"$/, async (object) => {2306 try {2307 switch (platform) {2308 case 'android':2309 // android here---2310 break;2311 case 'ios':2312 const medtime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2313 let HourValue = Hour;2314 const MinuteValue = Minute;2315 const MeridienValue = TimeMeridien;2316 if (HourValue >= 10) {2317 HourValue = `${HourValue} `2318 }2319 const Timeadd = `${HourValue}: ${MinuteValue} ${MeridienValue} `;2320 if (medtime === Timeadd) {2321 console.log(`${'New time chosen: '} ${medtime} `);2322 } else {2323 console.log('Time is not displayed');2324 }2325 break2326 case 'web':2327 // web operation2328 break;2329 default: break2330 }2331 } catch (e) {2332 console.error(`${object} is not displayed`);2333 //browser.saveScreenshot();2334 return assert.strictEqual(platform, '', e);2335 }2336});2337/*2338 Then statement to see medication icon in the previous screen2339*/2340Then(/^I should see "([^"]*)" in the previous screen$/, async (object) => {2341 try {2342 switch (platform) {2343 case 'android':2344 // android here---2345 break;2346 case 'ios':2347 const medicon = $(fileutils.readPropertyFile(platform, object));2348 if (medicon.isEnabled()) {2349 const medlabel = $(fileutils.readPropertyFile(platform, 'Medication.Icon.Label')).getText();2350 console.log(`${object} `, 'is present in the screen with label:', ` ${medlabel} `);2351 } else {2352 console.log(`${object} `, 'is not present in the screen');2353 }2354 break2355 case 'web':2356 // web operation2357 break;2358 default: break2359 }2360 } catch (e) {2361 console.error(`${object} screen is not displayed`);2362 //browser.saveScreenshot();2363 return assert.strictEqual(platform, '', e);2364 }2365});2366/*2367 Then statement to see that time is displayed as 12 am by default if2368 no medication is selected for the current day2369*/2370Then(/^I should verify that "([^"]*)" has 12:00 am as default if no medication is selected for the current day$/, async (object) => {2371 try {2372 switch (platform) {2373 case 'android':2374 // android here---2375 break;2376 case 'ios':2377 const medtime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2378 const time = '12:00 am';2379 if (medtime === time) {2380 console.log(`${'Default time is displayed: '} ${medtime} `);2381 } else {2382 console.log(`${'Different time is displayed: '} ${medtime} `);2383 }2384 break2385 case 'web':2386 // web operation2387 break;2388 default: break2389 }2390 } catch (e) {2391 console.error(`${object} screen is not displayed`);2392 //browser.saveScreenshot();2393 return assert.strictEqual(platform, '', e);2394 }2395});2396/*2397 Then statement to tap on back button to go home page2398*/2399Then(/^I tap "([^"]*)" button to go to home page$/, async (object) => {2400 try {2401 switch (platform) {2402 case 'android':2403 // android here---2404 break;2405 case 'ios':2406 const backbutton = $(fileutils.readPropertyFile(platform, object));2407 if (backbutton.isEnabled()) {2408 backbutton.click();2409 } else {2410 console.log('Unable to click on back button');2411 }2412 break2413 case 'web':2414 // web operation2415 break;2416 default: break2417 }2418 } catch (e) {2419 console.error(`${object} screen is not displayed`);2420 //browser.saveScreenshot();2421 return assert.strictEqual(platform, '', e);2422 }2423});2424/*2425 Checks objects Names: Accounts , Notifications2426 and Version from Settings compares from appconfig2427*/2428Then(/^I should verify "([^"]*)" in "([^"]*)" screen$/, async (object, screen) => {2429 try {2430 switch (platform) {2431 case 'android':2432 // android here---2433 break;2434 case 'ios':2435 const setmenu = fileutils.readPropertyFile(platform, object);2436 const settingmenutext = browser.elements(setmenu).getText();2437 const textfromconfig = appconfig.verifyTextFromConfig(screen);2438 const versioncheck = settingmenutext[2];2439 if (textfromconfig[0] === settingmenutext[0]2440 && textfromconfig[1] === settingmenutext[1] && versioncheck.includes(textfromconfig[2])) {2441 console.log('============Values Match============');2442 console.log(`Value from Config: ${textfromconfig[0]}| `, `Value from Application: ${settingmenutext[0]} `);2443 console.log(`Value from Config: ${textfromconfig[1]}| `, `Value from Application: ${settingmenutext[1]} `);2444 console.log(`Value from Config: ${textfromconfig[2]}| `, `Value from Application: ${settingmenutext[2]} `);2445 break;2446 } else {2447 console.log("============Values Don't Match============");2448 console.log(`Value from Config: ${textfromconfig[0]}| `, ` Value from Application: ${settingmenutext[0]} `);2449 console.log(`Value from Config: ${textfromconfig[1]}| `, ` Value from Application: ${settingmenutext[1]} `);2450 console.log(`Value from Config: ${textfromconfig[2]}| `, ` Value from Application: ${settingmenutext[2]} `);2451 }2452 const button = $(fileutils.readPropertyFile(platform, object));2453 if (button.isEnabled()) {2454 console.log(`${'Clicking on '} ${object} `);2455 button.click();2456 }2457 break2458 case 'web':2459 // web operation2460 break;2461 default: break;2462 }2463 } catch (e) {2464 console.error(`${object} screen is not displayed`);2465 //browser.saveScreenshot();2466 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2467 }2468});2469/*2470 Checks Terms And Condtions And Privacy Policy Options are above Logout in HamburgerMenu2471*/2472Then(/^I should verify "([^"]*)" are above Logout in "([^"]*)"$/, async (screen, object) => {2473 try {2474 switch (platform) {2475 case 'android':2476 // android here---2477 break;2478 case 'ios':2479 const textfromconfig = appconfig.verifyTextFromConfig(screen);2480 const xpathFromIosProp = fileutils.readPropertyFile(platform, object);2481 const HamburgerMenuOptions = browser.elements(xpathFromIosProp).getText();2482 console.log(`All Hamburger Menu Options: ${HamburgerMenuOptions} `);2483 for (let i = HamburgerMenuOptions.length; i > 0; i -= 1) {2484 const xpath = `${xpathFromIosProp} [${String(i)}]`;2485 const text = browser.elements(xpath).getText();2486 if (text === textfromconfig[8]) {2487 const xpathOfMenu1 = `${xpathFromIosProp} [${String(i - 1)}]`;2488 const xpathOfMenu2 = `${xpathFromIosProp} [${String(i - 2)}]`;2489 if (browser.elements(xpathOfMenu1).getText() === textfromconfig[7] && browser2490 .elements(xpathOfMenu2).getText() === textfromconfig[6]) {2491 console.log('Terms And Condtions & Privacy Policy options are above Logout in HamburgerMenu');2492 break;2493 } else {2494 console.log('Terms And Condtions & Privacy Policy options not found above Logout in HamburgerMenu');2495 break;2496 }2497 }2498 }2499 break;2500 default: break2501 }2502 } catch (e) {2503 console.error(`${object} screen is not displayed`);2504 //browser.saveScreenshot();2505 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2506 }2507});2508/*2509 Then statement to tap on back button to go home page2510*/2511Then(/^I tap on "([^"]*)"$/, async (object) => {2512 try {2513 switch (platform) {2514 case 'android':2515 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2516 if (exists) {2517 browser.element(`${fileutils.readPropertyFile(platform, object)}`).click()2518 console.log(`Clicked on ${object}`);2519 ////browser.saveScreenshot();2520 }2521 break;2522 case 'ios':2523 const xpath = fileutils.readPropertyFile(platform, object);2524 const exists1 = browser.waitUntil(() => {2525 const xpathcheck = fileutils.readPropertyFile(platform, object);2526 if (xpathcheck.startsWith('/') || xpathcheck.startsWith('//')) {2527 return $(fileutils.readPropertyFile(platform, object)).isVisible();2528 }2529 return browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible();2530 }, timeOutinMs, 'Error: Element not found');2531 if (exists1) {2532 if (xpath.startsWith('/') || xpath.startsWith('//')) {2533 const buttonxpath = $(`${xpath}`)2534 if (buttonxpath.isEnabled()) {2535 console.log(`${'Clicking on '} ${object} `);2536 buttonxpath.click();2537 }2538 } else {2539 const buttonid = browser.element(`${xpath}`)2540 if (buttonid.isEnabled()) {2541 console.log(`${'Clicking on '} ${object} `);2542 buttonid.click();2543 }2544 }2545 }2546 browser.saveScreenshot()2547 break2548 case 'web':2549 // web operation2550 break;2551 default: break2552 }2553 } catch (e) {2554 console.error(`${object} is not displayed`);2555 //browser.saveScreenshot();2556 return assert.strictEqual(platform, '', e);2557 }2558});2559Then(/^I tap on "([^"]*)" (?:button|label|card|link|icon|option|field|mark|screen)$/, async (object) => {2560 try {2561 switch (platform) {2562 case 'android':2563 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2564 if (exists) {2565 browser.element(`${fileutils.readPropertyFile(platform, object)}`).click()2566 console.log(`Clicked on ${object}`);2567 ////browser.saveScreenshot();2568 }2569 break;2570 case 'ios':2571 const xpath = fileutils.readPropertyFile(platform, object);2572 const exists1 = browser.waitUntil(() => {2573 const xpathcheck = fileutils.readPropertyFile(platform, object);2574 if (xpathcheck.startsWith('/') || xpathcheck.startsWith('//')) {2575 return $(fileutils.readPropertyFile(platform, object)).isVisible();2576 }2577 return browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible();2578 }, timeOutinMs, 'Error: Element not found');2579 if (exists1) {2580 if (xpath.startsWith('/') || xpath.startsWith('//')) {2581 const buttonxpath = $(`${xpath}`)2582 if (buttonxpath.isEnabled()) {2583 console.log(`${'Clicking on '} ${object} `);2584 buttonxpath.click();2585 }2586 }2587 else if (object == "ChangeName.Logout") {2588 const buttonxpath = browser.element("~Change Name & Logout");2589 if (buttonxpath.isEnabled()) {2590 console.log(`${'Clicking on '} ${object} `);2591 buttonxpath.click();2592 }2593 }2594 else if (object == "Continue.with.this.device") {2595 const buttonxpath = browser.element("~ Continue with this device ");2596 if (buttonxpath.isEnabled()) {2597 console.log(`${'Clicking on '} ${object} `);2598 buttonxpath.click();2599 }2600 }2601 else {2602 const buttonid = browser.element(`${xpath}`)2603 if (buttonid.isEnabled()) {2604 console.log(`${'Clicking on '} ${object} `);2605 buttonid.click();2606 }2607 }2608 }2609 //browser.saveScreenshot()2610 break2611 case 'web':2612 // web operation2613 break;2614 default: break2615 }2616 } catch (e) {2617 console.error(`${object} is not displayed`);2618 //browser.saveScreenshot();2619 return assert.strictEqual(platform, '', e);2620 }2621});2622Then(/^I should see the corresponding impact description$/, async () => {2623 try {2624 switch (platform) {2625 case 'android':2626 // perform operation on android element2627 break;2628 case 'ios':2629 const textFromConfig = appconfig.verifyTextFromConfig('ImpairmentScaleValue');2630 for (let i = 0; i < textFromConfig.length; i += 1) {2631 if (textFromConfig[i] === browser.element('~editimpact_descriptiontext_view').getText()) {2632 console.log('Actual and expected match \n Actual :',2633 browser.element('~editimpact_descriptiontext_view').getText(), '\n Expected:', `${textFromConfig[i]}`);2634 ////browser.saveScreenshot();2635 break;2636 }2637 }2638 break;2639 case 'web':2640 // web code----2641 break;2642 default: break2643 }2644 } catch (e) {2645 console.error(`\n Cannot read the impact level ${e} `);2646 //browser.saveScreenshot();2647 return assert.strictEqual(platform, 'ios', '\n Cannot read the impact level ');2648 }2649});2650Then(/^I should see the corresponding impact level$/, async () => {2651 try {2652 switch (platform) {2653 case 'android':2654 // perform operation on android element2655 break;2656 case 'ios':2657 const textFromConfig = appconfig.verifyTextFromConfig('ImpairmentScale');2658 for (let i = 0; i < textFromConfig.length; i += 1) {2659 if (textFromConfig[i] === browser.element('~editimpact_impact_text').getText()) {2660 console.log(`Actual and expected levels match \n Actual : ${browser.element('~editimpact_impact_text').getText()} \n Expected: ${textFromConfig[i]}`);2661 console.log(`Impact Value: ${browser.element('~editimpact_impact_value').getText()} \n`);2662 ////browser.saveScreenshot();2663 break;2664 }2665 }2666 break2667 case 'web':2668 // web code----2669 break;2670 default: break2671 }2672 } catch (e) {2673 console.error(`\n Cannot read the impact level ${e} `);2674 //browser.saveScreenshot();2675 return assert.strictEqual(platform, 'ios', '\n Cannot read the impact level ');2676 }2677});2678Then(/^I should see the corresponding intensity level$/, async () => {2679 try {2680 switch (platform) {2681 case 'android':2682 // perform operation on android element2683 break;2684 case 'ios':2685 const textFromConfig = appconfig.verifyTextFromConfig('IntensityScale');2686 for (let i = 0; i < textFromConfig.length; i += 1) {2687 if (textFromConfig[i] === browser.element('~editintensity_intensity_type').getText()) {2688 console.log(`Actual and expected levels match \n Actual : ${browser.element('~editintensity_intensity_type').getText()} \n Expected: ${textFromConfig[i]}`);2689 ////browser.saveScreenshot();2690 break;2691 }2692 }2693 break;2694 case 'web':2695 // web code----2696 break;2697 default: break2698 }2699 } catch (e) {2700 console.error(`\n Cannot read the intensity level ${e} `);2701 //browser.saveScreenshot();2702 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');2703 }2704});2705/*2706 Then statment to verify that header matches with config data2707*/2708Then(/^I should verify "([^"]*)" header text matches with "([^"]*)" screen$/, async (object, screen) => {2709 try {2710 switch (platform) {2711 case 'android':2712 // android here---2713 break;2714 case 'ios':2715 const navtitle = browser.element(`${fileutils.readPropertyFile(platform, object)}`);2716 if (navtitle.isEnabled()) {2717 const navtext = navtitle.getText();2718 const textfromconfig = appconfig.verifyTextFromConfig(screen);2719 console.log(textfromconfig)2720 for (let i = 0; i < textfromconfig.length; i += 1) {2721 if (textfromconfig[i] === navtext) {2722 console.log('----Navigation title matches----');2723 console.log(`App: ${navtext}`);2724 console.log(`Config: ${textfromconfig[i]}`);2725 break;2726 }2727 }2728 }2729 break;2730 default: break2731 }2732 } catch (e) {2733 console.error(`${object} values from application and appconfig do not match`);2734 //browser.saveScreenshot();2735 return assert.strictEqual(platform, 'ios', `${object} values from application and appconfig do not match`);2736 }2737});2738Then(/^I should see "([^"]*)" in the screen$/, async (object) => {2739 try {2740 switch (platform) {2741 case 'Android':2742 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2743 console.log(`${object} screen is displayed`);2744 ////browser.saveScreenshot();2745 break;2746 case 'ios':2747 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object)).isVisible(), timeOutinMs, 'Element not found');2748 if (exists) {2749 console.log(`${object} screen is displayed`);2750 const textmessage = $(fileutils.readPropertyFile(platform, object)).getText();2751 console.log(`${'Validation Message/Text Display: '} ${textmessage} `);2752 ////browser.saveScreenshot();2753 break;2754 }2755 break;2756 case 'Web':2757 // web operation2758 break;2759 default: break;2760 }2761 } catch (e) {2762 console.error(`${object} screen is not displayed`);2763 //browser.saveScreenshot();2764 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2765 }2766});2767Then(/^I switch back to app$/, async () => {2768 try {2769 browser.execute('mobile: launchApp', { bundleId: bundleid });2770 ////browser.saveScreenshot();2771 } catch (e) {2772 console.error('Cannot Switch Back to App ', e);2773 }2774});2775/*2776 Then statment to drag from one point to another for carousal2777*/2778Then(/^I should swipe left in the "([^"]*)"$/, async (object) => {2779 try {2780 switch (platform) {2781 case 'android':2782 // android here---2783 break;2784 case 'ios':2785 if (object === 'Summary.of.Intensity.Calendar.Carousel' || object === 'Summary.of.Impact.Calendar.Carousel') {2786 console.log('Swiping left in the ', `${object} `);2787 const xcoordinate = $(fileutils.readPropertyFile(platform, 'Summary.of.Intensity.Impact.Moderate')).getLocation('x');2788 const ycoordinate = $(fileutils.readPropertyFile(platform, 'Summary.of.Intensity.Impact.Moderate')).getLocation('y');2789 browser.execute('mobile:dragFromToForDuration', {2790 duration: 5, fromX: xcoordinate, fromY: ycoordinate, toX: 30, toY: 30,2791 });2792 browser.pause(7000);2793 } else {2794 console.log('Swiping left in the', `${object} `);2795 const xcoordinateforcurrentlevel = browser.element("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getLocation('x');2796 const ycoordinateforcurrentlevel = browser.element("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getLocation('y');2797 browser.execute('mobile:dragFromToForDuration', {2798 duration: 5,2799 fromX: xcoordinateforcurrentlevel,2800 fromY: ycoordinateforcurrentlevel,2801 toX: 30,2802 toY: 30,2803 });2804 }2805 break;2806 default: break;2807 }2808 } catch (e) {2809 console.error(`${object} is not displayed`);2810 //browser.saveScreenshot();2811 return assert.strictEqual(platform, '', e);2812 }2813});2814/*2815 Then statment to capture the attack heading and attack time2816*/2817Then(/^I should be able to see the "([^"]*)" attack header and days recorded$/, async (object) => {2818 try {2819 switch (platform) {2820 case 'android':2821 // android here---2822 break;2823 case 'ios':2824 console.log(`${'---Displaying the '} ${object} `, 'attack header and days recorded---');2825 if (object === 'Calendar.Migraine.Days') {2826 const calmigrainetext = $(fileutils.readPropertyFile(platform, object)).getText();2827 const calmigraineattacktext = browser.element(`${fileutils.readPropertyFile(platform, 'Number.of.Attack.Days.Recorded')} `).getText();2828 ////browser.saveScreenshot();2829 console.log(`${calmigrainetext}: `, ` ${calmigraineattacktext} `);2830 } else if (object === 'Calendar.Medication.Days') {2831 const calmedicationtext = $(fileutils.readPropertyFile(platform, object)).getText();2832 const calmedicationattacktext = browser.element(`${fileutils.readPropertyFile(platform, 'Number.of.Attack.Days.Recorded')} `).getText();2833 ////browser.saveScreenshot();2834 console.log(`${calmedicationtext}: `, ` ${calmedicationattacktext} `);2835 } else if (object === 'Calendar.Summary.of.Intensity') {2836 const sumofintensitylevel = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_level']").getText();2837 const sumofintensityattackdays = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getText();2838 ////browser.saveScreenshot();2839 for (let i = 0; i < sumofintensitylevel.length; i += 1) {2840 console.log(`${sumofintensitylevel[i]}: `, ` ${sumofintensityattackdays[i]} `);2841 }2842 } else if (object === 'Calendar.Summary.of.Impact') {2843 const sumofimpactlevel = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_level']").getText();2844 const sumofimpactattackdays = browser.elements("//XCUIElementTypeStaticText[@name='migraine_attack_time']").getText();2845 ////browser.saveScreenshot();2846 for (let i = 0; i < sumofimpactlevel.length; i += 1) {2847 console.log(`${sumofimpactlevel[i]}: `, ` ${sumofimpactattackdays[i]} `);2848 }2849 }2850 break;2851 default: break;2852 }2853 } catch (e) {2854 console.error(`${object} screen is not displayed`);2855 //browser.saveScreenshot();2856 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2857 }2858});2859Then(/^I verify "([^"]*)" label in Day Details screen for three consecutive days$/, async (object) => {2860 try {2861 switch (platform) {2862 case 'android':2863 // android here---2864 break;2865 case 'ios':2866 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2867 if (exists) {2868 const TodayLabel = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2869 if (TodayLabel === 'Today') {2870 console.log(`${TodayLabel}: Label found in Day Detail screen`);2871 } else {2872 console.log(`${TodayLabel}: Label not found in Day Detail screen`);2873 break;2874 }2875 browser.element('~dateNavigator_previous_button').click();2876 const YesterdayLabel = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2877 if (YesterdayLabel === 'Yesterday') {2878 console.log(`${YesterdayLabel}: Label found in Day Detail screen`);2879 } else {2880 console.log(`${YesterdayLabel}: Label not found in Day Detail screen`);2881 break;2882 }2883 browser.element('~dateNavigator_previous_button').click();2884 const TheyBeforeLabel = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();2885 let startdate = moment();2886 startdate = startdate.subtract(2, 'days');2887 startdate = startdate.format('dddd, Do MMM');2888 if (TheyBeforeLabel === startdate) {2889 console.log(`${TheyBeforeLabel}: Label found in Day Detail screen`);2890 } else {2891 console.log(`${TheyBeforeLabel}: Label not found in Day Detail screen`);2892 break;2893 }2894 }2895 break;2896 default: break;2897 }2898 } catch (e) {2899 console.error('Unable to open the URL specified', e);2900 return assert.strictEqual(platform, '', e);2901 }2902});2903/*2904Then statement to capture the error message on screen for elements having Xpath.2905*/2906Then(/^I should see "([^"]*)" on screen$/, async (object) => {2907 try {2908 switch (platform) {2909 case 'android':2910 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2911 console.log(`${object} screen is displayed`);2912 ////browser.saveScreenshot();2913 break;2914 case 'ios':2915 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object)).isVisible(), timeOutinMs, 'Element not found');2916 if (exists) {2917 console.log(`${object} screen is displayed`);2918 const textmessage = $(fileutils.readPropertyFile(platform, object)).getText();2919 console.log(`${'Message displayed: '} ${textmessage} `);2920 ////browser.saveScreenshot();2921 break;2922 }2923 break;2924 case 'Web':2925 // web operation2926 break;2927 default: break;2928 }2929 } catch (e) {2930 console.error(`${object} screen is not displayed`);2931 //browser.saveScreenshot();2932 return assert.strictEqual(platform, '', e);2933 }2934});2935/*2936 Then statement to verify the incorrect username and password with config data2937 */2938Then(/^I should validate the "([^"]*)" with the "([^"]*)" of config screen$/, async (object, screen) => {2939 try {2940 switch (platform) {2941 case 'android':2942 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2943 console.log(`${object} screen is displayed`);2944 ////browser.saveScreenshot();2945 break;2946 case 'ios':2947 const verifyfromconfig = appconfig.verifyTextFromConfig(screen);2948 const verifyfromscreen = $(fileutils.readPropertyFile(platform, object)).getText();2949 for (let i = 0; i < verifyfromconfig.length; i += 1) {2950 if (verifyfromconfig[i].includes(verifyfromscreen)) {2951 console.log('---Text from Screen matches with Text from Config---');2952 console.log(`Screen: ${verifyfromscreen} `);2953 console.log(`Config: ${verifyfromconfig[i]} `);2954 break;2955 }2956 }2957 break;2958 case 'Web':2959 // web operation2960 break;2961 default: break2962 }2963 } catch (e) {2964 console.error(`${object} screen is not displayed`);2965 //browser.saveScreenshot();2966 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);2967 }2968});2969/*2970 Then statement to verify the header/button/card present in the screen2971 */2972Then(/^I should see "([^"]*)" (?:button|header|card|text) in the screen$/, async (object) => {2973 try {2974 switch (platform) {2975 case 'android':2976 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');2977 console.log(object, 'screen is displayed');2978 ////browser.saveScreenshot();2979 break;2980 case 'ios':2981 const exists = browser.waitUntil(() => {2982 const xpathcheck = fileutils.readPropertyFile(platform, object)2983 if (xpathcheck.startsWith('/') || xpathcheck.startsWith('//')) {2984 return $(fileutils.readPropertyFile(platform, object)).isVisible();2985 }2986 return browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible();2987 }, timeOutinMs, 'Element not found');2988 if (exists) {2989 console.log(`${object} is displayed`);2990 const xpathvalue = fileutils.readPropertyFile(platform, object)2991 const cardvalue = browser.elements(`~${xpathvalue}`).getText()2992 for (let i = 0; i < cardvalue.length; i += 1) {2993 if (xpathvalue.startsWith('/') || xpathvalue.startsWith('//')) {2994 const textmessagewithxpath = $(fileutils.readPropertyFile(2995 platform, object,2996 )).getText();2997 if (cardvalue[i] === textmessagewithxpath) {2998 console.log(`Button or Header text displayed: ${textmessagewithxpath}`)2999 break;3000 }3001 } else {3002 const textmessagewithid = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText();3003 if (cardvalue[i] === textmessagewithid) {3004 console.log(`Button or Header text displayed: ${cardvalue[i]}`)3005 break;3006 }3007 }3008 }3009 ////browser.saveScreenshot();3010 }3011 break;3012 case 'web':3013 // web operation3014 break;3015 default: break3016 }3017 } catch (e) {3018 console.error(`${object} screen is not displayed`);3019 //browser.saveScreenshot();3020 return assert.strictEqual(platform, '', e);3021 }3022});3023/*3024 Then statement to compare data from screen with config file3025 */3026Then(/^I should verify "([^"]*)" (?:header|card) matches with "([^"]*)" of config$/, async (object, screen) => {3027 try {3028 switch (platform) {3029 case 'Android':3030 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');3031 console.log(`${object} screen is displayed`);3032 ////browser.saveScreenshot();3033 break;3034 case 'ios':3035 const textfromconfig = appconfig.verifyTextFromConfig(screen)3036 const xpathcheck = fileutils.readPropertyFile(platform, object)3037 if (xpathcheck.startsWith('/') || xpathcheck.startsWith('//')) {3038 const textfromscreenusingxpath = $(fileutils.readPropertyFile(platform, object)).getText()3039 if (screen === 'DayDetailsScreenText') {3040 if (textfromconfig === textfromscreenusingxpath) {3041 console.log('---Text matches---')3042 console.log(`App: ${textfromconfig}`)3043 console.log(`Screen: ${textfromscreenusingxpath}`)3044 }3045 } else if (screen === 'Describe.Impact.Pain.Migraine.Card') {3046 for (let i = 0; i < textfromconfig; i += 1) {3047 if (textfromconfig[i] === textfromscreenusingxpath) {3048 console.log('---Text matches---')3049 console.log(`App: ${textfromconfig}`)3050 console.log(`Screen: ${textfromscreenusingxpath}`)3051 }3052 }3053 }3054 } else {3055 const textfromscreenusingid = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText()3056 if (screen === 'DayDetailsScreenText') {3057 if (textfromconfig === textfromscreenusingid) {3058 console.log('---Text matches---')3059 console.log(`App: ${textfromconfig}`)3060 console.log(`Screen: ${textfromscreenusingid}`)3061 }3062 } else if (screen === 'Describe.Impact.Pain.Migraine.Card') {3063 for (let i = 0; i < textfromconfig; i += 1) {3064 if (textfromconfig[i] === textfromscreenusingid) {3065 console.log('---Text matches---')3066 console.log(`App: ${textfromconfig}`)3067 console.log(`Screen: ${textfromscreenusingid}`)3068 }3069 }3070 }3071 }3072 break;3073 case 'Web':3074 // web operation3075 break3076 default: break;3077 }3078 } catch (e) {3079 console.error(`${object} screen is not displayed`);3080 //browser.saveScreenshot();3081 return assert.strictEqual(platform, '', e);3082 }3083});3084/*3085 Then statement to verify if yesterday has been displayed3086 */3087Then(/^I should verify the header displayed as "([^"]*)"$/, async (object) => {3088 try {3089 switch (platform) {3090 case 'Android':3091 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');3092 console.log(`${object} screen is displayed`);3093 ////browser.saveScreenshot();3094 break;3095 case 'ios':3096 const day = browser.element(`${fileutils.readPropertyFile(platform, 'DayDetail.Day')}`)3097 if (day.isVisible()) {3098 const daytext = browser.element(`${fileutils.readPropertyFile(platform, 'DayDetail.Day')}`).getText()3099 if (daytext === 'Yesterday' || daytext === 'Today') {3100 console.log(`${daytext} is displayed after clicking on the date navigation bar`)3101 } else {3102 console.log(`Failure: ${daytext} is displayed after clicking on the date navigation bar`)3103 }3104 }3105 break;3106 case 'Web':3107 // web operation3108 break3109 default: break3110 }3111 } catch (e) {3112 console.error(`${object} is not displayed`);3113 //browser.saveScreenshot();3114 return assert.strictEqual(platform, '', e);3115 }3116});3117/*3118 Then statement to verify if yesterday has been displayed3119 */3120Then(/^I should verify the header displayed as date for "([^"]*)"$/, async (object) => {3121 try {3122 switch (platform) {3123 case 'Android':3124 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');3125 console.log(`${object} screen is displayed`);3126 ////browser.saveScreenshot();3127 break;3128 case 'ios':3129 const daybeforeyesterday = browser.element(`${fileutils.readPropertyFile(platform, 'DayDetail.Day')}`)3130 const daybeforedate = moment().subtract(2, 'days').format('dddd, Do MMMM');3131 if (daybeforeyesterday.isVisible()) {3132 const daybeforeyesterdaytext = browser.element(`${fileutils.readPropertyFile(platform, 'DayDetail.Day')}`).getText()3133 if (daybeforeyesterdaytext === daybeforedate) {3134 console.log(`Day before yesterday date: ${daybeforeyesterdaytext}`)3135 } else {3136 console.log(`Not displayed as date ${daybeforeyesterdaytext}`)3137 }3138 }3139 break;3140 case 'Web':3141 // web operation3142 break3143 default: break3144 }3145 } catch (e) {3146 console.error(`${object} screen is not displayed`);3147 //browser.saveScreenshot();3148 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);3149 }3150});3151/*3152 Then statement to verify if yesterday has been displayed3153 */3154Then(/^I should see "([^"]*)" displayed for "([^"]*)" card$/, async (object, card) => {3155 try {3156 switch (platform) {3157 case 'Android':3158 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');3159 console.log(`${object} screen is displayed`);3160 ////browser.saveScreenshot();3161 break;3162 case 'ios':3163 if (card === 'Describe.Impact') {3164 const impactimage = $(`${fileutils.readPropertyFile(platform, object)}`)3165 const impactchevron = $(`${fileutils.readPropertyFile(platform, 'Describe.Impact.Chevron')}`)3166 if (impactimage.isVisible() || impactchevron.isVisible()) {3167 console.log(`${object} is visible and present on the screen for the ${card} card`)3168 } else {3169 console.log(`${object} is not visible and present on the screen for the ${card} card`)3170 }3171 } else if (card === 'Describe.Pain.Intensity') {3172 const painintensityimage = $(`${fileutils.readPropertyFile(platform, object)}`)3173 const painintensitychevron = $(`${fileutils.readPropertyFile(platform, 'Describe.Pain.Intensity.Chevron')}`)3174 if (painintensityimage.isVisible() || painintensitychevron.isVisible()) {3175 console.log(`${object} is visible and present on the screen for the ${card} card`)3176 } else {3177 console.log(`${object} is not visible and present on the screen for the ${card} card`)3178 }3179 } else if (card === 'Describe.Migraine.Details') {3180 const migrainedetailsimage = $(`${fileutils.readPropertyFile(platform, object)}`)3181 const migrainedetailschevron = $(`${fileutils.readPropertyFile(platform, 'Describe.Migraine.Details.Chevron')}`)3182 if (migrainedetailsimage.isVisible() || migrainedetailschevron.isVisible()) {3183 console.log(`${object} is visible and present on the screen for the ${card} card`)3184 } else {3185 console.log(`${object} is not visible and present on the screen for the ${card} card`)3186 }3187 } else if (card === 'Describe.Medication') {3188 const medicationimage = $(`${fileutils.readPropertyFile(platform, object)}`)3189 const medicationchevron = $(`${fileutils.readPropertyFile(platform, 'Describe.Medication.Chevron')}`)3190 if (medicationimage.isVisible() || medicationchevron.isVisible()) {3191 console.log(`${object} is visible and present on the screen for the ${card} card`)3192 } else {3193 console.log(`${object} is not visible and present on the screen for the ${card} card`)3194 }3195 }3196 break;3197 case 'Web':3198 // web operation3199 break3200 default: break3201 }3202 } catch (e) {3203 console.error(`${object} screen is not displayed`);3204 //browser.saveScreenshot();3205 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);3206 }3207});3208/*3209 Then statement to verify the header/button/card present in the screen3210 */3211Then(/^I must verify the order of cards present in the screen$/, async () => {3212 try {3213 switch (platform) {3214 case 'Android':3215 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, '')} `).isVisible(), timeOutinMs, 'Element not found');3216 console.log('', 'screen is displayed');3217 ////browser.saveScreenshot();3218 break;3219 case 'ios':3220 const cardstext = browser.elements('~card_primary_text').getText()3221 if (_.indexOf(cardstext, 'Describe Pain Intensity') > _.indexOf(cardstext, 'Describe Impact')) {3222 console.log('Desribe Impact card is displayed 1st and then Describe Pain Intensity is displayed 2nd')3223 } else {3224 console.log('Describe Pain Intensity card is displayed 1st and then Desribe Impact is displayed 2nd')3225 }3226 if (_.indexOf(cardstext, 'Describe Migraine Details') > _.indexOf(cardstext, 'Describe Pain Intensity')) {3227 console.log('Describe Pain Intensity card is displayed 2nd and then Describe Migraine Details is displayed 3rd')3228 } else {3229 console.log('Describe Migraine Details card is displayed 1st and then Describe Pain Intensity is displayed 2nd')3230 }3231 if (_.indexOf(cardstext, 'Describe Medication') > _.indexOf(cardstext, 'ßDescribe Migraine Details')) {3232 console.log('Describe Migraine Details card is displayed 3rd and then Describe Medication is displayed 4th')3233 } else {3234 console.log('Describe Medication card is displayed 1st and then Describe Migraine Details is displayed 2nd')3235 }3236 break;3237 case 'Web':3238 // web operation3239 break;3240 default: break3241 }3242 } catch (e) {3243 console.error('screen is not displayed');3244 //browser.saveScreenshot();3245 return assert.strictEqual(platform, 'ios', 'screen is not displayed');3246 }3247});3248/*3249 Then statement to verify the header/button/card present in the screen3250 */3251Then(/^I must verify the order of medication card after saving for a different time slot$/, async () => {3252 try {3253 switch (platform) {3254 case 'Android':3255 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, '')} `).isVisible(), timeOutinMs, 'Element not found');3256 console.log('', 'screen is displayed');3257 ////browser.saveScreenshot();3258 break;3259 case 'ios':3260 const xpath = fileutils.readPropertyFile(platform, 'Describe.Medication.Time')3261 const medtimes = browser.elements(xpath).getText()3262 console.log(`Time displayed for each medication card: ${medtimes}`)3263 const timeadded = `${Hour}:${Minute} ${TimeMeridien}`3264 if (_.indexOf(medtimes, timeadded) < _.indexOf(medtimes, '12:00 am')) {3265 console.log(`${timeadded} is displayed first after the change in time for a medication card`)3266 } else {3267 console.log(`${timeadded} is displayed second after the change in time for a medication card`)3268 }3269 break;3270 case 'Web':3271 // web operation3272 break;3273 default: break3274 }3275 } catch (e) {3276 console.error('screen is not displayed');3277 //browser.saveScreenshot();3278 return assert.strictEqual(platform, 'ios', 'screen is not displayed');3279 }3280});3281/*3282 Then statement to verify the header/button/card present in the screen3283 */3284Then(/^I should verify in incomplete tab for undetailed events$/, async () => {3285 try {3286 switch (platform) {3287 case 'Android':3288 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, '')} `).isVisible(), timeOutinMs, 'Element not found');3289 console.log('', 'screen is displayed');3290 ////browser.saveScreenshot();3291 break;3292 case 'ios':3293 const undetailedcards = function undetailedcards() {3294 const migrainecard = $(`${fileutils.readPropertyFile(platform, 'Undetailed.Migraine.Card')}`)3295 const medicationcard = $(`${fileutils.readPropertyFile(platform, 'Undetailed.Medication.Card')}`)3296 // Migraine Card ----3297 if (migrainecard.isVisible()) {3298 migrainecard.click()3299 // Impact tab3300 const migraineheader = $(`${fileutils.readPropertyFile(platform, 'Undetailed.Migraine.Detail')}`).getText()3301 const editimpact = browser.element(`${fileutils.readPropertyFile(platform, 'Edit.Impact')}`).getText()3302 console.log(`${migraineheader} header is displayed`)3303 console.log(`Impact text: ${editimpact} `)3304 // Clicking on pain tab3305 browser.element(`${fileutils.readPropertyFile(platform, 'Pain')}`).Cick()3306 const editpain = browser.element(`${fileutils.readPropertyFile(platform, 'Edit.Intensity')}`).getText()3307 console.log(`Pain text: ${editpain}`)3308 // Clicking on details tab3309 browser.element(`${fileutils.readPropertyFile(platform, 'Details')}`).Cick()3310 const editdetails = browser.element(`${fileutils.readPropertyFile(platform, 'Select.Details')}`).getText()3311 console.log(`Details text: ${editdetails}`)3312 // Clicking on done button3313 browser.element(`${fileutils.readPropertyFile(platform, 'Donebtn')}`).Cick()3314 } else {3315 console.log('Edit Migraine not present')3316 }3317 // Medication card3318 if (medicationcard.isVisible()) {3319 medicationcard.click()3320 const editmedication = browser.element(`${fileutils.readPropertyFile(platform, 'Medication.Detail.Banner')}`).getText()3321 console.log(`Edit Medication text: ${editmedication}`)3322 browser.element(`${fileutils.readPropertyFile(platform, 'Add.Medication.Save')}`.click())3323 }3324 }3325 // Checking for weekday and month in Incomplete Event3326 const weekday = browser.element(`${fileutils.readPropertyFile(platform, 'Undetailed.WeekdDay')}`)3327 const month = $(`${fileutils.readPropertyFile(platform, 'Undetailed.Month')}`)3328 if (weekday.isVisible()) {3329 console.log(`Undetailed event has been logged on ${weekday.getText()} in the month of ${month.getText()}`)3330 }3331 const cards = browser.elements(`${fileutils.readreadPropertyFile(platform, 'Undetailed.Cards')}`)3332 if (cards.isVisible()) {3333 console.log(`Undetailed event cards displayed: ${cards.getText()}`)3334 undetailedcards()3335 } else {3336 console.log('There are no undetailed event cards present on screen')3337 }3338 break;3339 case 'Web':3340 // web operation3341 break;3342 default: break3343 }3344 } catch (e) {3345 console.error('screen is not displayed');3346 //browser.saveScreenshot();3347 return assert.strictEqual(platform, 'ios', 'screen is not displayed');3348 }3349});3350Then(/^I should see "([^"]*)" count on "([^"]*)"$/, async (tab, navigationtab) => {3351 try {3352 switch (platform) {3353 case 'android':3354 // android code here----3355 break;3356 case 'ios':3357 const exists = browser.waitUntil(() => browser.elements(`${fileutils.readPropertyFile(platform, navigationtab)}`).isEnabled(), timeOutinMs, 'Element not found');3358 if (exists) {3359 const value = browser.elements(`${fileutils.readPropertyFile(platform, navigationtab)}`).getText();3360 if (tab === value) {3361 console.log(`Total ${tab} incomplete badges are present`)3362 break3363 } else {3364 console.log('Incomplete badges are not present')3365 }3366 }3367 ////browser.saveScreenshot();3368 break;3369 case 'web':3370 // web operation3371 break;3372 default: break3373 }3374 } catch (e) {3375 console.error(e);3376 //browser.saveScreenshot();3377 return assert.strictEqual(platform, 'ios', `Total ${tab} incomplete badges are not displayed`);3378 }3379});3380Then(/^I get values from "([^"]*)" and verify if they are sorted$/, async (object) => {3381 try {3382 switch (platform) {3383 case 'android':3384 // android code here----3385 break;3386 case 'ios':3387 const check = fileutils.readPropertyFile(platform, object)3388 if (check.startsWith('/') || check.startsWith('//')) {3389 const xpath = fileutils.readPropertyFile(platform, object)3390 const ListFromApp = browser.elements(xpath).getText()3391 console.log('_________________________________________________________________________________')3392 console.log(`\n${object}: List from App\n${ListFromApp}\n`)3393 console.log('_________________________________________________________________________________')3394 const sortedtext = ListFromApp.sort()3395 if (ListFromApp === sortedtext) {3396 console.log(`${object} Pass: List is sorted`)3397 ////browser.saveScreenshot();3398 } else {3399 console.log(`${object} Fail: List is not sorted`)3400 }3401 }3402 break3403 case 'web':3404 // web operation3405 break;3406 default: break3407 }3408 } catch (e) {3409 console.error(`${object} is not displayed`);3410 //browser.saveScreenshot();3411 return assert.strictEqual(platform, 'ios', `${object} is not displayed`);3412 }3413});3414Then(/^I verify data from "([^"]*)" matches with data from contentful "([^"]*)"$/, async (object, contentType) => {3415 try {3416 switch (platform) {3417 case 'android':3418 // android code here----3419 break;3420 case 'ios':3421 const text = await contentful.Medication(contentType);3422 const xpath = fileutils.readPropertyFile(platform, object)3423 const ListFromApp = await browser.elements(xpath).getText()3424 const text1 = text.sort()3425 console.log('_________________________________________________________________________________')3426 console.log(`Data From contentful\n${text1}`)3427 console.log('_________________________________________________________________________________')3428 console.log('_________________________________________________________________________________')3429 console.log(`Data From Application\n${ListFromApp}`)3430 console.log('_________________________________________________________________________________')3431 let flag3432 for (let i = 0; i < ListFromApp.length; i += 1) {3433 if (text1[i] === ListFromApp[i]) {3434 flag = 13435 } else {3436 flag = 03437 break3438 }3439 }3440 if (flag === 1) {3441 console.log('Pass : Data From Contentful Matches with Data from the Application')3442 } else {3443 console.log('Fail : Data From Contentful does not match with Data from the Application')3444 }3445 break3446 case 'web':3447 // web operation3448 break;3449 default: break3450 }3451 } catch (e) {3452 console.error(`Cannot fetch contentful data: ${e}`);3453 //browser.saveScreenshot();3454 return assert.strictEqual(platform, 'ios', `Cannot fetch contentful data: ${e}`);3455 }3456});3457Then(/^I select "([^"]*)" and deselect the medicine$/, async (object) => {3458 try {3459 switch (platform) {3460 case 'android':3461 // android code here----3462 break;3463 case 'ios':3464 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object)).isVisible(), timeOutinMs, 'Element not found');3465 if (exists) {3466 const xpath = fileutils.readPropertyFile(platform, object)3467 const len = browser.elements(xpath).value.length;3468 console.log(len)3469 let rand = len3470 let ListFromApp = browser.element(`${xpath}[${rand}]`).getText()3471 console.log(ListFromApp)3472 browser.element(`${xpath}[${rand}]`).click()3473 let xpath2 = `//*[@value='${ListFromApp}']/preceding-sibling::XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']`3474 if (browser.element(xpath2).isVisible()) {3475 console.log(`Pass ${ListFromApp}is selected`)3476 } else {3477 console.log(`Fail ${ListFromApp}is not selected`)3478 }3479 browser.element(xpath2).click()3480 if (!browser.element(xpath2).isVisible()) {3481 console.log(`Pass ${ListFromApp}is de selected`)3482 } else {3483 console.log(`Fail ${ListFromApp}is not de selected`)3484 }3485 browser.element(`${xpath}[${rand}]`).click()3486 if (browser.element(xpath2).isVisible()) {3487 console.log(`Pass ${ListFromApp}is selected`)3488 } else {3489 console.log(`Fail ${ListFromApp}is not selected`)3490 }3491 rand -= 13492 browser.element(`${xpath}[${rand}]`).click()3493 if (!browser.element(xpath2).isVisible()) {3494 console.log(`Pass ${ListFromApp}is de selected`)3495 } else {3496 console.log(`Fail ${ListFromApp}is not de selected`)3497 }3498 ListFromApp = browser.element(`${xpath}[${rand}]`).getText()3499 xpath2 = `//*[@value='${ListFromApp}']/preceding-sibling::XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']`3500 if (browser.element(xpath2).isVisible()) {3501 recordlevel = ListFromApp3502 console.log(`Pass ${ListFromApp}is selected`)3503 } else {3504 console.log(`Fail ${ListFromApp}is not selected`)3505 }3506 }3507 browser.saveScreenshot()3508 break3509 case 'web':3510 // web operation3511 break;3512 default: break3513 }3514 } catch (e) {3515 console.error(`Cannot fetch contentful data: ${e}`);3516 }3517});3518Then(/^I select "([^"]*)" and check if reflects on screen$/, async (object) => {3519 try {3520 switch (platform) {3521 case 'android':3522 // android code here----3523 break;3524 case 'ios':3525 const xpath = fileutils.readPropertyFile(platform, object)3526 const ListFromApp = browser.element(xpath).getText()3527 browser.element(xpath).click()3528 browser.element('~Done').click();3529 const xpath2 = `//*[@value='${ListFromApp}']`3530 const ListFromApp2 = browser.elements(xpath2).getText()3531 if (ListFromApp2 === ListFromApp) {3532 console.log(`Pass ${ListFromApp}is selected successfully`)3533 } else {3534 console.log(`Fail ${ListFromApp}is not selected`)3535 }3536 browser.saveScreenshot()3537 break3538 case 'web':3539 // web operation3540 break;3541 default: break3542 }3543 } catch (e) {3544 console.error(`Cannot fetch contentful data: ${e}`);3545 //browser.saveScreenshot();3546 return assert.strictEqual(platform, 'ios', `Cannot fetch contentful data: ${e}`);3547 }3548});3549Then(/^I should verify that "([^"]*)" text is displayed$/, async (object) => {3550 try {3551 switch (platform) {3552 case 'android':3553 // android code here----3554 break;3555 case 'ios':3556 const xpath = fileutils.readPropertyFile(platform, object)3557 const impactlabel = $(`${fileutils.readPropertyFile(platform, 'Impact.Label')}`).getText()3558 if (xpath.startsWith('/') || xpath.startsWith('//')) {3559 const textwithxpath = $(xpath).getText()3560 console.log(`${impactlabel}: ${textwithxpath}`)3561 } else {3562 const textwithid = browser.element(`~${xpath}`).getText()3563 console.log(`${impactlabel}: ${textwithid}`)3564 }3565 break3566 case 'web':3567 // web operation3568 break;3569 default: break3570 }3571 } catch (e) {3572 console.error(`Cannot fetch text: ${e}`);3573 }3574});3575Then(/^I drag the impact slider to "([^"]*)"$/, async (impactlevel) => {3576 try {3577 switch (platform) {3578 case 'android':3579 // android code here----3580 break;3581 case 'ios':3582 const impactelementx = browser.element('~editimpact_slider').getLocation('x')3583 const impactelementy = browser.element('~editimpact_slider').getLocation('y')3584 if (impactlevel === 'mild') {3585 browser.touchMultiPerform([3586 { action: 'press', options: { x: impactelementx, y: impactelementy } },3587 { action: 'wait', options: { ms: 2000 } },3588 { action: 'moveTo', options: { x: 180, y: 200 } },3589 { action: 'release' },3590 ]);3591 } else if (impactlevel === 'moderate') {3592 browser.touchMultiPerform([3593 { action: 'press', options: { x: impactelementx, y: impactelementy } },3594 { action: 'wait', options: { ms: 2000 } },3595 { action: 'moveTo', options: { x: 220, y: 240 } },3596 { action: 'release' },3597 ]);3598 } else if (impactlevel === 'severe') {3599 browser.touchMultiPerform([3600 { action: 'press', options: { x: impactelementx, y: impactelementy } },3601 { action: 'wait', options: { ms: 2000 } },3602 { action: 'moveTo', options: { x: 400, y: 450 } },3603 { action: 'release' },3604 ]);3605 }3606 ////browser.saveScreenshot();3607 browser.pause(1000)3608 recordlevel = browser.element(`${fileutils.readPropertyFile(platform, 'Impact.Level')}`).getText()3609 console.log(`Impact Level: ${recordlevel}`)3610 break3611 case 'web':3612 // web operation3613 break;3614 default: break3615 }3616 } catch (e) {3617 console.error(`Cannot drag the slider to ${impactlevel} due to: ${e}`);3618 }3619});3620Then(/^I should verify that "([^"]*)" recorded is same as in the card detail$/, async (card) => {3621 try {3622 switch (platform) {3623 case 'android':3624 // android code here----3625 break;3626 case 'ios':3627 if (card === 'ImpactLevel') {3628 const impactcardtext = $(`${fileutils.readPropertyFile(platform, 'Impact.Details')}`).getText()3629 const splitforcomma = impactcardtext.split(',')3630 const number = splitforcomma[1]3631 if (parseInt(recordlevel, 10) === parseInt(number, 10)) {3632 console.log('----Recorded level matches----')3633 console.log(`Recorded Level: ${recordlevel}`)3634 console.log(`Level displayed on ${card}: ${number}`)3635 } else {3636 console.log('----Recorded Level does not match----')3637 console.log(`Recorded Level: ${recordlevel}`)3638 console.log(`Level displayed on ${card}: ${number}`)3639 }3640 } else if (card === 'PainIntensity') {3641 const paincardtext = $(`${fileutils.readPropertyFile(platform, 'Pain.Intensity.Details')}`).getText()3642 const splitforcomma = paincardtext.split(',')3643 const textoncard = splitforcomma[0]3644 if (painintensitylevel === textoncard) {3645 console.log('----Recorded level matches----')3646 console.log(`Recorded Level: ${painintensitylevel}`)3647 console.log(`Level displayed on ${card}: ${textoncard}`)3648 } else {3649 console.log('----Recorded Level does not match----')3650 console.log(`Recorded Level: ${painintensitylevel}`)3651 console.log(`Level displayed on ${card}: ${textoncard}`)3652 }3653 }3654 ////browser.saveScreenshot();3655 break3656 case 'web':3657 // web operation3658 break;3659 default: break3660 }3661 } catch (e) {3662 console.error(`Cannot perform for ${card} due to: ${e}`);3663 }3664});3665Then(/^I swipe up in the scale to "([^"]*)"$/, async (PainIntensity) => {3666 try {3667 switch (platform) {3668 case 'android':3669 // perform operation on android element3670 break;3671 case 'ios':3672 if (PainIntensity === 'moderate') {3673 browser.execute('mobile:swipe', { direction: 'down' })3674 } else if (PainIntensity === 'severe') {3675 browser.execute('mobile:swipe', { direction: 'up' })3676 }3677 // browser.saveScreenshot()3678 break;3679 case 'web':3680 // web code----3681 break;3682 default: break3683 }3684 } catch (e) {3685 console.error(`\n Cannot read ${PainIntensity} level: ${e} `);3686 ////browser.saveScreenshot();3687 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');3688 }3689});3690Then(/^"([^"]*)" option should get unselected on "([^"]*)"$/, async (symptom, listName) => {3691 try {3692 switch (platform) {3693 case 'android':3694 break3695 case 'ios':3696 const exists = browser.waitUntil(() => browser.elements('~widget_symptomslistcomponentlabel_text').isVisible(), timeOutinMs, 'Element not found');3697 if (exists) {3698 const textFromConfig = appconfig.verifyTextFromConfig(listName);3699 const selectedSymptoms = browser.elements("//XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']/following-sibling::XCUIElementTypeStaticText[@name='widget_symptomslistcomponentlabel_text']").getText();3700 const unique = textFromConfig.filter(o => selectedSymptoms.indexOf(o) === -1);3701 console.log(`Symptom not selected: ${unique}`);3702 for (let i = 0; i < unique.length; i += 1) {3703 if (`${symptom}` === `${unique[i]}`) {3704 console.log(`${unique[i]} option is unselected`);3705 }3706 }3707 ////browser.saveScreenshot();3708 break;3709 }3710 break3711 case 'web':3712 // web operation3713 break;3714 default: break3715 }3716 } catch (e) {3717 console.error(`${listName} is not displayed`);3718 //browser.saveScreenshot();3719 return assert.strictEqual(platform, 'ios', `${listName} is not displayed`);3720 }3721});3722Then(/^I verify for Terms and Privacy screen$/, async () => {3723 try {3724 switch (platform) {3725 case 'android':3726 // android code here----3727 break;3728 case 'ios':3729 const exists = browser.waitUntil(() => browser.element('~terms_privacy_text_view').isVisible(), timeOutinMs, 'Element not found');3730 if (exists) {3731 browser.element('~signup_agree_btn').click()3732 } else {3733 console.log('Terms and Privacy up to date')3734 }3735 ////browser.saveScreenshot();3736 break;3737 case 'web':3738 // web operation3739 break;3740 default: break3741 }3742 } catch (e) {3743 console.error(e);3744 //browser.saveScreenshot();3745 return assert.strictEqual(platform, 'ios', e);3746 }3747});3748Then(/^I press enter$/, async () => {3749 try {3750 switch (platform) {3751 case 'android':3752 browser.keys('\n')3753 ////browser.saveScreenshot();3754 break;3755 case 'ios':3756 browser.keys('\n')3757 ////browser.saveScreenshot();3758 break3759 case 'web':3760 // web operation3761 break;3762 default: break3763 }3764 } catch (e) {3765 console.error(`Cannot fetch contentful data: ${e}`);3766 }3767});3768/*3769 Then statement to verify the alert description for time chosen from the pickerwheel3770*/3771Then(/^I must see the "([^"]*)" with new time chosen from pickerwheel$/, async (object) => {3772 try {3773 switch (platform) {3774 case 'android':3775 // android here---3776 break;3777 case 'ios':3778 const alertdesctime = $(fileutils.readPropertyFile(platform, object)).getText();3779 const HourValue = Hour;3780 const MinuteValue = Minute;3781 const MeridienValue = TimeMeridien.toLowerCase();3782 const timeadd = `${HourValue}:${MinuteValue} ${MeridienValue}`;3783 if (alertdesctime.includes(timeadd)) {3784 console.log(`${object} is displayed with the new time chosen from picker wheel`);3785 console.log(`${'Alert Display: '} ${alertdesctime} `);3786 } else {3787 console.log('There is a difference in the time chosen and the alert displayed');3788 console.log(`${'Alert displayed: '} ${alertdesctime} `);3789 }3790 ////browser.saveScreenshot();3791 break3792 case 'web':3793 // web operation3794 break;3795 default: break3796 }3797 } catch (e) {3798 console.error(`${object} screen is not displayed`);3799 //browser.saveScreenshot();3800 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);3801 }3802});3803Then(/^I swipe in the scale to "([^"]*)"$/, async (PainIntensity) => {3804 try {3805 switch (platform) {3806 case 'android':3807 // perform operation on android element3808 break;3809 case 'ios':3810 if (PainIntensity === 'moderate') {3811 browser.execute('mobile: swipe', { direction: 'down' });3812 } else if (PainIntensity === 'severe') {3813 browser.execute('mobile:swipe', { direction: 'up' })3814 }3815 painintensitylevel = browser.element('~editintensity_intensity_type').getText()3816 console.log(`Pain Intensity Level: ${painintensitylevel}`)3817 ////browser.saveScreenshot();3818 break;3819 case 'web':3820 // web code----3821 break;3822 default: break3823 }3824 } catch (e) {3825 console.error(`\n Cannot read ${PainIntensity} level: ${e} `);3826 //browser.saveScreenshot();3827 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');3828 }3829});3830Then(/^I should verify that medication is added for the current day and date under "([^"]*)" label$/, async (object) => {3831 try {3832 switch (platform) {3833 case 'android':3834 // android here---3835 break;3836 case 'ios':3837 const medcurrentdate = browser.element(`${fileutils.readPropertyFile(platform, 'Medication.Current.Date')} `).getText();3838 const datefromsystem = moment().format('ddd D MMM YY');3839 if (medcurrentdate === datefromsystem) {3840 console.log(`-- - ${object} --- `);3841 console.log(`${'Medication is being added for the current date: '} ${medcurrentdate} `);3842 } else {3843 console.log(`${'Medication is being added for a different date: '} ${medcurrentdate} `);3844 console.log(`${'Date displayed in app: '} ${medcurrentdate} `);3845 console.log(`${'System date: '} ${datefromsystem} `);3846 }3847 break3848 case 'web':3849 // web operation3850 break;3851 default: break3852 }3853 } catch (e) {3854 console.error(`${object} screen is not displayed`);3855 //browser.saveScreenshot();3856 return assert.strictEqual(platform, 'ios', `${object} screen is not displayed`);3857 }3858});3859Then(/^I should verify that "([^"]*)" button is displayed at the bottom of screen$/, async (object) => {3860 try {3861 switch (platform) {3862 case 'android':3863 // perform operation on android element3864 break;3865 case 'ios':3866 if (object === 'Delete.Migraine') {3867 const deletemigraine = browser.element(`${fileutils.readPropertyFile(platform, object)}`)3868 if (deletemigraine.isVisible()) {3869 const deletemigrainetext = deletemigraine.getText()3870 console.log(`Pass: ${deletemigrainetext} is visible`)3871 } else {3872 console.log(`Fail: ${object} is not visible`)3873 }3874 } else if (object === 'Delete.All.Medications') {3875 const deletemedication = browser.element(`${fileutils.readPropertyFile(platform, object)}`)3876 if (deletemedication.isVisible()) {3877 const deletemigrainetext = deletemedication.getText()3878 console.log(`Pass: ${deletemigrainetext} is visible`)3879 } else {3880 console.log(`Fail: ${object} is not visible`)3881 }3882 }3883 // browser.saveScreenshot()3884 break;3885 case 'web':3886 // web code----3887 break;3888 default: break3889 }3890 } catch (e) {3891 console.error(`\n Cannot read ${object}: ${e} `);3892 //browser.saveScreenshot();3893 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');3894 }3895});3896Then(/^I should verify that "([^"]*)" is not visible$/, async (object) => {3897 try {3898 switch (platform) {3899 case 'android':3900 // perform operation on android element3901 break;3902 case 'ios':3903 const objidtext = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText()3904 const type = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getAttribute('type')3905 if (objidtext.isVisible()) {3906 console.log(`Fail: ${type}: ${object} is visible on screen`)3907 } else {3908 console.log(`Pass: ${type}: ${object} is not visible`)3909 }3910 break;3911 case 'web':3912 // web code----3913 break;3914 default: break3915 }3916 } catch (e) {3917 console.error(`\n Cannot read ${object}: ${e} `);3918 //browser.saveScreenshot();3919 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');3920 }3921});3922Then(/^I verify the "([^"]*)" for "([^"]*)"$/, async (Time, object) => {3923 try {3924 switch (platform) {3925 case 'android':3926 // perform operation on android element3927 break;3928 case 'ios':3929 const medtime = browser.element(`${fileutils.readPropertyFile(platform, object)}`).getText()3930 const day = browser.element(`${fileutils.readPropertyFile(platform, 'DayDetail.Day')}`).getText()3931 if (Time === 'Default.Time') {3932 if (medtime.includes('12:00 am')) {3933 console.log(`Pass: For ${day}, Time is defaulted to ${medtime}`)3934 } else {3935 console.log(`Fail: For ${day}, Time is not defaulted to ${medtime}`)3936 }3937 } else if (Time === 'Current.Time') {3938 const currenttime = moment().format('h:mm a')3939 if (medtime === currenttime) {3940 console.log('Pass: Time is defaulted to current time')3941 console.log(`Medication time displayed: ${medtime}`)3942 console.log(`Current System time: ${currenttime}`)3943 } else {3944 console.log('Fail: Time is not defaulted to current time')3945 console.log(`Medication time displayed: ${medtime}`)3946 console.log(`Current System time: ${currenttime}`)3947 }3948 } else if (Time === 'Edited.Medication.time') {3949 const timeadded = `${Hour}:${Minute} ${TimeMeridien}`3950 const medtext = $(`${fileutils.readPropertyFile(platform, 'Day.Details.Medication.Time')}`).getText()3951 if (medtext === timeadded) {3952 console.log(`Pass: Time is defaulted to medication time added: ${medtext}`)3953 } else {3954 console.log(`Fail: Time is not defaulted to medication time added: ${medtext}}`)3955 }3956 }3957 // browser.saveScreenshot()3958 break;3959 case 'web':3960 // web code----3961 break;3962 default: break3963 }3964 } catch (e) {3965 console.error(`\n Cannot read ${object}: ${e} `);3966 //browser.saveScreenshot();3967 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');3968 }3969});3970/*3971// Duplicate Step Defn for When(/^medication cards should be ordered by "([^"]*)"$/)3972// --- Keeping this as it is written using moment.js3973// Note: Will remove once the function becomes reduntant or performance issues3974*/3975Then(/^I should verify that medication cards are sorted for "([^"]*)"$/, async (object) => {3976 try {3977 switch (platform) {3978 case 'android':3979 // perform operation on android element3980 break;3981 case 'ios':3982 const xpath = fileutils.readPropertyFile(platform, object)3983 const daydetailsmedtime = browser.elements(`~${xpath}`).getText()3984 for (let i = 0; i < daydetailsmedtime.length; i += 1) {3985 const time1 = moment().format('[daydetailsmedtime[i]] h:mm a')3986 const time2 = moment().format('[daydetailsmedtime[i+1]] h:mm a')3987 if (time1 < time2) {3988 console.log(`Pass: ${time1} is displayed first and ${time2} is displayed second`)3989 } else {3990 console.log(`Fail: ${time2} is displayed first and ${time1} is displayed second`)3991 }3992 }3993 //browser.saveScreenshot()3994 break;3995 case 'web':3996 // web code----3997 break;3998 default: break3999 }4000 } catch (e) {4001 console.error(`\n Cannot read ${object}: ${e} `);4002 //browser.saveScreenshot();4003 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');4004 }4005});4006/*4007// Duplicate Step Defn for When(/^I move the "([^"]*)" towards "([^"]*)"$/)4008// --- Keeping this as the below is for Xpath.4009// Note: Will remove once the function becomes reduntant or performance issues4010*/4011Then(/^I should swipe "([^"]*)" for "([^"]*)"$/, async (swipe, object) => {4012 try {4013 switch (platform) {4014 case 'android':4015 // perform operation on android element4016 break;4017 case 'ios':4018 const card = $(`${fileutils.readPropertyFile(platform, object)}`)4019 browser.execute('mobile:swipe', { direction: swipe, element: card })4020 ////browser.saveScreenshot();4021 break;4022 case 'web':4023 // web code----4024 break;4025 default: break4026 }4027 } catch (e) {4028 console.error(`\n Cannot read ${object}: ${e} `);4029 //browser.saveScreenshot();4030 return assert.strictEqual(platform, '', e);4031 }4032});4033Then(/^I should verify the label on "([^"]*)"$/, async (object) => {4034 try {4035 switch (platform) {4036 case 'android':4037 // perform operation on android element4038 break;4039 case 'ios':4040 const objele = fileutils.readPropertyFile(platform, object)4041 const carddesc = browser.elements(`~${objele}`).getText()4042 for (let i = 0; i < carddesc.length; i += 1) {4043 if (carddesc[i].includes('Describe')) {4044 console.log(`Pass: ${carddesc[i]} is displayed after clearing the value`)4045 } else {4046 console.log(`Fail: ${carddesc} is not displayed after clearing the value`)4047 }4048 }4049 // browser.saveScreenshot()4050 break;4051 case 'web':4052 // web code----4053 break;4054 default: break4055 }4056 } catch (e) {4057 console.error(`\n Cannot read ${object}: ${e} `);4058 //browser.saveScreenshot();4059 return assert.strictEqual(platform, 'ios', '\n Cannot read the intensity level ');4060 }4061});4062Then(/^I input "([^"]*)" in "([^"]*)" and verify valid medications are listed in "([^"]*)"$/, async (item, object1, object2) => {4063 try {4064 switch (platform) {4065 case 'android':4066 // android here---4067 break;4068 case 'ios':4069 browser.element(`${fileutils.readPropertyFile(platform, object1)}`).click();4070 browser.element(`${fileutils.readPropertyFile(platform, object1)}`).setValue(item);4071 const exists = browser.waitUntil(() => $(fileutils.readPropertyFile(platform, object2)).isVisible(), timeOutinMs, 'Element not found');4072 if (exists) {4073 if (!browser.element('~Other - medication not listed').isVisible()) {4074 if (item.length === 2) {4075 const itemm = `^${item}`4076 const regex = { itemregex: itemm };4077 const ListRegex = new RegExp(regex.itemregex);4078 const xpath = fileutils.readPropertyFile(platform, object2)4079 const ListFromApp = browser.elements(xpath).getText()4080 let flag4081 for (let i = 0; i < ListFromApp.length; i += 1) {4082 const c = ListFromApp[i].split('(')4083 for (let j = 0; j < c.length; j += 1) {4084 if (ListRegex.test(c[j].toLowerCase())) {4085 flag = 14086 break4087 } else {4088 flag = 04089 }4090 }4091 if (flag === 1) {4092 console.log('_________________________________________________________________________________')4093 console.log('Pass: Search results matches the expected criteria')4094 console.log(ListFromApp[i])4095 console.log('_________________________________________________________________________________')4096 } else {4097 console.log('_________________________________________________________________________________')4098 console.log('Fail: Search results do not match the expected criteria')4099 console.log(ListFromApp[i])4100 console.log('_________________________________________________________________________________')4101 }4102 }4103 ////browser.saveScreenshot();4104 break4105 } else if (item.length > 2) {4106 const itemm = item4107 const regex = { itemregex: itemm };4108 const ListRegex = new RegExp(regex.itemregex);4109 const xpath = fileutils.readPropertyFile(platform, object2)4110 const ListFromApp = browser.elements(xpath).getText()4111 let flag4112 for (let i = 0; i < ListFromApp.length; i += 1) {4113 ListFromApp[i] = ListFromApp[i].replace('(', '')4114 const c = ListFromApp[i].split(' ')4115 for (let j = 0; j < c.length; j += 1) {4116 if (ListRegex.test(c[j].toLowerCase())) {4117 flag = 14118 break4119 } else {4120 flag = 04121 }4122 }4123 if (flag === 1) {4124 console.log('_________________________________________________________________________________')4125 console.log('Pass: Search results matches the expected criteria')4126 console.log(ListFromApp[i])4127 console.log('_________________________________________________________________________________')4128 } else {4129 console.log('_________________________________________________________________________________')4130 console.log('Fail: Search results do not match the expected criteria')4131 console.log(ListFromApp[i])4132 console.log('_________________________________________________________________________________')4133 }4134 }4135 ////browser.saveScreenshot();4136 break4137 }4138 } else {4139 console.log('Other - medication not listed')4140 }4141 }4142 ////browser.saveScreenshot();4143 break4144 case 'web':4145 // web operation4146 break;4147 default: break4148 }4149 } catch (e) {4150 console.error(`${object1} screen is not displayed`);4151 //browser.saveScreenshot();4152 return assert.strictEqual(platform, 'ios', `${object1} screen is not displayed`);4153 }4154});4155Then(/^I verify "([^"]*)" is deselected in "([^"]*)"$/, async (item, object) => {4156 try {4157 switch (platform) {4158 case 'android':4159 // android code here----4160 break;4161 case 'ios':4162 const exists = browser.waitUntil(() => browser.elements(`${fileutils.readPropertyFile(platform, object)}`).isVisible(), timeOutinMs, 'Element not found');4163 if (exists) {4164 const xpath2 = `//*[@value='${recordlevel}']/preceding-sibling::XCUIElementTypeImage[@name='widget_symptomslistcontainerimage_view']`4165 if (!browser.element(xpath2).isVisible()) {4166 console.log(`Pass ${recordlevel}is deselected`)4167 } else {4168 console.log(`Fail ${recordlevel}is not deselected`)4169 }4170 }4171 ////browser.saveScreenshot();4172 break4173 case 'web':4174 // web operation4175 break;4176 default: break4177 }4178 } catch (e) {4179 console.error(`Cannot fetch contentful data: ${e}`);4180 return assert.strictEqual(platform, '', e);4181 }4182});4183Then(/^I should see verify "([^"]*)" screen$/, async function (object) {4184 try {4185 switch (platform) {4186 case "android":4187 const myElem = $(fileutils.readPropertyFile(platform, object));4188 myElem.waitForVisible(90000);4189 browser.waitForExit(fileutils.readPropertyFile(platform, object), 19000);4190 let exists = browser.waitUntil(function () {4191 return browser.element(fileutils.readPropertyFile(platform, object)).isVisible()4192 }, timeOutinMs, 'Element not found');4193 if (exists) {4194 console.log(object + ' is displayed');4195 }4196 break;4197 case "ios":4198 browser.pause(2000);4199 let exists1 = browser.waitUntil(function () {4200 return browser.element(fileutils.readPropertyFile(platform, object)).isVisible()4201 }, timeOutinMs, 'Element not found');4202 if (exists1) {4203 console.log(object + ' is displayed');4204 }4205 break;4206 case "web":4207 // web operation4208 break4209 }4210 } catch (e) {4211 console.error(object + ' is not displayed');4212 //browser.saveScreenshot();4213 return assert.strictEqual(platform, '', e);4214 }4215});4216Then(/^I Verify "([^"]*)" option$/, async function (object) {4217 try {4218 switch (platform) {4219 case "android":4220 expect(browser.element(fileutils.readPropertyFile(platform, object)).isExisting);4221 console.log(object + ' is visible');4222 ////browser.saveScreenshot();4223 break;4224 case "ios":4225 let value = '5 minutes before';4226 let value1 = '15 minutes before';4227 let value2 = '30 minutes before';4228 let value3 = '1 hour before';4229 let value4 = '2 hours before';4230 let value5 = 'None';4231 for (let i = 0; i <= 5; i++) {4232 if (i === 0) {4233 // browser.pause(4000);4234 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value);4235 console.log(value + ' is found');4236 }4237 else if (i === 1) {4238 // browser.pause(4000);4239 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value1);4240 console.log(value1 + ' is found');4241 }4242 else if (i === 2) {4243 // browser.pause(4000);4244 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value2);4245 console.log(value2 + ' is found');4246 }4247 else if (i === 3) {4248 // browser.pause(4000);4249 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value3);4250 //browser.pause(1000);4251 console.log(value3 + ' is found');4252 }4253 else if (i === 4) {4254 // browser.pause(4000);4255 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value4);4256 // browser.pause(1000);4257 console.log(value4 + ' is found');4258 }4259 else if (i === 5) {4260 // browser.pause(4000);4261 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), value5);4262 // browser.pause(4000);4263 console.log(value5 + ' is found');4264 }4265 else {4266 console.log(object + ' is not found');4267 }4268 }4269 break;4270 case "web":4271 // perform operation on web element4272 break;4273 }4274 } catch (e) {4275 console.error(' Cannot find ' + object);4276 //browser.saveScreenshot();4277 return assert.strictEqual(platform, '', e);4278 }4279});4280Then(/^I enter "([^"]*)" character in "([^"]*)" field$/, async function (value, object) {4281 try {4282 switch (platform) {4283 case "android":4284 if (value === '12') {4285 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', '12'));4286 }4287 else if (value === '13') {4288 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', '13'));4289 }4290 else if (value === '34') {4291 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', '34'));4292 }4293 else {4294 console.log('no data found');4295 }4296 ////browser.saveScreenshot();4297 break;4298 case "ios":4299 if (value === '12') {4300 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', '12'));4301 }4302 else if (value === '34') {4303 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', '34'));4304 }4305 else {4306 console.log('no data found');4307 }4308 ////browser.saveScreenshot();4309 break;4310 case "web":4311 // web operation4312 break4313 }4314 } catch (e) {4315 console.error(object + ' is not displayed');4316 //browser.saveScreenshot();4317 return assert.strictEqual(platform, '', e);4318 }4319});4320Then(/^I should see "([^"]*)" alertmessage$/, async function (action) {4321 try {4322 switch (platform) {4323 case "android":4324 if (action === 'alert') {4325 const alerText = browser.alertText();4326 ////browser.saveScreenshot();4327 console.log(alerText);4328 }4329 else {4330 console.log('no alerText');4331 }4332 break;4333 case "ios":4334 $(fileutils.readPropertyFile(platform, object)).isVisible();4335 ////browser.saveScreenshot();4336 break;4337 case "web":4338 // web operation4339 break4340 }4341 } catch (e) {4342 console.error(action + ' is not displayed');4343 //browser.saveScreenshot();4344 return assert.strictEqual(platform, '', e);4345 }4346});4347Then(/^I enter "([^"]*)" Code of "([^"]*)" character in "([^"]*)" field$/, async function (type, value, object) {4348 try {4349 switch (platform) {4350 case "android":4351 if (type === 'valid') {4352 if (value === '13') {4353 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_13'));4354 }4355 else if (value === '33') {4356 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_33'));4357 }4358 else if (value === '20') {4359 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_20'));4360 }4361 else if (value === '25') {4362 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_25'));4363 }4364 }4365 else if (type === 'invalid') {4366 if (value === '13') {4367 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid_13'));4368 }4369 else if (value === '33') {4370 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid_33'));4371 }4372 else if (value === '20') {4373 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid_20'));4374 }4375 else if (value === '25') {4376 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid_25'));4377 }4378 }4379 else {4380 console.log('no data found');4381 }4382 ////browser.saveScreenshot();4383 break;4384 case "ios":4385 if (type === 'valid') {4386 if (value === 13) {4387 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_13'));4388 }4389 else if (value === 33) {4390 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_33'));4391 }4392 else if (value === 20) {4393 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'valid_20'));4394 }4395 }4396 else if (type === 'invalid') {4397 if (value === 13) {4398 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid_13'));4399 }4400 else if (value === 33) {4401 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid-33'));4402 }4403 else if (value === 20) {4404 $(fileutils.readPropertyFile(platform, object)).setValue(fileutils.readPropertyFile('data', 'invalid-20'));4405 }4406 }4407 ////browser.saveScreenshot();4408 break;4409 case "web":4410 // web operation4411 break4412 }4413 } catch (e) {4414 console.error(object + ' is not displayed');4415 //browser.saveScreenshot();4416 return assert.strictEqual(platform, '', e);4417 }4418});4419Then(/^I should see "([^"]*)" field does not accept the 34th character$/, async function (object) {4420 try {4421 switch (platform) {4422 case "android":4423 let element = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute('text').length;4424 console.log(element);4425 if (element < 34) {4426 console.log('text field length is less than 34');4427 }4428 else {4429 console.log('text field length is more than 34');4430 }4431 break;4432 case "ios":4433 let element1 = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute('value').length;4434 console.log(element1);4435 if (element1 < 34) {4436 console.log('text field length is less than 34');4437 }4438 else {4439 console.log('text field length is more than 34');4440 }4441 break;4442 case "web":4443 // web operation4444 break4445 }4446 } catch (e) {4447 console.error(object + ' is not displayed');4448 //browser.saveScreenshot();4449 return assert.strictEqual(platform, '', e);4450 }4451});4452Then(/^I Verify "([^"]*)" text$/, async function (object) {4453 try {4454 switch (platform) {4455 case "android":4456 let text1 = browser.element(fileutils.readPropertyFile(platform, object)).getText();4457 let value1 = `${fileutils.readPropertyFile("Android_text", object)}`;4458 // browser.pause(1000);4459 console.log(`${'Text to be Displayed : '}${value1}`);4460 console.log(`${'Text Displayed is : '}${text1}`);4461 if (text1 === value1) {4462 console.log(`${object} ${'Text Displayed is verified'}`);4463 }4464 else {4465 console.error(`${object} ${'Text Displayed is incorrect'}`)4466 }4467 ////browser.saveScreenshot();4468 break;4469 case "ios":4470 let text = browser.element(fileutils.readPropertyFile(platform, object)).getText();4471 let value = `${fileutils.readPropertyFile("iOS_text", object)}`;4472 // browser.pause(1000);4473 console.log(`${'Text to be Displayed : '}${value}`);4474 console.log(`${'Text Displayed is : '}${text}`);4475 if (text === value) {4476 console.log(`${object} ${'Text Displayed is verified'}`);4477 }4478 else {4479 console.error(`${object} ${'Text Displayed is incorrect'}`)4480 }4481 ////browser.saveScreenshot();4482 break;4483 case "web":4484 // perform operation on web element4485 break;4486 }4487 } catch (e) {4488 console.error(' Cannot find ' + object);4489 //browser.saveScreenshot();4490 return assert.strictEqual(platform, '', e);4491 }4492});4493Then(/^I should see "([^"]*)" (?:selected|Deselected)$/, async function (object) {4494 try {4495 switch (platform) {4496 case "android":4497 expect(browser.element(fileutils.readPropertyFile(platform, object)).isExisting);4498 let checker1 = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute("checked")4499 console.log(object + ' is visible');4500 if (checker1 == 'true') {4501 console.log(object + ' is Selected');4502 }4503 else {4504 console.log(object + ' is not Selected');4505 }4506 ////browser.saveScreenshot();4507 break;4508 case "ios":4509 expect(browser.element(fileutils.readPropertyFile(platform, object)).isExisting);4510 let checker = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute("value")4511 if (checker == 1) {4512 console.log(object + ' is Selected');4513 }4514 else {4515 console.log(object + ' is not Selected');4516 }4517 break;4518 case "web":4519 // perform operation on web element4520 break;4521 }4522 } catch (e) {4523 console.error(' Cannot find ' + object);4524 //browser.saveScreenshot();4525 return assert.strictEqual(platform, '', e);4526 }4527});4528Then(/^I verify elements in picker$/, async function () {4529 try {4530 switch (platform) {4531 case "android":4532 expect(browser.element(fileutils.readPropertyFile(platform, object)).isExisting);4533 console.log(object + ' is visible');4534 console.log("Value" + browser.element(fileutils.readPropertyFile(platform, object)).getAttribute("value"))4535 ////browser.saveScreenshot();4536 break;4537 case "ios":4538 browser.execute('mobile: selectPickerWheelValue', { direction: 'down' })4539 break;4540 case "web":4541 // perform operation on web element4542 break;4543 }4544 } catch (e) {4545 console.error(' Cannot find ' + object);4546 //browser.saveScreenshot();4547 return assert.strictEqual(platform, '', e);4548 }4549});4550Then(/^I verify "([^"]*)" option in "([^"]*)" picker wheel$/, async function (value, object) {4551 try {4552 switch (platform) {4553 case "android":4554 expect(browser.element(fileutils.readPropertyFile(platform, object)).isExisting);4555 console.log(object + ' is visible');4556 ////browser.saveScreenshot();4557 break;4558 case "ios":4559 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, object), fileutils.readPropertyFile("data", value));4560 let selectedPicker = browser.element(fileutils.readPropertyFile(platform, object)).getText();4561 let Pickervalue = `${fileutils.readPropertyFile("data", value)}`4562 if (selectedPicker == Pickervalue) {4563 console.log(value + " is present in " + object + " picker wheel");4564 }4565 else {4566 console.log(value + " is not present");4567 }4568 break;4569 case "web":4570 // perform operation on web element4571 break;4572 }4573 } catch (e) {4574 console.error(' Cannot find ' + object);4575 //browser.saveScreenshot();4576 return assert.strictEqual(platform, '', e);4577 }4578});4579Then(/^I should see Cancel button$/, async () => {4580 try {4581 switch (platform) {4582 case 'android':4583 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'Cancel')}`).isVisible(), timeOutinMs, 'Element not found');4584 console.log(object, 'screen is displayed');4585 ////browser.saveScreenshot();4586 break;4587 case 'ios':4588 const exists = browser.waitUntil(() => browser.element('~ Cancel').isVisible(), timeOutinMs, 'Element not found');4589 if (exists) {4590 console.log('cancel is displayed')4591 }4592 else {4593 console.error('cancel is not displayed')4594 }4595 break;4596 case 'web':4597 // web operation4598 break;4599 default: break4600 }4601 } catch (e) {4602 console.error("Cannot See Cancel button" + e);4603 //browser.saveScreenshot();4604 return assert.strictEqual(platform, '', e);4605 }4606});4607Then(/^I wait for "([^"]*)" minutes$/, async (value) => {4608 try {4609 let val = parseInt(value);4610 var val1 = val * 60 * 1000;4611 console.log('wait');4612 browser.pause(val1);4613 // browser.timeoutsImplicitWait(val1);4614 console.log('wait');4615 } catch (e) {4616 console.error(`Cannot wait ${e}`);4617 return assert.strictEqual(platform, '', e);4618 }4619});4620Then(/^I login "([^"]*)" times$/, async (minutes) => {4621 try {4622 switch (platform) {4623 case 'android':4624 for (var i = 0; i < minutes; i++) {4625 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');4626 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();4627 console.log(`Clicked on Login ${i+1} time/s`);4628 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).isVisible(), timeOutinMs, 'Element not found');4629 browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).click();4630 console.log(`Clicked on Okay ${i+1} time/s`);4631 }4632 break;4633case 'ios' :4634 for (var i = 0; i < minutes; i++) {4635 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');4636 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();4637 console.log(`Clicked on Login ${i+1} time/s`);4638 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).isVisible(), timeOutinMs, 'Element not found');4639 browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).click();4640 console.log(`Clicked on Okay ${i+1} time/s`);4641 }4642 break;4643 }4644 } catch (e) {4645 console.error('Cannot Login '+minutes +' times', e);4646 return assert.strictEqual(platform, '', e);4647 }4648})4649Then(/^I login 20 times$/, async () => {4650 try {4651 switch (platform) {4652 case 'android':4653 for (var i = 0; i < 20; i++) {4654 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');4655 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();4656 console.log(`Clicked on Login ${i} time/s`);4657 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).isVisible(), timeOutinMs, 'Element not found');4658 browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).click();4659 console.log(`Clicked on Okay ${i} time/s`);4660 }4661 break;4662case 'ios' :4663 for (var i = 0; i < 20; i++) {4664 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');4665 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();4666 console.log(`Clicked on Login ${i} time/s`);4667 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).isVisible(), timeOutinMs, 'Element not found');4668 browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).click();4669 console.log(`Clicked on Okay ${i} time/s`);4670 }4671 break;4672 }4673 } catch (e) {4674 console.error('Cannot Login 20 times', e);4675 return assert.strictEqual(platform, '', e);4676 }4677});4678Then(/^I handle Cancel button$/, async () => {4679 try {4680 switch (platform) {4681 case 'android':4682 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'cancel')}`).click(), timeOutinMs, 'Element not found');4683 if (exists) {4684 console.log(`Clicked on ${object}`);4685 ////browser.saveScreenshot();4686 }4687 break;4688 case 'ios':4689 browser.waitUntil(() => browser.element('~ Cancel').isVisible(), timeOutinMs, 'Element not found');4690 browser.element('~ Cancel').click();4691 console.log('Clicked on Cancel')4692 break;4693 case 'web':4694 // web operation4695 break;4696 default: break4697 }4698 } catch (e) {4699 console.error("Cannot Handle Cancel Button " + e);4700 //browser.saveScreenshot();4701 return assert.strictEqual(platform, '', e);4702 }4703});4704Then(/^I click on Proceed button$/, async () => {4705 try {4706 switch (platform) {4707 case 'android':4708 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'proceed')}`).click(), timeOutinMs, 'Element not found');4709 if (exists) {4710 console.log(`Clicked on ${object}`);4711 ////browser.saveScreenshot();4712 }4713 break;4714 case 'ios':4715 browser.waitUntil(() => browser.element('~Proceed').isVisible(), timeOutinMs, 'Element not found');4716 browser.element('~Proceed').click();4717 console.log('Clicked on Proceed')4718 break;4719 case 'web':4720 // web operation4721 break;4722 default: break4723 }4724 } catch (e) {4725 console.error("Cannot Handle Proceed Button" + e);4726 //browser.saveScreenshot();4727 return assert.strictEqual(platform, '', e);4728 }4729});4730Then(/^I should see Proceed button$/, async () => {4731 try {4732 switch (platform) {4733 case 'android':4734 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'proceed')}`).isVisible(), timeOutinMs, 'Element not found');4735 console.log(object, 'screen is displayed');4736 ////browser.saveScreenshot();4737 break;4738 case 'ios':4739 const exists = browser.waitUntil(() => browser.element('~Proceed').isVisible(), timeOutinMs, 'Element not found');4740 if (exists) {4741 console.log('proceed is displayed')4742 }4743 else {4744 console.error('proceed is not displayed')4745 }4746 break;4747 case 'web':4748 // web operation4749 break;4750 default: break4751 }4752 } catch (e) {4753 console.error("Cannot see Proceed Button" + e);4754 //browser.saveScreenshot();4755 return assert.strictEqual(platform, '', e);4756 }4757});4758// added for resend forget password verfication4759Then(/^I should connect to email for resend forgot password verification$/, async () => {4760 try {4761 const emailwait = await emailUtilsforforgotpassword.readforresendforgotpassword();4762 return emailwait;4763 } catch (e) {4764 console.error('Cannot open mailbox', e);4765 return assert.strictEqual(platform, '', e);4766 }4767});4768Then(/^I handle Remember me toggle button$/, async () => {4769 try {4770 switch (platform) {4771 case 'android':4772 try {4773 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "remember.me.toggle.off")}`).isVisible(), timeOutinMs, 'Element not found');4774 if (exists1) {4775 4776 browser.element(`${fileutils.readPropertyFile(platform, "remember.me.toggle.off")}`).click();4777 4778 console.log("remember me toggle button enabled")4779 4780 }4781 4782 }catch (e) {4783 console.log("Already remember me toggle button enabled")4784 }4785 4786 break;4787 ////////4788 4789 case 'ios':4790 browser.pause(3000);4791 if (browser.element(fileutils.readPropertyFile(platform, 'remember.me.toggle.on')).isVisible()) {4792 browser.element(fileutils.readPropertyFile(platform, 'remember.me.toggle.on')).click();4793 console.log('Remember me toggle button is disabled');4794 }4795 // else if (browser.element(fileutils.readPropertyFile(platform, 'remember.me.toggle.on')).isVisible()) {4796 // browser.element(fileutils.readPropertyFile(platform, 'remember.me.toggle.on')).click();4797 // console.log('Remember me toggle button is disabled');4798 // }4799 else{4800 console.log('Remember me toggle button is already disabled');4801 }4802 4803 break;4804 case 'web':4805 // web operation4806 break;4807 default: break4808 }4809 } catch (e) {4810 console.error(`Toggle button is not found`);4811 //browser.saveScreenshot();4812 return assert.strictEqual(platform, '', e);4813 }4814});4815Then(/^I handle Notification pop-up$/, async () => {4816 try {4817 switch (platform) {4818 case 'android':4819 browser.pause(3000);4820 try {4821 let exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'tempo.notifications')).isVisible(), timeOutinMs, 'Element not found');4822 if (exists1) {4823 console.log(browser.getText(fileutils.readPropertyFile(platform, 'tempo.notifications')));4824 browser.element(fileutils.readPropertyFile(platform, 'allow')).click();4825 console.log('Notifications Popup Handled');4826 }4827 }4828 catch (e) {4829 console.error('No pop-up');4830 }4831 break;4832 case 'ios':4833 browser.pause(3000);4834 try {4835 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'tempo.notifications')).isVisible(), timeOutinMs, 'Element not found');4836 if (exists) {4837 console.log(browser.getText(fileutils.readPropertyFile(platform, 'tempo.notifications')));4838 browser.element(fileutils.readPropertyFile(platform, 'allow')).click();4839 console.log('Notifications Popup Handled');4840 }4841 }4842 catch (e) {4843 console.error('No pop-up');4844 }4845 break;4846 case 'web':4847 // web operation4848 break;4849 default: break4850 }4851 } catch (e) {4852 console.error(`pop-up is not found`);4853 //browser.saveScreenshot();4854 return assert.strictEqual(platform, '', e);4855 }4856});4857Then(/^I handle login pop-up$/, async () => {4858 try {4859 switch (platform) {4860 case 'android':4861 browser.pause(3000);4862 if (browser.element(fileutils.readPropertyFile(platform, 'warning')).isVisible()) {4863 console.log(browser.getText(fileutils.readPropertyFile(platform, 'warning')));4864 browser.element('~ Proceed ').click();4865 console.log('One device at a time pop-up handled');4866 }4867 else if (browser.element(fileutils.readPropertyFile(platform, 'warning.login')).isVisible()) {4868 console.log(browser.getText(fileutils.readPropertyFile(platform, 'warning.login')));4869 browser.element('~ Proceed ').click();4870 console.log('Logging in as a different user pop-up handled');4871 }4872 else {4873 console.log('No pop-up');4874 }4875 break;4876 case 'ios':4877 browser.pause(3000);4878 try {4879 if (browser.element(fileutils.readPropertyFile(platform, 'warning')).isVisible()) {4880 console.log(browser.getText(fileutils.readPropertyFile(platform, 'warning')));4881 browser.element('~ Proceed ').click();4882 console.log('One device at a time pop-up handled');4883 }4884 else if (browser.element(fileutils.readPropertyFile(platform, 'warning.login')).isVisible()) {4885 console.log(browser.getText(fileutils.readPropertyFile(platform, 'warning.login')));4886 browser.element('~ Proceed ').click();4887 console.log('Logging in as a different user pop-up handled');4888 }4889 }4890 catch (e) {4891 console.log('No pop-up');4892 }4893 break;4894 case 'web':4895 // web operation4896 break;4897 default: break4898 }4899 } catch (e) {4900 console.error(`pop-up is not found`);4901 //browser.saveScreenshot();4902 return assert.strictEqual(platform, '', e);4903 }4904});4905Then(/^I Verify "([^"]*)" text in more menu$/, async function (object) {4906 try {4907 switch (platform) {4908 case "android":4909 let text1 = browser.element(fileutils.readPropertyFile(platform, object)).getText();4910 //console.log(text1);4911 let element = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute('text');4912 if (text1 === element) {4913 console.log(text1 + ' is displayed');4914 }4915 console.log(object + ' is visible');4916 ////browser.saveScreenshot();4917 break;4918 case "ios":4919 let text = browser.element(fileutils.readPropertyFile(platform, object)).getAttribute("name");4920 let value = `${fileutils.readPropertyFile("iOS_text", object)}`;4921 console.log(`${'Text to be Displayed : '}${value}`);4922 console.log(`${'Text Displayed is : '}${text}`);4923 if (text === value) {4924 console.log(`${object} ${'Text Displayed is verified'}`);4925 }4926 else {4927 console.log(`${object} ${'Text Displayed is incorrect'}`)4928 }4929 break;4930 case "web":4931 // perform operation on web element4932 break;4933 }4934 } catch (e) {4935 console.error(' Cannot find ' + object);4936 //browser.saveScreenshot();4937 return assert.strictEqual(platform, '', e);4938 }4939});4940Then(/^I should see "([^"]*)" and "([^"]*)" in "([^"]*)"$/, async (value1, value2, object) => {4941 try {4942 switch (platform) {4943 case 'android':4944 let fieldvalue = fileutils.readPropertyFile(platform, object);4945 const value1data = fileutils.readPropertyFile("data", value1);4946 const value2data = fileutils.readPropertyFile("data", value2);4947 const fieldtext = browser.element(fieldvalue).getText();4948 const valuedata = value1data + " " + value2data4949 console.log(fieldtext);4950 if (fieldtext == valuedata) {4951 console.log("The value displayed is matched: " + fieldtext);4952 }4953 else {4954 console.log("The value displayed is not matched: " + fieldtext);4955 }4956 break;4957 case 'ios':4958 let fieldvalue1 = fileutils.readPropertyFile(platform, object);4959 const value1data1 = fileutils.readPropertyFile("data", value1);4960 const value2data1 = fileutils.readPropertyFile("data", value2);4961 const fieldtext1 = browser.element(fieldvalue1).getText();4962 const valuedata1 = value1data1 + " " + value2data14963 console.log(fieldtext1);4964 if (fieldtext1 == valuedata1) {4965 console.log("The value displayed is matched: " + fieldtext1);4966 }4967 else {4968 console.log("The value displayed is not matched: " + fieldtext1);4969 }4970 break;4971 }4972 } catch (e) {4973 console.error(`Cannot Find: ${e}`);4974 return assert.strictEqual(platform, '', e);4975 }4976});4977Then(/^I set "([^"]*)" time in device settings$/, async (value) => {4978 try {4979 switch (platform) {4980 case "android":4981 break;4982 case "ios":4983 mobileactions.mobileScroll('up')4984 let search = browser.element(`${fileutils.readPropertyFile(platform, 'Settings.Search')}`)4985 search.click();4986 search.setValue("Date & Time");4987 browser.element("~Date & Time").click();4988 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "Settings.set.automatically")}`).isVisible(), timeOutinMs, 'Error: Element not found');4989 if (exists) {4990 let value = browser.element(fileutils.readPropertyFile(platform, "Settings.set.automatically")).getAttribute('value')4991 // console.log(value)4992 if (value == 1) {4993 browser.element(fileutils.readPropertyFile(platform, "Settings.set.automatically")).click();4994 console.log("Disabled Set Automatically Button")4995 }4996 else {4997 console.log('Set Automatically Button already disabled');4998 }4999 }5000 try {5001 browser.element(fileutils.readPropertyFile(platform, "Setting.time")).click();5002 browser.pause(500);5003 console.log(value.split(':')[0])5004 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "Settings.minute"), value.split(':')[0]);5005 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "Settings.hour"), value.split(':')[1]);5006 browser.element(fileutils.readPropertyFile(platform, "Settings.general")).click();5007 }5008 catch (e) {5009 console.log(e);5010 }5011 // }5012 break;5013 case "web":5014 break;5015 }5016 } catch (e) {5017 console.error('Cannot set Device Timings', e);5018 //browser.saveScreenshot();5019 return assert.strictEqual(platform, '', e);5020 }5021});5022Then(/^I change device time as "([^"]*)" "([^"]*)" and "([^"]*)"$/, async (value1, value2, value3) => {5023 try {5024 switch (platform) {5025 case 'android':5026 break;5027 case "ios":5028 try {5029 let hour = `${fileutils.readPropertyFile('data', value1)}`;5030 let min = `${fileutils.readPropertyFile('data', value2)}`;5031 let amorpm = `${fileutils.readPropertyFile('data', value3)}`;5032 const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];5033 let current_datetime = new Date()5034 let formatted_date = current_datetime.getDate() + "-" + months[current_datetime.getMonth()] + "-" + current_datetime.getFullYear()5035 console.log(formatted_date)5036 browser.execute('mobile: launchApp', { bundleId: settingsApp });5037 mobileactions.swipeDown(0.40);5038 browser.pause(1000);5039 if (browser.element(fileutils.readPropertyFile(platform, "Setting.General")).isVisible()) {5040 browser.element(fileutils.readPropertyFile(platform, "Setting.General")).click();5041 mobileactions.swipeDown(0.85);5042 }5043 if (browser.element(fileutils.readPropertyFile(platform, "Settings.Date.Time")).isVisible()) {5044 browser.element(fileutils.readPropertyFile(platform, "Settings.Date.Time")).click();5045 }5046 else {5047 console.error('date & time is not visible');5048 }5049 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "Settings.Set.Automatically")}`).isVisible(), timeOutinMs, 'Error: Element not found');5050 if (exists) {5051 let value1 = browser.element(fileutils.readPropertyFile(platform, "Settings.Set.Automatically")).getAttribute('value')5052 console.log(value1)5053 if (value1 == 1) {5054 browser.element(fileutils.readPropertyFile(platform, "Settings.Set.Automatically")).click();5055 }5056 else {5057 console.log("ready to change")5058 }5059 let xpath = fileutils.readPropertyFile(platform, 'Time.layout').replace('25-Aug-2019', formatted_date)5060 console.log(xpath);5061 browser.element(xpath).click();5062 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "Settings.Hour"), hour);5063 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "Settings.Min"), min);5064 mobileElementAction.selectValueFromPicker(fileutils.readPropertyFile(platform, "Setting.AM.PM"), amorpm);5065 }5066 browser.execute('mobile: activateApp', { bundleId: bundleid });5067 browser.pause(3000);5068 }5069 //}5070 catch (e) {5071 console.error('Cannot set Device format', e);5072 ////browser.saveScreenshot();5073 }5074 break;5075 case "web":5076 break;5077 }5078 } catch (e) {5079 console.error('Cannot set Device Timings', e);5080 //browser.saveScreenshot();5081 return assert.strictEqual(platform, '', e);5082 }5083});5084Then(/^I handle Continue with this device button$/, async () => {5085 try {5086 switch (platform) {5087 case 'android':5088 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'Continue with this device')}`).click(), timeOutinMs, 'Element not found');5089 if (exists) {5090 console.log(`Clicked on ${object}`);5091 ////browser.saveScreenshot();5092 }5093 break;5094 case 'ios':5095 browser.waitUntil(() => browser.element(('~ Continue with this device ')).isVisible(), timeOutinMs, 'Element not found');5096 browser.element('~ Continue with this device ').click();5097 console.log('Clicked on Continue with this device')5098 break;5099 case 'web':5100 // web operation5101 break;5102 default: break5103 }5104 } catch (e) {5105 console.error(e);5106 //browser.saveScreenshot();5107 return assert.strictEqual(platform, '', e);5108 }5109});5110Then(/^I should see Continue with this device button$/, async () => {5111 try {5112 switch (platform) {5113 case 'android':5114 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'Continue with this device')}`).isVisible(), timeOutinMs, 'Element not found');5115 console.log(object, 'screen is displayed');5116 ////browser.saveScreenshot();5117 break;5118 case 'ios':5119 const exists = browser.waitUntil(() => browser.element('~ Continue with this device ').isVisible(), timeOutinMs, 'Element not found');5120 // " Continue with this device "5121 if (exists) {5122 console.log('continue with this button is displayed')5123 }5124 else {5125 console.error('continue with this button not displayed')5126 }5127 break;5128 case 'web':5129 // web operation5130 break;5131 default: break5132 }5133 } catch (e) {5134 console.error(e);5135 //browser.saveScreenshot();5136 return assert.strictEqual(platform, '', e);5137 }5138});5139Then(/^I login multiple times$/, async () => {5140 try {5141 switch (platform) {5142 case 'android':5143 for (var i = 0; i < 50; i++) {5144 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');5145 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();5146 console.log(`Clicked on Login ${i} time/s`);5147 if (browser.element(fileutils.readPropertyFile(platform, 'account.locked')).isVisible()) {5148 browser.element(fileutils.readPropertyFile(platform, 'okay.button')).click();5149 console.log(`Clicked on ok`);5150 break;5151 }5152 // if (exists) {5153 // browser.element(`${fileutils.readPropertyFile(platform, 'okay')}`).click();5154 // break;5155 // }5156 else{5157 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).isVisible(), timeOutinMs, 'Element not found');5158 browser.element(`${fileutils.readPropertyFile(platform, 'okay.button')}`).click();5159 console.log(`Clicked on Okay ${i} time/s`);5160 }5161 5162 }5163 break;5164case 'ios' :5165 for (var i = 0; i < 50; i++) {5166 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).isVisible(), timeOutinMs, 'Element not found');5167 browser.element(`${fileutils.readPropertyFile(platform, 'login')}`).click();5168 console.log(`Clicked on Login ${i} time/s`);5169 //const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'account.locked')}`).isVisible());5170 if (browser.element(fileutils.readPropertyFile(platform, 'account.locked')).isVisible()) {5171 browser.element(fileutils.readPropertyFile(platform, 'ok')).click();5172 console.log(`Clicked on ok`);5173 break;5174 }5175 // if (exists) {5176 // browser.element(`${fileutils.readPropertyFile(platform, 'okay')}`).click();5177 // break;5178 // }5179 else{5180 browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).isVisible(), timeOutinMs, 'Element not found');5181 browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).click();5182 console.log(`Clicked on Okay ${i} time/s`);5183 }5184 }5185 break;5186 }5187 } catch (e) {5188 console.error('Cannot Login multiple times', e);5189 return assert.strictEqual(platform, '', e);5190 }5191});5192Then(/^I handle time zone popup$/, async () => {5193 try {5194 switch (platform) {5195 case 'android':5196 5197 case 'ios':5198 try {5199 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'ok')).isVisible(), timeOutinMs, 'Element not found');5200 if (exists) {5201 console.log(browser.getText(fileutils.readPropertyFile(platform, 'ok')));5202 browser.element(fileutils.readPropertyFile(platform, 'ok')).click();5203 console.log('Clicked on time zone Pop-up');5204 }5205 }5206 catch (e) {5207 console.error('No pop-up');5208 }5209 // browser.pause(3000);5210 // if5211 // (browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).isVisible(), timeOutinMs, 'Element not found')){;5212 // browser.element(`${fileutils.readPropertyFile(platform, 'ok')}`).click();5213 // console.log('Clicked on time zone Pop-up');5214 // }5215 // if (browser.element("~ OK, I Understand ").isVisible()) {5216 // browser.element("~ OK, I Understand ").click();5217 // console.log('Clicked on time zone Pop-up');5218 // }5219 // else {5220 // console.log('Pop-up not displayed');5221 // }5222 break;5223 case 'web':5224 // web operation5225 break;5226 default: break5227 }5228 } catch (e) {5229 console.error(`Time zone popup is not found`);5230 //browser.saveScreenshot();5231 return assert.strictEqual(platform, '', e);5232 }5233});5234Then(/^I should see "([^"]*)" (?:text|screen|option|pop-up|icon|overlay) in English$/, async (value) => {5235 try {5236 switch (platform) {5237 case 'android':5238 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, value)}`).isVisible(), timeOutinMs, 'Element not found');5239 if (exists) {5240 let text1 = browser.element(fileutils.readPropertyFile(platform, value)).getText();5241 let value1 = `${fileutils.readPropertyFile("Android_text", value)}`;5242 console.log(`${'Text to be Displayed : '}${value1}`);5243 console.log(`${'Text Displayed is : '}${text1}`);5244 if (text1 === value1) {5245 console.log(`${value} ${'Text Displayed is verified'}`);5246 }5247 else {5248 console.error(`${value} ${'Text Displayed is incorrect'}`)5249 }5250 5251 // console.log(isEnglish(text1))5252 // var val = lngDetector.detect(text1,15)5253 if (isEnglish(text1)) {5254 console.log(`${value} ${'is Displayed in English'}`);5255 }5256 else {5257 console.error(`${value} ${'is not Displayed in English'}`)5258 }5259 }5260 break;5261 case 'ios':5262 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, value)}`).isVisible(), timeOutinMs, 'Element not found');5263 if (exists1) {5264 let text1 = browser.element(fileutils.readPropertyFile(platform, value)).getAttribute("name");5265 let value1 = `${fileutils.readPropertyFile("iOS_text", value)}`;5266 console.log(`${'Text to be Displayed : '}${value1}`);5267 console.log(`${'Text Displayed is : '}${text1}`);5268 if (text1 === value1) {5269 console.log(`${value} ${'Text Displayed is verified'}`);5270 }5271 else {5272 console.error(`${value} ${'Text Displayed is incorrect'}`)5273 }5274 5275 // console.log(isEnglish(text1))5276 // var val = lngDetector.detect(text1,15)5277 if (isEnglish(text1)) {5278 console.log(`${value} ${'is Displayed in English'}`);5279 }5280 else {5281 console.error(`${value} ${'is not Displayed in English'}`)5282 }5283 }5284 break;5285 case 'web':5286 // web operation5287 break;5288 default: break5289 }5290 } catch (e) {5291 console.error(`Text Not English`);5292 //browser.saveScreenshot();5293 return assert.strictEqual(platform, '', e);5294 }5295});5296Then(/^I should see "([^"]*)" in English$/, async (value) => {5297 try {5298 switch (platform) {5299 case 'android':5300 const exists = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, value)}`).isVisible(), timeOutinMs, 'Element not found');5301 if (exists) {5302 let text1 = browser.element(fileutils.readPropertyFile(platform, value)).getText();5303 let value1 = `${fileutils.readPropertyFile("Android_text", value)}`;5304 console.log(`${'Text to be Displayed : '}${value1}`);5305 console.log(`${'Text Displayed is : '}${text1}`);5306 if (text1 === value1) {5307 console.log(`${value} ${'Text Displayed is verified'}`);5308 }5309 else {5310 console.error(`${value} ${'Text Displayed is incorrect'}`)5311 }5312 5313 // console.log(isEnglish(text1))5314 // var val = lngDetector.detect(text1,15)5315 if (isEnglish(text1)) {5316 console.log(`${value} ${'is Displayed in English'}`);5317 }5318 else {5319 console.error(`${value} ${'is not Displayed in English'}`)5320 }5321 }5322 break;5323 case 'ios':5324 const exists1 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, value)}`).isVisible(), timeOutinMs, 'Element not found');5325 if (exists1) {5326 let text1 = browser.element(fileutils.readPropertyFile(platform, value)).getText();5327 let value1 = `${fileutils.readPropertyFile("iOS_text", value)}`;5328 console.log(`${'Text to be Displayed : '}${value1}`);5329 console.log(`${'Text Displayed is : '}${text1}`);5330 if (text1 === value1) {5331 console.log(`${value} ${'Text Displayed is verified'}`);5332 }5333 else {5334 console.error(`${value} ${'Text Displayed is incorrect'}`)5335 }5336 5337 // console.log(isEnglish(text1))5338 // var val = lngDetector.detect(text1,15)5339 if (isEnglish(text1)) {5340 console.log(`${value} ${'is Displayed in English'}`);5341 }5342 else {5343 console.error(`${value} ${'is not Displayed in English'}`)5344 }5345 }5346 break;5347 case 'web':5348 // web operation5349 break;5350 default: break5351 }5352 } catch (e) {5353 console.error(`Text Not English`);5354 //browser.saveScreenshot();5355 return assert.strictEqual(platform, '', e);5356 }5357});5358Then(/^I handle Bluetooth Notification pop-up$/, async () => {5359 try {5360 switch (platform) {5361 case 'android':5362 browser.pause(3000);5363 try {5364 const exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification.popup')).isVisible(), timeOutinMs, 'Element not found');5365 if (exists1) {5366 console.log(browser.getText(fileutils.readPropertyFile(platform, 'bluetooth.notification.popup')));5367 browser.element(fileutils.readPropertyFile(platform, 'enable.bluetooth.popup')).click();5368 const exists2 = browser.waitUntil(() => browser.element(`${fileutils.readPropertyFile(platform, "turn.on.bluetooth.popup")}`).isVisible(), timeOutinMs, 'Element not found');5369 if (exists2) {5370 console.log(browser.getText(fileutils.readPropertyFile(platform, 'turn.on.bluetooth.popup')));5371 browser.element(fileutils.readPropertyFile(platform, 'bluetooth.allow')).click();5372 browser.pause(10000);5373 console.log('Bluetooth Notifications Popup Handled');5374 }5375 }5376 }5377 catch (e) {5378 console.error('No Bluetooth Notifications Popup');5379 }5380 break;5381 case 'ios':5382 browser.pause(3000);5383 try {5384 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification')).isVisible(), timeOutinMs, 'Element not found');5385 if (exists) {5386 console.log(browser.getText(fileutils.readPropertyFile(platform, 'bluetooth.notification')));5387 browser.element(fileutils.readPropertyFile(platform, 'bluetooth.ok')).click();5388 console.log('Bluetooth Notifications Popup Handled');5389 }5390 }5391 catch (e) {5392 console.error('No pop-up');5393 }5394 break;5395 case 'web':5396 // web operation5397 break;5398 default: break5399 }5400 } catch (e) {5401 console.error(`pop-up is not found`);5402 //browser.saveScreenshot();5403 return assert.strictEqual(platform, '', e);5404 }5405});5406Then(/^I disable Bluetooth Notification pop-up$/, async () => {5407 try {5408 switch (platform) {5409 case 'android':5410 browser.pause(3000);5411 try {5412 const exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification.popup')).isVisible(), timeOutinMs, 'Element not found');5413 if (exists1) {5414 browser.element(fileutils.readPropertyFile(platform, 'not.now.bluetooth.popup')).click();5415 console.log('Bluetooth Notifications Disabled');5416 }5417 }5418 catch (e) {5419 console.error('No Bluetooth Notifications Popup');5420 }5421 break;5422 case 'ios':5423 browser.pause(3000);5424 try {5425 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification')).isVisible(), timeOutinMs, 'Element not found');5426 if (exists) {5427 console.log(browser.getText(fileutils.readPropertyFile(platform, 'bluetooth.notification')));5428 browser.element(fileutils.readPropertyFile(platform, 'bluetooth.dont.allow')).click();5429 console.log('Bluetooth Notifications Disabled');5430 }5431 }5432 catch (e) {5433 console.error('No pop-up');5434 }5435 break;5436 case 'web':5437 // web operation5438 break;5439 default: break5440 }5441 } catch (e) {5442 console.error(`pop-up is not found`);5443 //browser.saveScreenshot();5444 return assert.strictEqual(platform, '', e);5445 }5446});5447Then(/^I wait for "([^"]*)" seconds$/, async (value) => {5448 try {5449 let val3 = parseInt(value);5450 var val4 = val3 * 1000;5451 console.log('wait');5452 browser.pause(val4);5453 console.log('wait');5454 } catch (e) {5455 console.error(`Cannot wait ${e}`);5456 return assert.strictEqual(platform, '', e);5457 }5458});5459Then(/^I handle turn on bluetooth pop-up$/, async () => {5460 try {5461 switch (platform) {5462 case 'android':5463 browser.pause(3000);5464 try {5465 let exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification')).isVisible(), timeOutinMs, 'Element not found');5466 if (exists1) {5467 console.log(browser.getText(fileutils.readPropertyFile(platform, 'bluetooth.notification')));5468 browser.element(fileutils.readPropertyFile(platform, 'bluetooth.ok')).click();5469 console.log('Notifications Popup Handled');5470 }5471 }5472 catch (e) {5473 console.error('No pop-up');5474 }5475 break;5476 case 'ios':5477 browser.pause(3000);5478 try {5479 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'turnon.your.bluetooth')).isVisible(), timeOutinMs, 'Element not found');5480 if (exists) {5481 console.log(browser.getText(fileutils.readPropertyFile(platform, 'turnon.your.bluetooth')));5482 browser.element(fileutils.readPropertyFile(platform, 'not.now.button')).click();5483 console.log('Turn on Bluetooth Popup Handled');5484 }5485 }5486 catch (e) {5487 console.error('No pop-up');5488 }5489 break;5490 case 'web':5491 // web operation5492 break;5493 default: break5494 }5495 } catch (e) {5496 console.error(`pop-up is not found`);5497 //browser.saveScreenshot();5498 return assert.strictEqual(platform, '', e);5499 }5500});5501Then(/^I handle Connect Your Devices pop-up$/, async () => {5502 try {5503 switch (platform) {5504 case 'android':5505 browser.pause(3000);5506 try {5507 const exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'connect.your.device.popup')).isVisible(), timeOutinMs, 'Element not found');5508 if (exists1) {5509 console.log(browser.getText(fileutils.readPropertyFile(platform, 'connect.your.device.popup')));5510 browser.element(fileutils.readPropertyFile(platform, 'connect.device.not.now')).click();5511 browser.pause(2000);5512 console.log('Connect Your Devices Popup Handled');5513 }5514 }5515 catch (e) {5516 console.error('No Connect Your Devices Popup');5517 }5518 break;5519 case 'ios':5520 // Yet to be implemented5521 break;5522 case 'web':5523 // web operation5524 break;5525 default: break5526 }5527 } catch (e) {5528 console.error(`pop-up is not found`);5529 //browser.saveScreenshot();5530 return assert.strictEqual(platform, '', e);5531 }5532});5533Then(/^I handle auto logged entries popup$/, async () => {5534 try {5535 switch (platform) {5536 case 'android':5537 // browser.pause(3000);5538 // try {5539 // let exists1 = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'bluetooth.notification')).isVisible(), timeOutinMs, 'Element not found');5540 // if (exists1) {5541 // console.log(browser.getText(fileutils.readPropertyFile(platform, 'bluetooth.notification')));5542 // browser.element(fileutils.readPropertyFile(platform, 'bluetooth.ok')).click();5543 // console.log('Notifications Popup Handled');5544 // }5545 // }5546 // catch (e) {5547 // console.error('No pop-up');5548 // }5549 break;5550 case 'ios':5551 browser.pause(3000);5552 try {5553 let exists = browser.waitUntil(() => browser.element(fileutils.readPropertyFile(platform, 'auto.logged.entries')).isVisible(), timeOutinMs, 'Element not found');5554 if (exists) {5555 console.log(browser.getText(fileutils.readPropertyFile(platform, 'auto.logged.entries')));5556 browser.element(fileutils.readPropertyFile(platform, 'ok')).click();5557 console.log('ok button Handled');5558 }5559 }5560 catch (e) {5561 console.error('No ok button');5562 }5563 break;5564 case 'web':5565 // web operation5566 break;5567 default: break5568 }5569 } catch (e) {5570 console.error(`ok is not found`);5571 //browser.saveScreenshot();5572 return assert.strictEqual(platform, '', e);5573 }5574});5575Then(/^I wait "([^"]*)" minutes$/, async (value) => {5576 try {5577 let val = parseInt(value);5578 var val1 = val * 60 * 1000;5579 console.log('wait');5580 browser.timeoutsImplicitWait(val1);5581 //browser.setTimeout({ 'implicit': val1 })5582 console.log('wait');5583 } catch (e) {5584 console.error(`Cannot wait ${e}`);5585 return assert.strictEqual(platform, '', e);...

Full Screen

Full Screen

story-steps.spec.js

Source:story-steps.spec.js Github

copy

Full Screen

1var expect = require('chai').expect;2var getStorySteps = require('../../src/scripts/story-steps');3describe('screener-storybook/src/scripts/story-steps', function() {4 describe('getStorySteps', function() {5 it('should remove invalid kind format from storybook array', function() {6 var storybookData = [7 'kind',8 {9 kind: '',10 stories: [{}]11 },12 {13 kind: 'Component1'14 },15 {16 kind: 'Component2',17 stories: []18 },19 ];20 var result = getStorySteps(storybookData);21 expect(result).to.deep.equal([]);22 });23 it('should remove invalid story format from storybook array', function() {24 var storybookData = [25 {26 kind: 'Component1',27 stories: ['story']28 },29 {30 kind: 'Component2',31 stories: [{}]32 },33 ];34 var result = getStorySteps(storybookData);35 expect(result).to.deep.equal([36 {37 kind: 'Component1',38 stories: []39 },40 {41 kind: 'Component2',42 stories: []43 }44 ]);45 });46 it('should extract steps from React storybook array', function() {47 var storybookData = [48 {49 kind: 'Component1',50 stories: [51 {52 name: 'default',53 render: function() {54 return {55 props: {56 isScreenerComponent: true,57 steps: [58 {59 type: 'clickElement'60 },61 {62 type: 'saveScreenshot'63 }64 ]65 }66 };67 }68 }69 ]70 }71 ];72 var result = getStorySteps(storybookData);73 expect(result).to.deep.equal([74 {75 kind: 'Component1',76 stories: [77 {78 name: 'default',79 steps: [80 {81 type: 'clickElement'82 },83 {84 type: 'saveScreenshot',85 }86 ]87 }88 ]89 }90 ]);91 });92 it('should extract steps from React props with story function', function() {93 var storybookData = [94 {95 kind: 'Component1',96 stories: [97 {98 name: 'default',99 render: function() {100 return {101 props: {102 story: function() {103 return {104 props: {105 isScreenerComponent: true,106 steps: [107 {108 type: 'clickElement'109 },110 {111 type: 'saveScreenshot'112 }113 ]114 }115 };116 }117 }118 };119 }120 }121 ]122 }123 ];124 var result = getStorySteps(storybookData);125 expect(result).to.deep.equal([126 {127 kind: 'Component1',128 stories: [129 {130 name: 'default',131 steps: [132 {133 type: 'clickElement'134 },135 {136 type: 'saveScreenshot',137 }138 ]139 }140 ]141 }142 ]);143 });144 it('should extract steps from React props with storyFn function', function() {145 var storybookData = [146 {147 kind: 'Component1',148 stories: [149 {150 name: 'default',151 render: function() {152 return {153 props: {154 storyFn: function() {155 return {156 props: {157 isScreenerComponent: true,158 steps: [159 {160 type: 'clickElement'161 },162 {163 type: 'saveScreenshot'164 }165 ]166 }167 };168 }169 }170 };171 }172 }173 ]174 }175 ];176 var result = getStorySteps(storybookData);177 expect(result).to.deep.equal([178 {179 kind: 'Component1',180 stories: [181 {182 name: 'default',183 steps: [184 {185 type: 'clickElement'186 },187 {188 type: 'saveScreenshot',189 }190 ]191 }192 ]193 }194 ]);195 });196 it('should extract steps from React children with type function', function() {197 var storybookData = [198 {199 kind: 'Component1',200 stories: [201 {202 name: 'default',203 render: function() {204 return {205 props: {206 initialContent: {207 props: {208 children: {209 props: {},210 type: function() {211 return {212 props: {213 isScreenerComponent: true,214 steps: [215 {216 type: 'clickElement'217 },218 {219 type: 'saveScreenshot',220 }221 ]222 }223 };224 }225 }226 }227 }228 }229 };230 }231 }232 ]233 }234 ];235 var result = getStorySteps(storybookData);236 expect(result).to.deep.equal([237 {238 kind: 'Component1',239 stories: [240 {241 name: 'default',242 steps: [243 {244 type: 'clickElement'245 },246 {247 type: 'saveScreenshot',248 }249 ]250 }251 ]252 }253 ]);254 });255 it('should extract nested initialContent steps from React storybook array', function() {256 var storybookData = [257 {258 kind: 'Component1',259 stories: [260 {261 name: 'default',262 render: function() {263 return {264 props: {265 initialContent: {266 props: {267 children: {268 props: {269 isScreenerComponent: true,270 steps: [271 {272 type: 'clickElement'273 },274 {275 type: 'saveScreenshot',276 }277 ]278 }279 }280 }281 }282 }283 };284 }285 }286 ]287 }288 ];289 var result = getStorySteps(storybookData);290 expect(result).to.deep.equal([291 {292 kind: 'Component1',293 stories: [294 {295 name: 'default',296 steps: [297 {298 type: 'clickElement'299 },300 {301 type: 'saveScreenshot',302 }303 ]304 }305 ]306 }307 ]);308 });309 it('should extract multiple children steps from React storybook array', function() {310 var storybookData = [311 {312 kind: 'Component1',313 stories: [314 {315 name: 'default',316 render: function() {317 return {318 props: {319 children: [320 {props: {}},321 {322 props: {323 children: {324 props: {325 isScreenerComponent: true,326 steps: [327 {328 type: 'clickElement'329 },330 {331 type: 'saveScreenshot',332 }333 ]334 }335 }336 }337 }338 ]339 }340 };341 }342 }343 ]344 }345 ];346 var result = getStorySteps(storybookData);347 expect(result).to.deep.equal([348 {349 kind: 'Component1',350 stories: [351 {352 name: 'default',353 steps: [354 {355 type: 'clickElement'356 },357 {358 type: 'saveScreenshot',359 }360 ]361 }362 ]363 }364 ]);365 });366 it('should extract top-most steps from React storybook array', function() {367 var storybookData = [368 {369 kind: 'Component1',370 stories: [371 {372 name: 'default',373 render: function() {374 return {375 props: {376 children: {377 props: {378 isScreenerComponent: true,379 steps: [],380 children: {381 props: {382 isScreenerComponent: true,383 steps: [384 {385 type: 'clickElement'386 },387 {388 type: 'saveScreenshot',389 }390 ]391 }392 }393 }394 }395 }396 };397 }398 }399 ]400 }401 ];402 var result = getStorySteps(storybookData);403 expect(result).to.deep.equal([404 {405 kind: 'Component1',406 stories: [407 {408 name: 'default',409 steps: []410 }411 ]412 }413 ]);414 });415 it('should extract nested children steps from React storybook array', function() {416 var storybookData = [417 {418 kind: 'Component1',419 stories: [420 {421 name: 'default',422 render: function() {423 return {424 props: {425 children: {426 props: {427 children: {428 props: {429 isScreenerComponent: true,430 steps: [431 {432 type: 'clickElement'433 },434 {435 type: 'saveScreenshot',436 }437 ]438 }439 }440 }441 }442 }443 };444 }445 }446 ]447 }448 ];449 var result = getStorySteps(storybookData);450 expect(result).to.deep.equal([451 {452 kind: 'Component1',453 stories: [454 {455 name: 'default',456 steps: [457 {458 type: 'clickElement'459 },460 {461 type: 'saveScreenshot',462 }463 ]464 }465 ]466 }467 ]);468 });469 it('should extract steps from Vue or Angular storybook array', function() {470 var storybookData = [471 {472 kind: 'Component1',473 stories: [474 {475 name: 'default',476 render: function() {477 return {478 steps: [479 {480 type: 'clickElement'481 },482 {483 type: 'saveScreenshot',484 }485 ]486 };487 }488 }489 ]490 }491 ];492 var result = getStorySteps(storybookData);493 expect(result).to.deep.equal([494 {495 kind: 'Component1',496 stories: [497 {498 name: 'default',499 steps: [500 {501 type: 'clickElement'502 },503 {504 type: 'saveScreenshot',505 }506 ]507 }508 ]509 }510 ]);511 });512 it('should extract steps from Vue decorator with render method', function() {513 var storybookData = [514 {515 kind: 'Component1',516 stories: [517 {518 name: 'default',519 render: function() {520 return {521 render: function(fn) {522 fn();523 return {524 steps: [525 {526 type: 'clickElement'527 },528 {529 type: 'saveScreenshot',530 }531 ]532 };533 }534 };535 }536 }537 ]538 }539 ];540 var result = getStorySteps(storybookData);541 expect(result).to.deep.equal([542 {543 kind: 'Component1',544 stories: [545 {546 name: 'default',547 steps: [548 {549 type: 'clickElement'550 },551 {552 type: 'saveScreenshot',553 }554 ]555 }556 ]557 }558 ]);559 });560 it('should extract steps from Vue decorator with components.story', function() {561 var storybookData = [562 {563 kind: 'Component1',564 stories: [565 {566 name: 'default',567 render: function() {568 return {569 components: {570 story: {571 render: function(fn) {572 fn();573 return {574 steps: [575 {576 type: 'clickElement'577 },578 {579 type: 'saveScreenshot',580 }581 ]582 };583 }584 }585 }586 };587 }588 }589 ]590 }591 ];592 var result = getStorySteps(storybookData);593 expect(result).to.deep.equal([594 {595 kind: 'Component1',596 stories: [597 {598 name: 'default',599 steps: [600 {601 type: 'clickElement'602 },603 {604 type: 'saveScreenshot',605 }606 ]607 }608 ]609 }610 ]);611 });612 it('should handle exceptions when executing render method', function() {613 var storybookData = [614 {615 kind: 'Component1',616 stories: [617 {618 name: 'default',619 render: function() {620 throw new Error('this is a test');621 }622 }623 ]624 }625 ];626 var result = getStorySteps(storybookData);627 expect(result).to.deep.equal([628 {629 kind: 'Component1',630 stories: [631 {632 name: 'default'633 }634 ]635 }636 ]);637 });638 });...

Full Screen

Full Screen

screenshot.js

Source:screenshot.js Github

copy

Full Screen

...13 var bn = browser.globals.browser_name;14 browser15 .url(baseurl + 'animation1' + extHtml)16 .waitForElementPresent(classDone, timeout, 'animation1')17 .saveScreenshot(screenshotPath + bn + '/' + 'animation1' + extImage)18 .url(baseurl + 'animation2' + extHtml)19 .waitForElementPresent(classDone, timeout, 'animation2')20 .saveScreenshot(screenshotPath + bn + '/' + 'animation2' + extImage)21 .url(baseurl + 'arrowKeys' + extHtml)22 .waitForElementPresent(classDone, timeout, 'arrowKeys')23 .saveScreenshot(screenshotPath + bn + '/' + 'arrowKeys' + extImage)24 .url(baseurl + 'autoHeight' + extHtml)25 .waitForElementPresent(classDone, timeout, 'autoHeight')26 .saveScreenshot(screenshotPath + bn + '/' + 'autoHeight' + extImage)27 .url(baseurl + 'autoplay' + extHtml)28 .waitForElementPresent(classDone, timeout, 'autoplay')29 .saveScreenshot(screenshotPath + bn + '/' + 'autoplay' + extImage)30 .url(baseurl + 'base' + extHtml)31 .waitForElementPresent(classDone, timeout, 'base')32 .saveScreenshot(screenshotPath + bn + '/' + 'base' + extImage)33 .url(baseurl + 'center-non-loop' + extHtml)34 .waitForElementPresent(classDone, timeout, 'center-non-loop')35 .saveScreenshot(screenshotPath + bn + '/' + 'center-non-loop' + extImage)36 .url(baseurl + 'center-loop' + extHtml)37 .waitForElementPresent(classDone, timeout, 'center-loop')38 .saveScreenshot(screenshotPath + bn + '/' + 'center-loop' + extImage)39 .url(baseurl + 'center-fixedWidth-non-loop' + extHtml)40 .waitForElementPresent(classDone, timeout, 'center-fixedWidth-non-loop')41 .saveScreenshot(screenshotPath + bn + '/' + 'center-fixedWidth-non-loop' + extImage)42 .url(baseurl + 'center-fixedWidth-loop' + extHtml)43 .waitForElementPresent(classDone, timeout, 'center-fixedWidth-loop')44 .saveScreenshot(screenshotPath + bn + '/' + 'center-fixedWidth-loop' + extImage)45 .url(baseurl + 'center-autoWidth-non-loop' + extHtml)46 .waitForElementPresent(classDone, timeout, 'center-autoWidth-non-loop')47 .saveScreenshot(screenshotPath + bn + '/' + 'center-autoWidth-non-loop' + extImage)48 .url(baseurl + 'center-autoWidth-loop' + extHtml)49 .waitForElementPresent(classDone, timeout, 'center-autoWidth-loop')50 .saveScreenshot(screenshotPath + bn + '/' + 'center-autoWidth-loop' + extImage)51 .url(baseurl + 'center-autoWidth-non-loop-edgePadding' + extHtml)52 .waitForElementPresent(classDone, timeout, 'center-autoWidth-non-loop-edgePadding')53 .saveScreenshot(screenshotPath + bn + '/' + 'center-autoWidth-non-loop-edgePadding' + extImage)54 .url(baseurl + 'center-autoWidth-loop-edgePadding' + extHtml)55 .waitForElementPresent(classDone, timeout, 'center-autoWidth-loop-edgePadding')56 .saveScreenshot(screenshotPath + bn + '/' + 'center-autoWidth-loop-edgePadding' + extImage)57 .url(baseurl + 'center-lazyload-non-loop' + extHtml)58 .waitForElementPresent(classDone, timeout, 'center-lazyload-non-loop')59 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-non-loop' + extImage)60 .url(baseurl + 'center-lazyload-loop' + extHtml)61 .waitForElementPresent(classDone, timeout, 'center-lazyload-loop')62 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-loop' + extImage)63 .url(baseurl + 'center-lazyload-fixedWidth-non-loop' + extHtml)64 .waitForElementPresent(classDone, timeout, 'center-lazyload-fixedWidth-non-loop')65 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-fixedWidth-non-loop' + extImage)66 .url(baseurl + 'center-lazyload-fixedWidth-loop' + extHtml)67 .waitForElementPresent(classDone, timeout, 'center-lazyload-fixedWidth-loop')68 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-fixedWidth-loop' + extImage)69 .url(baseurl + 'center-lazyload-autoWidth-non-loop' + extHtml)70 .waitForElementPresent(classDone, timeout, 'center-lazyload-autoWidth-non-loop')71 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-autoWidth-non-loop' + extImage)72 .url(baseurl + 'center-lazyload-autoWidth-loop' + extHtml)73 .waitForElementPresent(classDone, timeout, 'center-lazyload-autoWidth-loop')74 .saveScreenshot(screenshotPath + bn + '/' + 'center-lazyload-autoWidth-loop' + extImage)75 .url(baseurl + 'customize' + extHtml)76 .waitForElementPresent(classDone, timeout, 'customize')77 .saveScreenshot(screenshotPath + bn + '/' + 'customize' + extImage)78 .url(baseurl + 'edgePadding-gutter' + extHtml)79 .waitForElementPresent(classDone, timeout, 'edgePadding-gutter')80 .saveScreenshot(screenshotPath + bn + '/' + 'edgePadding-gutter' + extImage)81 .url(baseurl + 'edgePadding' + extHtml)82 .waitForElementPresent(classDone, timeout, 'edgePadding')83 .saveScreenshot(screenshotPath + bn + '/' + 'edgePadding' + extImage)84 .url(baseurl + 'few-items' + extHtml)85 .waitForElementPresent(classDone, timeout, 'few-items')86 .saveScreenshot(screenshotPath + bn + '/' + 'few-items' + extImage)87 .url(baseurl + 'fixedWidth-edgePadding-gutter' + extHtml)88 .waitForElementPresent(classDone, timeout, 'fixedWidth-edgePadding-gutter')89 .saveScreenshot(screenshotPath + bn + '/' + 'fixedWidth-edgePadding-gutter' + extImage)90 .url(baseurl + 'fixedWidth-edgePadding' + extHtml)91 .waitForElementPresent(classDone, timeout, 'fixedWidth-edgePadding')92 .saveScreenshot(screenshotPath + bn + '/' + 'fixedWidth-edgePadding' + extImage)93 .url(baseurl + 'fixedWidth-gutter' + extHtml)94 .waitForElementPresent(classDone, timeout, 'fixedWidth-gutter')95 .saveScreenshot(screenshotPath + bn + '/' + 'fixedWidth-gutter' + extImage)96 .url(baseurl + 'fixedWidth' + extHtml)97 .waitForElementPresent(classDone, timeout, 'fixedWidth')98 .saveScreenshot(screenshotPath + bn + '/' + 'fixedWidth' + extImage)99 .url(baseurl + 'frame1' + extHtml)100 .waitForElementPresent(classDone, timeout, 'frame1')101 .saveScreenshot(screenshotPath + bn + '/' + 'frame1' + extImage)102 .url(baseurl + 'frame2' + extHtml)103 .waitForElementPresent(classDone, timeout, 'frame2')104 .saveScreenshot(screenshotPath + bn + '/' + 'frame2' + extImage)105 .url(baseurl + 'frame3' + extHtml)106 .waitForElementPresent(classDone, timeout, 'frame3')107 .saveScreenshot(screenshotPath + bn + '/' + 'frame3' + extImage)108 // .url(baseurl + 'frame4' + extHtml)109 // .waitForElementPresent(classDone, timeout, false, function(e){ console.log('frametable+ee); }, 'frame4')110 // .saveScreenshot(screenshotPath + bn + '/' + 'frame4' + extImage)111 .url(baseurl + 'frame5' + extHtml)112 .waitForElementPresent(classDone, timeout, 'frame5')113 .saveScreenshot(screenshotPath + bn + '/' + 'frame5' + extImage)114 .url(baseurl + 'frame6' + extHtml)115 .waitForElementPresent(classDone, timeout, 'frame6')116 .saveScreenshot(screenshotPath + bn + '/' + 'frame6' + extImage)117 .url(baseurl + 'gutter' + extHtml)118 .waitForElementPresent(classDone, timeout, 'gutter')119 .saveScreenshot(screenshotPath + bn + '/' + 'gutter' + extImage)120 .url(baseurl + 'lazyload' + extHtml)121 .waitForElementPresent(classDone, timeout, 'lazyload')122 .saveScreenshot(screenshotPath + bn + '/' + 'lazyload' + extImage)123 // .url(baseurl + 'mouse-drag' + extHtml)124 // .waitForElementPresent(classDone, timeout, 'mouse-drag')125 // .saveScreenshot(screenshotPath + bn + '/' + 'mouse-drag' + extImage)126 .url(baseurl + 'nested' + extHtml)127 .waitForElementPresent(classDone, timeout, 'nested')128 .saveScreenshot(screenshotPath + bn + '/' + 'nested' + extImage)129 .url(baseurl + 'non-loop' + extHtml)130 .waitForElementPresent(classDone, timeout, 'non-loop')131 .saveScreenshot(screenshotPath + bn + '/' + 'non-loop' + extImage)132 .url(baseurl + 'rewind' + extHtml)133 .waitForElementPresent(classDone, timeout, 'rewind')134 .saveScreenshot(screenshotPath + bn + '/' + 'rewind' + extImage)135 .url(baseurl + 'slide-by-page' + extHtml)136 .waitForElementPresent(classDone, timeout, 'slide-by-page')137 .saveScreenshot(screenshotPath + bn + '/' + 'slide-by-page' + extImage)138 .url(baseurl + 'vertical-edgePadding-gutter' + extHtml)139 .waitForElementPresent(classDone, timeout, 'vertical-edgePadding-gutter')140 .saveScreenshot(screenshotPath + bn + '/' + 'vertical-edgePadding-gutter' + extImage)141 .url(baseurl + 'vertical-edgePadding' + extHtml)142 .waitForElementPresent(classDone, timeout, 'vertical-edgePadding')143 .saveScreenshot(screenshotPath + bn + '/' + 'vertical-edgePadding' + extImage)144 .url(baseurl + 'vertical-gutter' + extHtml)145 .waitForElementPresent(classDone, timeout, 'vertical-gutter')146 .saveScreenshot(screenshotPath + bn + '/' + 'vertical-gutter' + extImage)147 .url(baseurl + 'vertical' + extHtml)148 .waitForElementPresent(classDone, timeout, 'vertical')149 .saveScreenshot(screenshotPath + bn + '/' + 'vertical' + extImage)150 .url(baseurl + 'start-index' + extHtml)151 .waitForElementPresent(classDone, timeout, 'start-index')152 .saveScreenshot(screenshotPath + bn + '/' + 'start-index' + extImage)153 .end();...

Full Screen

Full Screen

render_tests.js

Source:render_tests.js Github

copy

Full Screen

...20 I.mockEndpoint(Endpoints.getFolder(8), 'emptyTrash');21 I.amOnPage('/products/files');22 I.wait(5);23 I.see('My documents');24 I.saveScreenshot(`1.row-default-my-documents-tab.png`);25 if (!isModel) {26 I.seeVisualDiff(`1.row-default-my-documents-tab.png`, {27 tolerance: 3,28 prepareBaseImage: false,29 });30 }31 if (deviceType !== 'mobile') {32 I.switchView('tile');33 I.saveScreenshot(`1.tile-default-my-documents-tab.png`);34 if (!isModel) {35 I.seeVisualDiff(`1.tile-default-my-documents-tab.png`, {36 tolerance: 3,37 prepareBaseImage: false,38 });39 }40 }41 if (deviceType !== 'desktop') I.openArticle();42 I.click('Shared with me');43 I.wait(2);44 I.see('Shared with me');45 I.saveScreenshot(`2.empty-shared-with-me-tab.png`);46 if (!isModel) {47 I.seeVisualDiff(`2.empty-shared-with-me-tab.png`, {48 tolerance: 3,49 prepareBaseImage: false,50 });51 }52 if (deviceType !== 'desktop') I.openArticle();53 I.click('Favorites');54 I.wait(2);55 I.see('Favorites');56 I.saveScreenshot(`3.empty-favorites-tab.png`);57 if (!isModel) {58 I.seeVisualDiff(`3.empty-favorites-tab.png`, {59 tolerance: 3,60 prepareBaseImage: false,61 });62 }63 if (deviceType !== 'desktop') I.openArticle();64 I.click('Recent');65 I.wait(2);66 I.see('Recent');67 I.saveScreenshot(`4.empty-recent-tab.png`);68 if (!isModel) {69 I.seeVisualDiff(`4.empty-recent-tab.png`, {70 tolerance: 3,71 prepareBaseImage: false,72 });73 }74 if (deviceType !== 'desktop') I.openArticle();75 I.click('Private Room');76 I.wait(2);77 I.see('Private Room');78 I.saveScreenshot(`5.empty-private-room-tab.png`);79 if (!isModel) {80 I.seeVisualDiff(`5.empty-private-room-tab.png`, {81 tolerance: 3,82 prepareBaseImage: false,83 });84 }85 if (deviceType !== 'desktop') I.openArticle();86 I.click('Common');87 I.wait(2);88 I.see('Common');89 I.saveScreenshot(`6.empty-common-tab.png`);90 if (!isModel) {91 I.seeVisualDiff(`6.empty-common-tab.png`, {92 tolerance: 3,93 prepareBaseImage: false,94 });95 }96 if (deviceType !== 'desktop') I.openArticle();97 I.click('Trash');98 I.wait(2);99 I.see('Trash');100 I.saveScreenshot(`7.empty-trash-tab.png`);101 if (!isModel) {102 I.seeVisualDiff(`7.empty-trash-tab.png`, {103 tolerance: 3,104 prepareBaseImage: false,105 });106 }107});108Scenario('Default settings render test', ({ I }) => {109 I.mockEndpoint(Endpoints.root, 'empty');110 I.mockEndpoint(Endpoints.my, 'default');111 I.amOnPage('/products/files');112 I.wait(5);113 if (deviceType !== 'desktop') I.openArticle();114 I.click({ react: 'ContextTreeNode', props: { eventKey: 'settings' } });115 I.see('Common settings');116 I.see('Admin settings');117 I.see('Connected clouds');118 I.click('Common settings');119 if (deviceType !== 'desktop') I.forceClick('.backdrop-active');120 I.see('Common settings');121 I.saveScreenshot(`8.default-common-settings-tab.png`);122 if (!isModel) {123 I.seeVisualDiff(`8.default-common-settings-tab.png`, {124 tolerance: 3,125 prepareBaseImage: false,126 });127 }128 if (deviceType !== 'desktop') I.openArticle();129 I.click('Admin settings');130 if (deviceType !== 'desktop') I.forceClick('.backdrop-active');131 I.see('Admin settings');132 I.saveScreenshot(`9.default-admin-settings-tab.png`);133 if (!isModel) {134 I.seeVisualDiff(`9.default-admin-settings-tab.png`, {135 tolerance: 3,136 prepareBaseImage: false,137 });138 }139 if (deviceType !== 'desktop') I.openArticle();140 I.click('Connected clouds');141 if (deviceType !== 'desktop') I.forceClick('.backdrop-active');142 I.see('Connected clouds');143 I.saveScreenshot(`10.default-connected-clouds-tab.png`);144 if (!isModel) {145 I.seeVisualDiff(`10.default-connected-clouds-tab.png`, {146 tolerance: 3,147 prepareBaseImage: false,148 });149 }150});151Scenario('Many documents and folders render test', ({ I }) => {152 I.mockEndpoint(Endpoints.root, 'one');153 I.mockEndpoint(Endpoints.my, 'many');154 I.mockEndpoint(Endpoints.getFolder(9), '9');155 I.mockEndpoint(Endpoints.getSubfolder(9), '9');156 I.amOnPage('/products/files');157 I.wait(5);158 I.click('New folder');159 I.see('New folder');160 I.saveScreenshot(`11.row-many-documents.png`);161 if (!isModel) {162 I.seeVisualDiff(`11.row-many-documents.png`, {163 tolerance: 3,164 prepareBaseImage: false,165 });166 }167 if (deviceType !== 'mobile') {168 I.switchView('tile');169 I.saveScreenshot(`11.tile-many-documents.png`);170 if (!isModel) {171 I.seeVisualDiff(`11.tile-many-documents.png`, {172 tolerance: 3,173 prepareBaseImage: false,174 });175 }176 }...

Full Screen

Full Screen

tags.test.js

Source:tags.test.js Github

copy

Full Screen

...5 describe('view', () => {6 it('should view tags', async () => {7 const testName = 'view-tags'8 const page = await puppeteer.createBrowser()9 await puppeteer.saveScreenshot(page, `${testName}-1.png`)10 const tagsButton = await puppeteer.getElement(page, 'Tags')11 await tagsButton.click()12 await puppeteer.saveScreenshot(page, `${testName}-2.png`)13 const content = await puppeteer.evaluate(page, () => document.querySelector('.pgn').innerHTML.trim())14 assert.strictEqual(true, content.startsWith('[Event "F/S Return Match"]'))15 await puppeteer.close(page)16 })17 it('should add tag', async () => {18 const testName = 'add-tag'19 const page = await puppeteer.createBrowser()20 await puppeteer.saveScreenshot(page, `${testName}-1.png`)21 const tagsButton = await puppeteer.getElement(page, 'Tags')22 await tagsButton.click()23 await puppeteer.saveScreenshot(page, `${testName}-2.png`)24 await page.evaluate(() => {25 document.querySelector('.new-tag-name').value = 'Test'26 document.querySelector('.new-tag-value').value = 'Test value'27 })28 await puppeteer.saveScreenshot(page, `${testName}-3.png`)29 const addTagButton = await puppeteer.getElement(page, '.add-tag-button')30 await addTagButton.click()31 await puppeteer.saveScreenshot(page, `${testName}-4.png`)32 const pgnButton = await puppeteer.getElement(page, 'PGN')33 await pgnButton.click()34 await puppeteer.saveScreenshot(page, `${testName}-5.png`)35 const content = await puppeteer.evaluate(page, () => document.querySelector('.pgn').innerHTML.trim())36 assert.strictEqual(true, content.indexOf('[Test "Test value"]') > -1)37 await puppeteer.close(page)38 })39 })40 describe('update', () => {41 it('should update tag', async () => {42 const testName = 'update-tag'43 const page = await puppeteer.createBrowser()44 await puppeteer.saveScreenshot(page, `${testName}-1.png`)45 const tagsButton = await puppeteer.getElement(page, 'Tags')46 await tagsButton.click()47 await puppeteer.saveScreenshot(page, `${testName}-2.png`)48 await page.evaluate(() => {49 const table = document.querySelector('.tags-table')50 table.rows[1].cells[0].firstChild.value = 'Test'51 table.rows[1].cells[1].firstChild.value = 'Test value'52 window.regeneratePGNHeader()53 })54 await puppeteer.saveScreenshot(page, `${testName}-3.png`)55 const pgnButton = await puppeteer.getElement(page, 'PGN')56 await pgnButton.click()57 await puppeteer.saveScreenshot(page, `${testName}-4.png`)58 const content = await puppeteer.evaluate(page, () => document.querySelector('.pgn').innerHTML.trim())59 assert.strictEqual(true, content.indexOf('[Test "Test value"]') > -1)60 await puppeteer.close(page)61 })62 })63 describe('delete', () => {64 it('should delete tag', async () => {65 const testName = 'delete-tag'66 const page = await puppeteer.createBrowser()67 await puppeteer.saveScreenshot(page, `${testName}-1.png`)68 const tagsButton = await puppeteer.getElement(page, 'Tags')69 await tagsButton.click()70 await puppeteer.saveScreenshot(page, `${testName}-2.png`)71 await page.evaluate(() => {72 const table = document.querySelector('.tags-table')73 table.rows[1].cells[2].firstChild.click()74 })75 await puppeteer.saveScreenshot(page, `${testName}-3.png`)76 const addTagButton = await puppeteer.getElement(page, '.add-tag-button')77 await addTagButton.click()78 await puppeteer.saveScreenshot(page, `${testName}-4.png`)79 const pgnButton = await puppeteer.getElement(page, 'PGN')80 await pgnButton.click()81 await puppeteer.saveScreenshot(page, `${testName}-5.png`)82 const content = await puppeteer.evaluate(page, () => document.querySelector('.pgn').innerHTML.trim())83 assert.strictEqual(true, content.indexOf('[Result "1/2-1/2"]') === -1)84 await puppeteer.close(page)85 })86 })...

Full Screen

Full Screen

login.js

Source:login.js Github

copy

Full Screen

...7 height: 7008 });9 let title = browser.getTitle()10 assert.equal(title, "Serverboards")11 browser.saveScreenshot("./shots/001-login.png")12 $("input[name=email]").waitForExist()13 $('input[name=email]').setValue("test@serverboards.io")14 $('input[name=password]').setValue("asdfasdf")15 $('button.login').click()16 browser.waitUntil(() => $('body').getText().includes("Start by creating your first project"))17 browser.saveScreenshot("./shots/002-logged-in.png")18 })19 it("Once logged in, can go to user profile", function(){20 browser.saveScreenshot("./shots/003-A.png")21 $("#top-menu #profile").waitForExist()22 browser.saveScreenshot("./shots/003-B.png")23 $("#profile").click()24 $("#top-menu #profile_menu #user").waitForVisible()25 browser.saveScreenshot("./shots/003-C.png")26 $('#top-menu #profile_menu #user').click()27 browser.saveScreenshot("./shots/003-profile.png")28 })29 it("Can navigate to top level sections, data is shown", function(){30 $('#top-menu #settings').click()31 browser.waitForText('.ui.top.header.secondary')32 browser.saveScreenshot("./shots/004-settings.png")33 assert( $('.ui.top.header.secondary').getText().includes("General information") )34 $('#top-menu #actions').click()35 browser.waitForText('.ui.top.menu.secondary')36 browser.saveScreenshot("./shots/005-processes.png")37 assert( $('.ui.top.menu.secondary').getText().includes("Process history") )38 $('#top-menu #notifications').click()39 browser.waitForText('.ui.top.menu.secondary')40 browser.saveScreenshot("./shots/006-notifications.png")41 assert( $('.ui.top.menu.secondary').getText().includes("All Notifications") )42 $('#top-menu #issues').click()43 browser.waitForText('.ui.top.menu.secondary')44 browser.saveScreenshot("./shots/007-issues.png")45 assert( $('.ui.top.menu.secondary').getText().includes("Issues") )46 $('#top-menu #projects').click()47 browser.waitForText('.ui.main.area .ui.container.centered')48 browser.saveScreenshot("./shots/008-projects.png")49 assert( $('.ui.main.area .ui.container.centered').getText().includes("This is how Serverboards works.") )50 })51 it("Logs out", function(){52 browser.saveScreenshot("./shots/009-A.png")53 $('#profile img').click()54 $('#profile_menu #logout').waitForExist()55 browser.saveScreenshot("./shots/009-B.png")56 $('#profile_menu #logout').click()57 $("input[name=email]").waitForExist()58 browser.saveScreenshot("./shots/009-logged-out.png")59 })...

Full Screen

Full Screen

leak.js

Source:leak.js Github

copy

Full Screen

...5 before(() => {6 browser.url('https://www.google.com/');7 browser.waitForExist('.RNNXgb', 20000);8 });9 it('dummyit1', () => { browser.saveScreenshot('pic'); });10 it('dummyit2', () => { browser.saveScreenshot('pic'); });11 it('dummyit3', () => { browser.saveScreenshot('pic'); });12 it('dummyit4', () => { browser.saveScreenshot('pic'); });13 it('dummyit5', () => { browser.saveScreenshot('pic'); });14 it('dummyit6', () => { browser.saveScreenshot('pic'); });15 it('dummyit7', () => { browser.saveScreenshot('pic'); });16 it('dummyit8', () => { browser.saveScreenshot('pic'); });17 it('dummyit9', () => { browser.saveScreenshot('pic'); });18 it('dummyit10', () => { browser.saveScreenshot('pic'); });19 it('dummyit11', () => { browser.saveScreenshot('pic'); });20 it('dummyit12', () => { browser.saveScreenshot('pic'); });21 it('dummyit13', () => { browser.saveScreenshot('pic'); });22 it('dummyit14', () => { browser.saveScreenshot('pic'); });23 it('dummyit15', () => { browser.saveScreenshot('pic'); });...

Full Screen

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 .saveScreenshot('google.png')9 .end();10var webdriverio = require('webdriverio');11var options = {12 desiredCapabilities: {13 }14};15 .remote(options)16 .init()17 .saveScreenshot('google.png', '#hplogo')18 .end();19var webdriverio = require('webdriverio');20var options = {21 desiredCapabilities: {22 }23};24 .remote(options)25 .init()26 .saveScreenshot('google.png', {27 })28 .end();29var webdriverio = require('webdriverio');30var options = {31 desiredCapabilities: {32 }33};

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var webdriverio = require('webdriverio');3var options = { desiredCapabilities: { browserName: 'chrome' } };4var client = webdriverio.remote(options);5.init()6.getTitle().then(function(title) {7 console.log('Title was: ' + title);8})9.saveScreenshot('google.png')10.end();11var fs = require('fs');12var webdriverio = require('webdriverio');13var options = { desiredCapabilities: { browserName: 'chrome' } };14var client = webdriverio.remote(options);15.init()16.getTitle().then(function(title) {17 console.log('Title was: ' + title);18})19.saveScreenshot('google.png')20.end();21var fs = require('fs');22var webdriverio = require('webdriverio');23var options = { desiredCapabilities: { browserName: 'chrome' } };24var client = webdriverio.remote(options);25.init()26.getTitle().then(function(title) {27 console.log('Title was: ' + title);28})29.saveScreenshot('google.png')30.end();31var fs = require('fs');32var webdriverio = require('webdriverio');33var options = { desiredCapabilities: { browserName: 'chrome' } };34var client = webdriverio.remote(options);35.init()36.getTitle().then(function(title) {37 console.log('Title was: ' + title);38})39.saveScreenshot('google.png')40.end();41var fs = require('fs');42var webdriverio = require('webdriverio');43var options = { desiredCapabilities: { browserName: 'chrome' } };44var client = webdriverio.remote(options);45.init()46.getTitle().then(function(title) {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 browser.saveScreenshot('screenshot.png');4 const title = browser.getTitle();5 expect(title).to.equal('WebdriverIO · Next-gen WebDriver test framework for Node.js');6 });7});8const path = require('path');9exports.config = {

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 .saveScreenshot('wdio.png')9 .end();10var webdriverio = require('webdriverio');11var options = {12 desiredCapabilities: {13 }14};15 .remote(options)16 .init()17 .saveElement('.docs-logo', 'wdio.png')18 .end();19var webdriverio = require('webdriverio');20var options = {21 desiredCapabilities: {22 }23};24 .remote(options)25 .init()26 .saveScreenshot('wdio.png', false)27 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.saveScreenshot('./screenshots/screenshot.png');2onComplete: function(exitCode, config, capabilities, results) {3 browser.saveScreenshot('./screenshots/screenshot.png');4}5afterTest: function(test, context, { error, result, duration, passed, retries }) {6 if (error) {7 browser.saveScreenshot('./screenshots/screenshot.png');8 }9}10afterStep: function (stepResult, context) {11 if (stepResult.status === 'failed') {12 browser.saveScreenshot('./screenshots/screenshot.png');13 }14}15after: function (test, context, { error, result, duration, passed, retries }) {16 if (error) {17 browser.saveScreenshot('./screenshots/screenshot.png');18 }19}20afterScenario: function (test, context, { error, result, duration, passed, retries }) {21 if (error) {22 browser.saveScreenshot('./screenshots/screenshot.png');23 }24}25afterFeature: function (test, context, { error, result, duration, passed, retries }) {26 if (error) {27 browser.saveScreenshot('./screenshots/screenshot.png');28 }29}30afterCommand: function (commandName, args, result, error) {31 if (error) {32 browser.saveScreenshot('./screenshots/screenshot.png');33 }34}35afterSuite: function (suite) {36 if (suite.error) {37 browser.saveScreenshot('./screenshots/screenshot.png');38 }39}40afterHook: function (test, context, { error, result, duration, passed, retries })

Full Screen

Using AI Code Generation

copy

Full Screen

1client.saveScreenshot('./screenshot.png');2client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {3 fs.writeFile('screenshot.png', screenshot, 'base64', function(err) {4 console.log(err);5 });6});7client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {8 fs.writeFile('screenshot.png', screenshot.value, 'base64', function(err) {9 console.log(err);10 });11});12client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {13 fs.writeFile('screenshot.png', new Buffer(screenshot.value, 'base64'), function(err) {14 console.log(err);15 });16});17client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {18 fs.writeFile('screenshot.png', new Buffer(screenshot.value, 'base64'), function(err) {19 console.log(err);20 });21});22client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {23 fs.writeFile('screenshot.png', new Buffer(screenshot.value, 'base64'), function(err) {24 console.log(err);25 });26});27client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {28 fs.writeFile('screenshot.png', new Buffer(screenshot.value, 'base64'), function(err) {29 console.log(err);30 });31});32client.saveScreenshot('./screenshot.png', function(err, screenshot, response) {33 fs.writeFile('screenshot.png', new Buffer(screenshot.value, 'base64'), function(err) {34 console.log(err);35 });36});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var webdrivercss = require('webdrivercss');3var options = {4 desiredCapabilities: {5 }6};7var client = webdriverio.remote(options);8webdrivercss.init(client);9 .init()10 .webdrivercss('google-homepage', [{11 }], function(err, res) {12 console.log(res.search[0].isWithinMisMatchTolerance);13 })14 .end();15### init(client, options)16webdrivercss.init(client, {17});18### webdrivercss(name, specs, callback)19 .webdrivercss('google-homepage', [{20 }], function(err, res) {21 console.log(res.search[0].isWithinMisMatchTolerance);22 })

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.saveScreenshot('./screenshot.png').then(function() {2 browser.saveScreenshot('./screenshot1.png').then(function() {3 browser.saveScreenshot('./screenshot2.png').then(function() {4 browser.saveScreenshot('./screenshot3.png').then(function() {5 browser.saveScreenshot('./screenshot4.png').then(function() {6 browser.saveScreenshot('./screenshot5.png').then(function() {7 browser.saveScreenshot('./screenshot6.png').then(function() {8 browser.saveScreenshot('./screenshot7.png').then(function() {9 browser.saveScreenshot('./screenshot8.png').then(function() {10 browser.saveScreenshot('./screenshot9.png').then(function() {11 browser.saveScreenshot('./screenshot10.png').then(function() {12 browser.saveScreenshot('./screenshot11.png').then(function() {13 browser.saveScreenshot('./screenshot12.png').then(function() {14 browser.saveScreenshot('./screenshot13.png').then(function() {

Full Screen

WebdriverIO Tutorial

Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.

Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.

Chapters

  1. Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?

  4. Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.

  5. How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.

  6. Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.

Run Webdriverio 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