Best JavaScript code snippet using taiko
CalendarVisual.spec.js
Source:CalendarVisual.spec.js
...14 function singleDaySelection(){15 // initial loading16 it("should load test page", function () {17 _initCalendar("1");18 expect(takeScreenshot(oCal)).toLookAs("000_initial_Rendering"); // January 2015 rendered, 2 selected, no focus19 });20 it("should select a date by click", function () {21 _pressDate(sCalId, "20150120"); // 20 selected an focused (2 unselected)22 expect(takeScreenshot(oCal)).toLookAs("001_press_date");23 });24 it("should select a date in other month by click to other month", function () {25 _pressDate(sCalId, "20141230"); // month says on January 2015, 20. January focused and 30. December selected26 expect(takeScreenshot(oCal)).toLookAs("002_press_date_other_month");27 });28 it("should show the previous month by click on prev-button", function () {29 _initCalendar("1");30 _pressPrev(sCalId); // December 2014 shown, 31 focus31 expect(takeScreenshot(oCal)).toLookAs("003_press_previous");32 });33 it("should show the next month by click on next-button", function () {34 _initCalendar("1");35 _pressNext(sCalId); // February 2015 shown, 1 focus36 expect(takeScreenshot(oCal)).toLookAs("004_press_next");37 });38 it("should handle the month picker", function () {39 _initCalendar("1");40 _pressMonthPicker(sCalId); // month picker opened, January selected and focused41 expect(takeScreenshot(oCal)).toLookAs("005_MonthPicker");42 _pressPrev(sCalId); // year changed to 201443 expect(takeScreenshot(oCal)).toLookAs("006_MonthPicker_Previous");44 _pressMonth(sCalId, "1"); // month picker closed, February 2014 shown, 2 focused45 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios") {46 browser.actions().mouseMove(element(by.css("#B1"))).perform();47 expect(takeScreenshot(oCal)).toLookAs("007_MonthPicker_Select");48 }49 });50 it("should handle the year picker", function () {51 _initCalendar("1");52 _pressYearPicker(sCalId); // year Picker shown, 2015 selected and focused53 expect(takeScreenshot(oCal)).toLookAs("008_YearPicker");54 _pressPrev(sCalId); // years changed to 1985-2004, 1995 focused55 expect(takeScreenshot(oCal)).toLookAs("009_YearPicker_Previous");56 _pressYear(sCalId, "1990"); // year picker closed, January 1990 shown, 2 focused57 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios") {58 browser.actions().mouseMove(element(by.css("#B1"))).perform();59 expect(takeScreenshot(oCal)).toLookAs("010_YearPicker_Select");60 }61 });62 keyboardTest();63 }64 function keyboardTest(){65 it("should handle keyboard navigation", function () {66 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios" && browser.testrunner.runtime.browserName != "safari") {67 // only on desktop and not in Safari (sendKeys needs an Element in Safari, so test makes no sense there)68 _initCalendar("1");69 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform(); // focus on 970 expect(takeScreenshot(oCal)).toLookAs("011_keyboard_Arrow_Down");71 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform(); // focus on 1072 expect(takeScreenshot(oCal)).toLookAs("012_keyboard_Arrow_Right");73 browser.actions().sendKeys(protractor.Key.ARROW_UP).perform(); // focus on 374 expect(takeScreenshot(oCal)).toLookAs("013_keyboard_Arrow_Up");75 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform(); // focus on 276 expect(takeScreenshot(oCal)).toLookAs("014_keyboard_Arrow_Left");77 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform(); // focus on 178 browser.actions().sendKeys(protractor.Key.ENTER).perform(); // 1 selected79 expect(takeScreenshot(oCal)).toLookAs("015_keyboard_Enter");80 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform(); // switch to December, focus on 3181 expect(takeScreenshot(oCal)).toLookAs("016_keyboard_Arrow_Left_other_Month");82 browser.actions().sendKeys(protractor.Key.SPACE).perform(); // 31 selected83 expect(takeScreenshot(oCal)).toLookAs("017_keyboard_Space");84 browser.actions().sendKeys(protractor.Key.PAGE_UP).perform(); // switch to November, focus on 3085 expect(takeScreenshot(oCal)).toLookAs("018_keyboard_PAGE_Up");86 browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform(); // switch to December, focus on 3087 expect(takeScreenshot(oCal)).toLookAs("019_keyboard_PABE_Down");88 browser.actions().sendKeys(protractor.Key.TAB).perform(); // focus on month89 expect(takeScreenshot(oCal)).toLookAs("020_keyboard_Tab1");90 browser.actions().sendKeys(protractor.Key.TAB).perform(); // focus on year91 expect(takeScreenshot(oCal)).toLookAs("021_keyboard_Tab2");92 browser.actions().sendKeys(protractor.Key.TAB).perform(); // focus leaves calendar93 expect(takeScreenshot(oCal)).toLookAs("022_keyboard_Tab3");94 var sShiftTab = protractor.Key.chord(protractor.Key.SHIFT, protractor.Key.TAB);95 browser.actions().sendKeys(sShiftTab).perform(); // focus on year96 expect(takeScreenshot(oCal)).toLookAs("023_keyboard_Shift_Tab1");97 if (browser.testrunner.runtime.browserName != "ie") {98 browser.actions().sendKeys(sShiftTab).perform(); // focus on month99 expect(takeScreenshot(oCal)).toLookAs("024_keyboard_Shift_Tab2");100 browser.actions().sendKeys(sShiftTab).perform(); // focus on 30101 expect(takeScreenshot(oCal)).toLookAs("025_keyboard_Shift_Tab3");102 } else {103 // shift+Tab don't work in selenium on IE on year and month button - So try to get to the December 30104 element(by.id("__page0-title")).click();105 browser.actions().sendKeys(protractor.Key.TAB).perform();106 }107 }108 }, iDefaultTimeout);109 it("should handle keyboard navigation for MonthPicker", function () {110 // MonthPicker111 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios" && browser.testrunner.runtime.browserName != "safari") {112 // only on desktop and not in Safari (sendKeys needs an Element in Safari, so test makes no sense there)113 browser.actions().sendKeys(protractor.Key.TAB).perform();114 browser.actions().sendKeys(protractor.Key.SPACE).perform(); // month picker open, focus on December115 expect(takeScreenshot(oCal)).toLookAs("026_keyboard_Month_Space");116 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform(); // focus on March 2015117 expect(takeScreenshot(oCal)).toLookAs("027_keyboard_MonthPicker_Arrow_Down");118 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform(); // focus on April 2015119 expect(takeScreenshot(oCal)).toLookAs("028_keyboard_MonthPicker_Arrow_Right");120 browser.actions().sendKeys(protractor.Key.SPACE).perform(); // Month Picker closed, April displayed, focus on 30121 expect(takeScreenshot(oCal)).toLookAs("029_keyboard_MonthPicker_Space");122 browser.actions().sendKeys(protractor.Key.TAB).perform();123 browser.actions().sendKeys(protractor.Key.ENTER).perform(); // month picker open, focus on April124 expect(takeScreenshot(oCal)).toLookAs("030_keyboard_MonthPicker_Enter");125 browser.actions().sendKeys(protractor.Key.ARROW_UP).perform(); // focus on January126 expect(takeScreenshot(oCal)).toLookAs("031_keyboard_MonthPicker_Arrow_UP");127 browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); // Month Picker closed, January displayed, focus on 30128 expect(takeScreenshot(oCal)).toLookAs("032_keyboard_MonthPicker_Escape");129 }130 }, iDefaultTimeout);131 it("should handle keyboard navigation for YearPicker", function () {132 // YearPicker133 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios" && browser.testrunner.runtime.browserName != "safari") {134 // only on desktop and not in Safari (sendKeys needs an Element in Safari, so test makes no sense there)135 browser.actions().sendKeys(protractor.Key.TAB).perform();136 browser.actions().sendKeys(protractor.Key.TAB).perform();137 browser.actions().sendKeys(protractor.Key.SPACE).perform(); // year Picker open, focus on 2015138 expect(takeScreenshot(oCal)).toLookAs("033_keyboard_Year_Space");139 browser.actions().sendKeys(protractor.Key.ARROW_UP).perform(); // focus on 2011140 expect(takeScreenshot(oCal)).toLookAs("034_keyboard_YearPicker_Arrow_UP");141 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform(); // focus on 2010142 expect(takeScreenshot(oCal)).toLookAs("035_keyboard_YearPicker_Arrow_Left");143 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform(); // focus on 2014144 expect(takeScreenshot(oCal)).toLookAs("036_keyboard_YearPicker_Arrow_Down");145 browser.actions().sendKeys(protractor.Key.PAGE_UP).perform(); // years changed, focus on 1994146 expect(takeScreenshot(oCal)).toLookAs("037_keyboard_YearPicker_Page_UP");147 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform(); // focus on 1995148 expect(takeScreenshot(oCal)).toLookAs("038_keyboard_YearPicker_Arrow_Right");149 browser.actions().sendKeys(protractor.Key.SPACE).perform(); // Year Picker closed, January 1995 displayed, focus on 30150 expect(takeScreenshot(oCal)).toLookAs("039_keyboard_YearPicker_Space");151 browser.actions().sendKeys(protractor.Key.TAB).perform();152 browser.actions().sendKeys(protractor.Key.TAB).perform();153 browser.actions().sendKeys(protractor.Key.ENTER).perform(); // year Picker open, focus on 1995 (selected)154 expect(takeScreenshot(oCal)).toLookAs("040_keyboard_Year_ENTER");155 browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform(); // years changed, focus on 2015156 expect(takeScreenshot(oCal)).toLookAs("041_keyboard_YearPicker_Page_DOWN");157 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform();158 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform(); // focus on 2017159 expect(takeScreenshot(oCal)).toLookAs("042_keyboard_YearPicker_Arrow_Right2");160 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform();161 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform(); // years changed, focus on 2025162 expect(takeScreenshot(oCal)).toLookAs("043_keyboard_YearPicker_Arrow_Down2");163 browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); // Year Picker closed, January 1995 displayed, focus on 30164 expect(takeScreenshot(oCal)).toLookAs("044_keyboard_YearPicker_Escape");165 _initCalendar("1");166 }167 });168 it("YearRangePicker looks OK", function() {169 _pressYearPicker(sCalId); // click the year button to open YearPicker170 _pressYearPicker(sCalId); // click the year button again to open YearRangePicker171 expect(takeScreenshot(oCal)).toLookAs("045_year_range_picker_displayed");172 });173 }174 function twoTypes(){175 it("should show calendar with two types", function () {176 _initCalendar("4");177 expect(takeScreenshot(oCal)).toLookAs("050_two_types");178 });179 }180 function widthSet(){181 it("should show calendar with a width set", function () {182 _initCalendar("5");183 expect(takeScreenshot(oCal)).toLookAs("060_width_set");184 });185 }186 function intervalSelection(){187 it("should test interval selection", function () {188 _initCalendar("2");189 expect(takeScreenshot(oCal)).toLookAs("070_interval_selection_initial");190 _pressDate(sCalId, "20150120"); // old interval unselected, 20 selected and focused191 expect(takeScreenshot(oCal)).toLookAs("071_select_interval_start");192 _pressDate(sCalId, "20150122"); // 20-22 selected, 22 focused193 expect(takeScreenshot(oCal)).toLookAs("072_select_interval_end");194 _initCalendar("2");195 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios") {196 var sStartDateId = sCalId + "--Month0-" + "20150120";197 var sEndDateId = sCalId + "--Month0-" + "20150130";198 browser.actions().dragAndDrop(element(by.id(sStartDateId)), element(by.id(sEndDateId))).perform(); // old interval unselected, 20-30 selected, 30 focused199 expect(takeScreenshot(oCal)).toLookAs("073_select_interval_move");200 }201 });202 }203 function multiDaySelection(){204 it("should test multiple day selection", function () {205 _initCalendar("3");206 expect(takeScreenshot(oCal)).toLookAs("080_multiple_day_selection_initilal");207 _pressDate(sCalId, "20150120"); // 2 and 20 selected, 20 focused208 expect(takeScreenshot(oCal)).toLookAs("081_multiple_day_selection_press_date1");209 _pressDate(sCalId, "20150122"); // 2, 20, 22 selected, 22 focused210 expect(takeScreenshot(oCal)).toLookAs("082_multiple_day_selection_press_date2");211 _pressDate(sCalId, "20150120"); // 2 and 22 selected, 20 focused212 expect(takeScreenshot(oCal)).toLookAs("083_multiple_day_selection_press_date3");213 });214 }215 function multiMonthSelection(){216 it("should test multiple month display", function () {217 // we have multiple months displayed only on desktop, so skip the tests for mobile218 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios") {219 _initCalendar("6");220 expect(takeScreenshot(oCal)).toLookAs("090_multiple_month_initilal");221 _pressPrev(sCalId); // month switched to December 2014, 31 focused222 expect(takeScreenshot(oCal)).toLookAs("091_multiple_month_press_previous");223 _initCalendar("6");224 _pressNext(sCalId); // month switched to February 2015, 1 focused225 expect(takeScreenshot(oCal)).toLookAs("092_multiple_month_press_next");226 _initCalendar("6");227 _pressMonthPicker(sCalId); // month picker opened, January selected and focused228 expect(takeScreenshot(oCal)).toLookAs("093_multiple_month_MonthPicker");229 _pressMonth(sCalId, "1"); // month picker closed, February 28 focused230 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios") {231 browser.actions().mouseMove(element(by.css("#B1"))).perform();232 expect(takeScreenshot(oCal)).toLookAs("094_multiple_month_MonthPicker_Select");233 }234 _initCalendar("6");235 _pressYearPicker(sCalId); // year Picker shown, 2015 selected and focused236 expect(takeScreenshot(oCal)).toLookAs("095_multiple_month_YearPicker");237 _pressYear(sCalId, "2014"); // year picker closed, January-April 2014 shown, January 31 focused238 browser.actions().mouseMove(element(by.css("#B1"))).perform();239 expect(takeScreenshot(oCal)).toLookAs("096_multiple_month_YearPicker_Select");240 }241 }, iDefaultTimeout);242 it("should test multiple month display keyboard handling", function () {243 if (browser.testrunner.runtime.platformName != "android" && browser.testrunner.runtime.platformName != "ios" && browser.testrunner.runtime.browserName != "safari") {244 // only on desktop and not in Safari (sendKeys needs an Element in Safari, so test makes no sense there)245 _initCalendar("6");246 browser.actions().sendKeys(protractor.Key.ARROW_RIGHT).perform(); // focus on February 1247 expect(takeScreenshot(oCal)).toLookAs("097_multiple_month_keyboard_Arrow_Right");248 browser.actions().sendKeys(protractor.Key.ARROW_UP).perform(); // focus on January 25249 expect(takeScreenshot(oCal)).toLookAs("098_multiple_month_keyboard_Arrow_UP");250 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform(); // focus on February 1251 expect(takeScreenshot(oCal)).toLookAs("099_multiple_month_keyboard_Arrow_Down");252 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform(); // focus on January 31253 expect(takeScreenshot(oCal)).toLookAs("100_multiple_month_keyboard_Arrow_Left");254 browser.actions().sendKeys(protractor.Key.PAGE_UP).perform(); // switch to December-March, focus on December 31255 expect(takeScreenshot(oCal)).toLookAs("101_multiple_month_keyboard_Page_Up1");256 browser.actions().sendKeys(protractor.Key.PAGE_UP).perform(); // focus on November-February 30257 expect(takeScreenshot(oCal)).toLookAs("102_multiple_month_keyboard_Page_Up2");258 browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform(); // focus on December-March 30259 expect(takeScreenshot(oCal)).toLookAs("103_multiple_month_keyboard_Page_Down1");260 browser.actions().sendKeys(protractor.Key.PAGE_DOWN).perform(); // switch to January-April, focus on January 30261 expect(takeScreenshot(oCal)).toLookAs("103_multiple_month_keyboard_Page_Down2");262 }263 });264 it("sap.ui.unified.calendar.Header looks OK when chinese language is set and calendar has two months", function() {265 _initCalendar("7");266 expect(takeScreenshot(oCal)).toLookAs("104_month_displayed");267 _pressYearPicker(sCalId); // click the year button to open YearPicker268 expect(takeScreenshot(oCal)).toLookAs("105_year_picker_displayed");269 });270 it("sap.ui.unified.calendar.Header should test two months header button", function() {271 _initCalendar("8");272 expect(takeScreenshot(oCal)).toLookAs("106_month_displayed");273 _pressNext(sCalId); // Month switched to February - March274 expect(takeScreenshot(oCal)).toLookAs("107_february_march_displayed");275 _pressPrev(sCalId); // Month switch to January - February276 expect(takeScreenshot(oCal)).toLookAs("108_january_february_displayed");277 _pressMonthPicker(sCalId); //right month picker open, focus on January278 expect(takeScreenshot(oCal)).toLookAs("109_month_picker_displayed_focus_january");279 browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform();280 browser.actions().sendKeys(protractor.Key.ENTER).perform(); // Show month is April and May281 expect(takeScreenshot(oCal)).toLookAs("110_month_displayed_apr_may");282 _pressMonthPickerSecondHeader(sCalId); //left month picker open, focus on May283 expect(takeScreenshot(oCal)).toLookAs("111_month_picker_displayed_focus_may");284 browser.actions().sendKeys(protractor.Key.ARROW_UP).perform();285 browser.actions().sendKeys(protractor.Key.ARROW_LEFT).perform();286 browser.actions().sendKeys(protractor.Key.ENTER).perform(); // Show month December prev. year and January287 expect(takeScreenshot(oCal)).toLookAs("112_month_displayed_dec_jan");288 _pressPrev(sCalId); // Month switch to Nov. - Dec.289 expect(takeScreenshot(oCal)).toLookAs("113_november_december_displayed");290 _pressNext(sCalId); // Month swich to Dec. - Jan next year291 expect(takeScreenshot(oCal)).toLookAs("114_december_january_displayed");292 _pressNext(sCalId); // Month switch to Jan - Dec293 expect(takeScreenshot(oCal)).toLookAs("115_january_december_displayed");294 });295 }296 function _initCalendar(sVersion) {297 // initialize via Button function298 element(by.id("B" + sVersion)).click();299 oCal = element(by.id(sCalId));300 }301 function _pressDate(sCalendarId, sNewDate) {302 var sDateId = sCalendarId + "--Month0-" + sNewDate;303 element(by.id(sDateId)).click();304 }305 function _pressPrev(sCalendarId) {306 element(by.id(sCalendarId + "--Head-prev")).click();307 }...
CheckBox.spec.js
Source:CheckBox.spec.js
1/*global describe,it,element,by,takeScreenshot,expect*/2describe("sap.m.CheckBox", function() {3 "use strict";4 it('should load test page',function(){5 expect(takeScreenshot()).toLookAs('initial');6 });7 // verify checkBox is checked and editable8 it('should click on the checked and editable checkbox', function() {9 expect(takeScreenshot(element(by.id('cb_selected_enabled')))).toLookAs('cb_selected_enabled_before_click');10 element(by.id('cb_selected_enabled')).click();11 expect(takeScreenshot(element(by.id('cb_selected_enabled')))).toLookAs('cb_selected_enabled_after_click');12 });13 // verify checkBox is disabled and not editable14 it('should click on the disabled checkbox', function() {15 expect(takeScreenshot(element(by.id('cb_selected_disabled')))).toLookAs('cb_selected_disabled');16 element(by.id('cb_selected_disabled')).click();17 expect(takeScreenshot(element(by.id('cb_selected_disabled')))).toLookAs('cb_selected_disabled');18 });19 // verify checkBox is enabled and editable20 it('should click on the enabled and deselected checkbox', function() {21 expect(takeScreenshot(element(by.id('cb_deselected_enabled')))).toLookAs('cb_deselected_enabled_before_click');22 element(by.id('cb_deselected_enabled')).click();23 expect(takeScreenshot(element(by.id('cb_deselected_enabled')))).toLookAs('cb_deselected_enabled_after_click');24 });25 // verify checkBox is disabled and deselected26 it('should click on the disabled and deselected checkbox', function() {27 expect(takeScreenshot(element(by.id('cb_disabled_deselected')))).toLookAs('disabled_deselected');28 element(by.id('cb_disabled_deselected')).click();29 expect(takeScreenshot(element(by.id('cb_disabled_deselected')))).toLookAs('disabled_deselected');30 });31 // verify checkbox'es label size32 it('should check the label size in the checkbox', function() {33 expect(takeScreenshot(element(by.id('cb_with_label_size-label')))).toLookAs('checkbox_label');34 });35 // verify checkBox is not editable36 it('should click on the not editable checkbox', function() {37 expect(takeScreenshot(element(by.id('cb_not_editable')))).toLookAs('not_editable_before_click');38 element(by.id('cb_not_editable')).click();39 expect(takeScreenshot(element(by.id('cb_not_editable')))).toLookAs('not_editable_after_click');40 });41 // verify checkBox is display only42 it('should click on the display only checkbox', function() {43 expect(takeScreenshot(element(by.id('cb_display_only')))).toLookAs('cb_display_only');44 expect(takeScreenshot(element(by.id('cb_display_only_checked')))).toLookAs('cb_display_only_checked');45 });46 // verify warning checkBox is not selected and editable47 it('should click on the editable warning checkbox', function() {48 expect(takeScreenshot(element(by.id('cb_warning_deselected')))).toLookAs('warning_editable_before_click');49 element(by.id('cb_warning_deselected')).click();50 expect(takeScreenshot(element(by.id('cb_warning_deselected')))).toLookAs('warning_editable_after_click');51 });52 // verify warning checkBox is selected and editable53 it('should click on the editable selected warning checkbox', function() {54 expect(takeScreenshot(element(by.id('cb_warning_selected')))).toLookAs('warning_selected_editable_before_click');55 element(by.id('cb_warning_selected')).click();56 expect(takeScreenshot(element(by.id('cb_warning_selected')))).toLookAs('warning_selected_editable_after_click');57 });58 // verify warning checkBox is selected and not editable59 it('should click on the not editable selected warning checkbox', function() {60 expect(takeScreenshot(element(by.id('cb_warning_selected_disabled')))).toLookAs('warning_selected_disabled_before');61 element(by.id('cb_warning_selected_disabled')).click();62 expect(takeScreenshot(element(by.id('cb_warning_selected_disabled')))).toLookAs('warning_selected_disabled_after');63 });64 // verify error checkBox is not selected and editable65 it('should click on the editable error checkbox', function() {66 expect(takeScreenshot(element(by.id('cb_error_deselected')))).toLookAs('error_editable_before_click');67 element(by.id('cb_error_deselected')).click();68 expect(takeScreenshot(element(by.id('cb_error_deselected')))).toLookAs('error_editable_after_click');69 });70 // verify error checkBox is selected and editable71 it('should click on the editable selected error checkbox', function() {72 expect(takeScreenshot(element(by.id('cb_error_selected')))).toLookAs('error_selected_editable_before_click');73 element(by.id('cb_error_selected')).click();74 expect(takeScreenshot(element(by.id('cb_error_selected')))).toLookAs('error_selected_editable_after_click');75 });76 // verify error checkBox is selected and not editable77 it('should click on the not editable selected error checkbox', function() {78 expect(takeScreenshot(element(by.id('cb_error_selected_disabled')))).toLookAs('error_selected_disabled_after');79 element(by.id('cb_error_selected_disabled')).click();80 expect(takeScreenshot(element(by.id('cb_error_selected_disabled')))).toLookAs('error_selected_disabled_before');81 });82 // verify the checkBox enabled/disabled the checkBox in the toolbar83 it('should disable the checkbox in the toolbar', function() {84 expect(takeScreenshot(element(by.id('cb_in_toolbar')))).toLookAs('enabled_in_toolbar');85 element(by.id('cb_enable_disable_toolbar')).click();86 expect(takeScreenshot(element(by.id('cb_in_toolbar')))).toLookAs('disabled_in_toolbar');87 });88 // verify focused checkBox in a simple form has visible focus outline89 it('should click on the checkbox in the simple form', function() {90 element(by.id('cb_in_a_form')).click();91 expect(takeScreenshot(element(by.id('sf_with_checkbox')))).toLookAs('focused_in_simple_form');92 });...
quality_assurance.js
Source:quality_assurance.js
...3import { createUserRole } from '../testcafe/helpers/roles'4import fetchSandbox from '../testcafe/helpers/sandboxes'5fixture('Quality Assurance,').page(ROOT_PATH)6test('captures dâécran de toutes les pages du site', async () => {7 await takeScreenshot('connexion')8 await takeScreenshot('mot-de-passe-perdu')9 await takeScreenshot('inscription')10 await takeScreenshot('inscription/confirmation')11 const { user } = await fetchSandbox(12 'pro_03_offerers',13 'get_existing_pro_validated_user_with_validated_offerer_validated_user_offerer'14 )15 await t.useRole(createUserRole(user))16 await takeScreenshot('404')17 await t18 .navigateTo('/accueil')19 .takeScreenshot(optionsOfScreenshot('accueil'))20 .click(Selector('button').withText('Fred Leopold'))21 .takeScreenshot(optionsOfScreenshot('menu'))22 const token = Selector('label').withText('Contremarque')23 await t24 .navigateTo('/guichet')25 .typeText(token, 'FAAKEE', { replace: true })26 .takeScreenshot(optionsOfScreenshot('guichet-FAAKEE'))27 await t28 .navigateTo('/guichet')29 .typeText(token, '100004', { replace: true })30 .takeScreenshot(optionsOfScreenshot('guichet'))31 await t32 .navigateTo('/offres')33 .click(Selector('input[type="checkbox"]'))34 .click(Selector('.field-date-end .period-filter-input'))35 .takeScreenshot(optionsOfScreenshot('offres'))36 .typeText(Selector('label').withText('Nom de lâoffre ou ISBN'), 'search without result')37 .click(Selector('button').withText('Lancer la recherche'))38 .takeScreenshot(optionsOfScreenshot('offres-search-without-result'))39 await t40 .navigateTo('/offres')41 .click(Selector('table a'))42 .takeScreenshot(optionsOfScreenshot('offre-edition'))43 .click(Selector('.of-placeholder'))44 .click(Selector('.tna-toggle'))45 .takeScreenshot(optionsOfScreenshot('thumbnail-upload-from-computer'))46 .click(Selector('.thumbnail-dialog .bc-step:not(.active) a'))47 .takeScreenshot(optionsOfScreenshot('thumbnail-upload-from-url'))48 .typeText(49 Selector('.thumbnail-dialog .tnf-form input[name="url"]'),50 'https://pass.culture.fr/wp-content/uploads/2020/11/N_PASS_CULTURE_HD.png'51 )52 .click(Selector('.thumbnail-dialog .tnf-url-button'))53 .takeScreenshot(optionsOfScreenshot('thumbnail-credit'))54 .click(Selector('.thumbnail-dialog .tnd-actions .primary-button'))55 .takeScreenshot(optionsOfScreenshot('thumbnail-image-editor'))56 .click(Selector('.thumbnail-dialog .tnd-actions .primary-button'))57 .takeScreenshot(optionsOfScreenshot('thumbnail-preview'))58 .click(Selector('.thumbnail-dialog .tnd-actions .primary-button'))59 .click(Selector('a').withText('Stock et prix'))60 .takeScreenshot(optionsOfScreenshot('offre-stocks'))61 await t62 .navigateTo('/offres/creation')63 .click(Selector('select').withText('Choisir un type'))64 .click(Selector('select option').withText('Jeux - abonnements'))65 .typeText(Selector('label').withText("Titre de l'offre"), 'Un titre dâoffre')66 .click(Selector('select').withText('Sélectionnez une structure'))67 .click(Selector('select option').withText('Club Dorothy'))68 .click(Selector('select').withText('Sélectionnez un lieu'))69 .click(Selector('select option').withText('Maison de la Brique'))70 .typeText(Selector('label').withText('URL dâaccès à lâoffre'), 'https://example.com')71 .click(Selector('input[name="noDisabilityCompliant"]'))72 .takeScreenshot(optionsOfScreenshot('offre-creation'))73 .click(Selector('button').withText('Enregistrer et passer aux stocks'))74 .click(Selector('button').withText('Ajouter un stock'))75 .takeScreenshot(optionsOfScreenshot('offre-stocks'))76 .click(Selector('button').withText('Enregistrer'))77 .takeScreenshot(optionsOfScreenshot('offre-confirmation'))78 await t79 .navigateTo('/reservations')80 .click(Selector('img[alt="Filtrer par statut"]'))81 .takeScreenshot(optionsOfScreenshot('reservations'))82 .typeText(Selector(`input[placeholder="Rechercher par nom d'offre"]`), 'search without result')83 .takeScreenshot(optionsOfScreenshot('reservations-search-without-result'))84 await t85 .navigateTo('/profil')86 .takeScreenshot(optionsOfScreenshot('profil'))87 .click(Selector('button').withText('Enregistrer'))88 .takeScreenshot(optionsOfScreenshot('profil-success-banner'))89 await t90 .navigateTo('/structures')91 .takeScreenshot(optionsOfScreenshot('structures'))92 .click(Selector('a').withText('Club Dorothy'))93 .takeScreenshot(optionsOfScreenshot('structure'))94 .click(Selector('a').withText('+ Ajouter un lieu'))95 .takeScreenshot(optionsOfScreenshot('lieu-creation'))96 .click(Selector('button').withText('Annuler'))97 .click(Selector('a').withText('Maison de la Brique'))98 .takeScreenshot(optionsOfScreenshot('lieu'))99 .click(Selector('a').withText('Modifier le lieu'))100 .takeScreenshot(optionsOfScreenshot('lieu-edition'))101 await takeScreenshot('structures?mots-cles=search-without-result')102 await takeScreenshot('structures/creation')103 await takeScreenshot('styleguide')104 await takeScreenshot('remboursements')105 // TODO: Pourquoi vois-je du JS ?106 await takeScreenshot('remboursements/detail')107})108const takeScreenshot = async path => {109 await t.navigateTo(`/${path}`).takeScreenshot(optionsOfScreenshot(path))110}111const optionsOfScreenshot = path => ({112 path: `branch/${path.replace(/(\/|\?|=)/g, '-')}.png`,113 fullPage: true,...
TakeScreenshots.js
Source:TakeScreenshots.js
...16 browser.init();17 browser.waitForElementVisible("body");18 //----- Login page -----19 pageId = "loginPage";20 takeScreenshot(browser, i++, `${pageId}`);21 browser.lskLogin();22 //----- Invoice index page -----23 pageId = "invoiceIndexPage";24 takeScreenshot(browser, i++, `${pageId}`);25 browser.lskClick(`#${pageId}MenuActivator`);26 browser.lskClick(`#${pageId}AddInvoiceMenuItem`);27 takeScreenshot(browser, i++, `${pageId}AddInvoiceDialog`);28 browser.lskClick(`#${pageId}AddInvoiceDialogCancelButton`);29 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(9) .mdi-delete`);30 takeScreenshot(browser, i++, `${pageId}DeleteInvoiceDialog`);31 browser.lskClick(`#${pageId}DeleteInvoiceDialogCancelButton`);32 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(9) .mdi-monitor`);33 //----- Invoice show page -----34 pageId = "invoiceShowPage";35 takeScreenshot(browser, i++, `${pageId}`);36 browser.lskClick(`#${pageId}MenuActivator`);37 browser.lskClick(`#${pageId}EditInvoiceMenuItem`);38 takeScreenshot(browser, i++, `${pageId}EditInvoiceDialog`);39 browser.lskClick(`#${pageId}EditInvoiceDialogCancelButton`);40 browser.lskClick(`#${pageId}MenuActivator`);41 browser.lskClick(`#${pageId}EditInvoiceCustomerMenuItem`);42 takeScreenshot(browser, i++, `${pageId}EditInvoiceCustomerDialog`);43 browser.lskClick(`#${pageId}EditInvoiceCustomerDialogCancelButton`);44 browser.lskClick(`#${pageId}MenuActivator`);45 browser.lskClick(`#${pageId}EditInvoiceBillerMenuItem`);46 takeScreenshot(browser, i++, `${pageId}EditInvoiceBillerDialog`);47 browser.lskClick(`#${pageId}EditInvoiceBillerDialogCancelButton`);48 browser.lskClick(`#${pageId}InvoiceLineMenuActivator`);49 browser.lskClick(`#${pageId}AddInvoiceLineMenuItem`);50 takeScreenshot(browser, i++, `${pageId}AddInvoiceLineDialog`);51 browser.lskClick(`#${pageId}AddInvoiceLineDialogCancelButton`);52 browser.lskClick(`#${pageId}InvoiceLineTable tbody tr td:nth-child(7) .mdi-delete`);53 takeScreenshot(browser, i++, `${pageId}DeleteInvoiceLineDialog`);54 browser.lskClick(`#${pageId}DeleteInvoiceLineDialogCancelButton`);55 browser.lskClick(`#${pageId}InvoiceLineTable tbody tr td:nth-child(7) .mdi-pencil`);56 takeScreenshot(browser, i++, `${pageId}EditInvoiceLineDialog`);57 browser.lskClick(`#${pageId}EditInvoiceLineDialogCancelButton`);58 browser.lskClick(`#customerTab`);59 //----- Customer index page -----60 pageId = "customerIndexPage";61 browser.lskClick(`#${pageId}Title`);62 takeScreenshot(browser, i++, `${pageId}`);63 browser.lskClick(`#${pageId}MenuActivator`);64 browser.lskClick(`#${pageId}AddCustomerMenuItem`);65 takeScreenshot(browser, i++, `${pageId}AddCustomerDialog`);66 browser.lskClick(`#${pageId}AddCustomerDialogCancelButton`);67 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(5) .mdi-delete`);68 takeScreenshot(browser, i++, `${pageId}DeleteCustomerDialog`);69 browser.lskClick(`#${pageId}DeleteCustomerDialogCancelButton`);70 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(5) .mdi-monitor`);71 //----- Customer show page -----72 pageId = "customerShowPage";73 takeScreenshot(browser, i++, `${pageId}`);74 browser.lskClick(`#${pageId}MenuActivator`);75 browser.lskClick(`#${pageId}EditCustomerMenuItem`);76 takeScreenshot(browser, i++, `${pageId}EditCustomerDialog`);77 browser.lskClick(`#${pageId}EditCustomerDialogCancelButton`);78 browser.lskClick(`#billerTab`);79 //----- Biller index page -----80 pageId = "billerIndexPage";81 browser.lskClick(`#${pageId}Title`);82 takeScreenshot(browser, i++, `${pageId}`);83 browser.lskClick(`#${pageId}MenuActivator`);84 browser.lskClick(`#${pageId}AddBillerMenuItem`);85 takeScreenshot(browser, i++, `${pageId}AddBillerDialog`);86 browser.lskClick(`#${pageId}AddBillerDialogCancelButton`);87 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(7) .mdi-delete`);88 takeScreenshot(browser, i++, `${pageId}DeleteBillerDialog`);89 browser.lskClick(`#${pageId}DeleteBillerDialogCancelButton`);90 browser.lskClick(`#${pageId}Table tbody tr td:nth-child(7) .mdi-monitor`);91 //----- Biller show page -----92 pageId = "billerShowPage";93 takeScreenshot(browser, i++, `${pageId}`);94 browser.lskClick(`#${pageId}MenuActivator`);95 browser.lskClick(`#${pageId}EditBillerMenuItem`);96 takeScreenshot(browser, i++, `${pageId}EditBillerDialog`);97 browser.end();98 },...
test-admin-navigate-sections.js
Source:test-admin-navigate-sections.js
1describe("verify navigation of admin sections", function() {2 it("should should navigate through admin sections", async function() {3 await browser.gl.utils.login_admin();4 await element.all(by.cssContainingText("a", "Home")).first().click();5 await browser.gl.utils.takeScreenshot("admin/home.png");6 await element.all(by.cssContainingText("a", "Changelog")).first().click();7 await browser.gl.utils.takeScreenshot("admin/changelog.png");8 await element.all(by.cssContainingText("a", "License")).first().click();9 await browser.gl.utils.takeScreenshot("admin/license.png");10 await element.all(by.cssContainingText("a", "Site settings")).first().click();11 await element.all(by.cssContainingText("a", "Main configuration")).first().click();12 await browser.gl.utils.takeScreenshot("admin/site_settings_main_configuration.png");13 await browser.gl.utils.takeScreenshot("admin/site_settings_logo_detail.png", element(by.id("Content")));14 await element.all(by.cssContainingText("a", "Theme customization")).first().click();15 await browser.gl.utils.takeScreenshot("admin/site_settings_theme_customization.png");16 await element.all(by.cssContainingText("a", "Files")).first().click();17 await browser.gl.utils.takeScreenshot("admin/site_settings_files.png");18 await element.all(by.cssContainingText("a", "Languages")).first().click();19 await browser.gl.utils.takeScreenshot("admin/site_settings_languages.png");20 await browser.gl.utils.takeScreenshot("admin/site_settings_languages_detail.png", element(by.id("Content")));21 await element.all(by.cssContainingText("a", "Text customization")).first().click();22 await browser.gl.utils.takeScreenshot("admin/site_settings_text_customization.png");23 await element.all(by.cssContainingText("a", "Users")).first().click();24 await browser.gl.utils.takeScreenshot("admin/users.png");25 await element.all(by.cssContainingText("a", "Questionnaires")).first().click();26 await browser.gl.utils.takeScreenshot("admin/questionnaires.png");27 await element.all(by.cssContainingText("a", "Question templates")).first().click();28 await browser.gl.utils.takeScreenshot("admin/question_templates.png");29 await element.all(by.cssContainingText("a", "Contexts")).first().click();30 await browser.gl.utils.takeScreenshot("admin/contexts.png");31 await element.all(by.cssContainingText("a", "Case management")).first().click();32 await browser.gl.utils.takeScreenshot("admin/report_statuses.png");33 await element.all(by.cssContainingText("a", "Notification settings")).first().click();34 await element.all(by.cssContainingText("a", "Main configuration")).first().click();35 await browser.gl.utils.takeScreenshot("admin/notification_settings.png");36 await browser.gl.utils.takeScreenshot("admin/notification_settings_detail.png", element(by.id("Content")));37 await element.all(by.cssContainingText("a", "Notification templates")).first().click();38 await browser.gl.utils.takeScreenshot("admin/notification_templates.png");39 await element.all(by.cssContainingText("a", "Network settings")).first().click();40 await element.all(by.cssContainingText("a", "Tor")).first().click();41 await browser.gl.utils.takeScreenshot("admin/tor.png");42 await element.all(by.cssContainingText("a", "HTTPS")).first().click();43 await browser.gl.utils.takeScreenshot("admin/https.png");44 await element.all(by.cssContainingText("a", "Access control")).first().click();45 await browser.gl.utils.takeScreenshot("admin/access_control.png");46 await element.all(by.cssContainingText("a", "URL redirects")).first().click();47 await browser.gl.utils.takeScreenshot("admin/url_redirects.png");48 await element.all(by.cssContainingText("a", "Sites management")).first().click();49 await browser.gl.utils.takeScreenshot("admin/sites_management_sites.png");50 await element(by.cssContainingText("a", "Options")).click();51 await browser.gl.utils.takeScreenshot("admin/sites_management_options.png");52 await element.all(by.cssContainingText("a", "Advanced settings")).first().click();53 await element.all(by.cssContainingText("a", "Main configuration")).first().click();54 await browser.gl.utils.takeScreenshot("admin/advanced_settings.png");55 await element.all(by.cssContainingText("a", "Anomaly detection thresholds")).first().click();56 await browser.gl.utils.takeScreenshot("admin/anomaly_thresholds.png");57 await element.all(by.cssContainingText("a", "Audit log")).first().click();58 await browser.gl.utils.takeScreenshot("admin/audit_log.png");59 await element.all(by.cssContainingText("a", "Users")).get(1).click();60 await browser.gl.utils.takeScreenshot("admin/audit_log_users.png");61 await element.all(by.cssContainingText("a", "Reports")).first().click();62 await browser.gl.utils.takeScreenshot("admin/audit_log_reports.png");63 await element.all(by.cssContainingText("a", "Scheduled jobs")).first().click();64 await browser.gl.utils.takeScreenshot("admin/audit_log_scheduled_jobs.png");65 });...
page.spec.js
Source:page.spec.js
...27 const pageTitle = faker.random.word();28 const pageContent = faker.lorem.lines(1);29 let counter = 0;30 const slug = "PageCreated";31 async function takeScreenshot(slug) {32 await page.screenshot({33 path: `${pathImages}/${slug}${counter++}.jpg`,34 });35 }36 await pagePageObject.createPage(page, slug, takeScreenshot);37 await pagePageObject.addContent(38 page,39 pageTitle,40 pageContent,41 slug,42 takeScreenshot43 );44 await pagePageObject.publishPage(page, slug, takeScreenshot);45 await expect(page).toMatch("Published");46 await page.click('a[href="#/pages/"]');47 await new Promise((r) => setTimeout(r, 1000));48 await page.click(".gh-notification-close");49 await expect(page).toMatch(pageTitle);50 });51 it("Create Page and schedule it successfully", async () => {52 const pageTitle = faker.random.word();53 const pageContent = faker.lorem.lines(1);54 let counter = 0;55 const slug = "PageScheduled";56 async function takeScreenshot(slug) {57 await page.screenshot({58 path: `${pathImages}/${slug}${counter++}.jpg`,59 });60 }61 await pagePageObject.createPage(page, slug, takeScreenshot);62 await pagePageObject.addContent(63 page,64 pageTitle,65 pageContent,66 slug,67 takeScreenshot68 );69 await pagePageObject.schedulePage(page, slug, takeScreenshot);70 await expect(page).toMatch("Scheduled");71 await page.click('a[href="#/pages/"]');72 await new Promise((r) => setTimeout(r, 1000));73 await page.click(".gh-notification-close");74 await expect(page).toMatch(pageTitle);75 });76 it("Create draft Page", async () => {77 const pageTitle = faker.random.word();78 const pageContent = faker.lorem.lines(1);79 let counter = 0;80 const slug = "PageDraft";81 async function takeScreenshot(slug) {82 await page.screenshot({83 path: `${pathImages}/${slug}${counter++}.jpg`,84 });85 }86 await pagePageObject.createPage(page, slug, takeScreenshot);87 await pagePageObject.addContent(88 page,89 pageTitle,90 pageContent,91 slug,92 takeScreenshot93 );94 await page.click('a[href="#/pages/"]');95 await new Promise((r) => setTimeout(r, 1000));96 await expect(page).toMatch(pageTitle);97 });98 it("Create Page, try to edit the first page but discard changes", async () => {99 const pageTitle = faker.random.word();100 const pageContent = faker.lorem.lines(1);101 const pageTitleEdit = faker.random.word();102 let counter = 0;103 const slug = "PageDiscardChanges";104 async function takeScreenshot(slug) {105 await page.screenshot({106 path: `${pathImages}/${slug}${counter++}.jpg`,107 });108 }109 await pagePageObject.createPage(page, slug, takeScreenshot);110 await pagePageObject.addContent(111 page,112 pageTitle,113 pageContent,114 slug,115 takeScreenshot116 );117 await pagePageObject.publishPage(page, slug, takeScreenshot);118 await expect(page).toMatch("Published");...
takeScreenshot.spec.js
Source:takeScreenshot.spec.js
...10});11it("returns a buffer containing the result of 'takeScreenshot' on the Appium Service", async () => {12 const screenshot = "dGVzdA==";13 jest.spyOn(appiumService, "takeScreenshot").mockResolvedValue(screenshot);14 const result = await device.takeScreenshot();15 expect(result).toBeInstanceOf(Buffer);16 expect(result.toString("base64")).toEqual(screenshot);17 expect(appiumService.takeScreenshot).toHaveBeenCalledTimes(1);18});19it("stores the screenshot on disk if a 'filePath' is configured", async () => {20 const filePath = "some/path";21 jest.spyOn(appiumService, "takeScreenshot").mockResolvedValue("dGVzdA==");22 jest.spyOn(fs, "writeFile").mockImplementation((path, data, cb) => cb());23 const buffer = await device.takeScreenshot({ filePath });24 expect(fs.writeFile).toHaveBeenCalledWith(filePath, buffer, expect.any(Function));25});26it("throws an ActionError for Appium request errors", async () => {27 const error = new AppiumError("Request error.", 3);28 jest.spyOn(appiumService, "takeScreenshot").mockRejectedValue(error);29 expect.assertions(3);30 try {31 await device.takeScreenshot();32 } catch (err) {33 expect(err).toBeInstanceOf(ActionError);34 expect(err).toHaveProperty("message", "Failed to take screenshot.");35 }36 expect(appiumService.takeScreenshot).toHaveBeenCalledTimes(1);37});38it("throws an ActionError if it is unable to store on disk when a 'filePath' is configured", async () => {39 const error = new Error("File system error.");40 jest.spyOn(appiumService, "takeScreenshot").mockResolvedValue("dGVzdA==");41 jest.spyOn(fs, "writeFile").mockImplementation((path, data, cb) => cb(error));42 expect.assertions(4);43 try {44 await device.takeScreenshot({ filePath: "some/path" });45 } catch (err) {46 expect(err).toBeInstanceOf(ActionError);47 expect(err).toHaveProperty("message", "Failed to store screenshot on disk.");48 }49 expect(appiumService.takeScreenshot).toHaveBeenCalledTimes(1);50 expect(fs.writeFile).toHaveBeenCalledTimes(1);51});52it("propagates other types of errors", async () => {53 const error = new Error("Something went wrong.");54 jest.spyOn(appiumService, "takeScreenshot").mockRejectedValue(error);55 expect.assertions(3);56 try {57 await device.takeScreenshot();58 } catch (err) {59 expect(err).toBeInstanceOf(error.constructor);60 expect(err).toHaveProperty("message", error.message);61 }62 expect(appiumService.takeScreenshot).toHaveBeenCalledTimes(1);...
takeScreenshotChain.test.js
Source:takeScreenshotChain.test.js
...30 assert.deepStrictEqual(toJSON(), {type: 'takeScreenshot'});31 });32 describe('testing takeScreenshot with different arguments', () => {33 it('should handle not empty string or undefined', () => {34 assert.doesNotThrow(() => takeScreenshot('raw'));35 assert.doesNotThrow(() => takeScreenshot('base64'));36 });37 it('should throw error when passing invalid arguments', () => {38 function isSuitestErrorInvalidInput(err) {39 return err instanceof SuitestError &&40 err.code === SuitestError.INVALID_INPUT &&41 err.message.includes('Invalid input provided for .takeScreenshot function');42 }43 assert.throws(() => takeScreenshot(''), isSuitestErrorInvalidInput);44 assert.throws(() => takeScreenshot('any/path/image.png'), isSuitestErrorInvalidInput);45 assert.throws(() => takeScreenshot(null), isSuitestErrorInvalidInput);46 assert.throws(() => takeScreenshot([]), isSuitestErrorInvalidInput);47 assert.throws(() => takeScreenshot(() => void 0), isSuitestErrorInvalidInput);48 assert.throws(() => takeScreenshot(111), isSuitestErrorInvalidInput);49 assert.throws(() => takeScreenshot(Symbol('any')), isSuitestErrorInvalidInput);50 });51 });...
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, takeScreenshot } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await goto("google.com");6 await takeScreenshot({ path: 'google.png' });7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');14(async () => {15 try {16 await openBrowser({ headless: false });17 await goto("google.com");18 await screenshot({ path: 'google.png' });19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');26(async () => {27 try {28 await openBrowser({ headless: false });29 await goto("google.com");30 await screenshot({ path: 'google.png' });31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();37const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');38(async () => {39 try {40 await openBrowser({ headless: false });41 await goto("google.com");42 await screenshot({ path: 'google.png' });43 } catch (e) {44 console.error(e);45 } finally {46 await closeBrowser();47 }48})();49const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');50(async () => {51 try {52 await openBrowser({ headless: false });53 await goto("google.com");54 await screenshot({ path: 'google.png' });55 } catch (e) {56 console.error(e);57 } finally {58 await closeBrowser();59 }60})();61const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');62(async () => {63 try {64 await openBrowser({ head
Using AI Code Generation
1const { openBrowser, goto, write, click, closeBrowser, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser({headless:false});5 await goto("google.com");6 await write("taiko");7 await click("Google Search");8 await screenshot({path:'test.png'});9 } catch (e) {10 console.error(e);11 } finally {12 await closeBrowser();13 }14})();15const { openBrowser, goto, write, click, closeBrowser, screenshot } = require('taiko');16(async () => {17 try {18 await openBrowser({headless:false});19 await goto("google.com");20 await write("taiko");21 await click("Google Search");22 await screenshot({path:'test.png', options: {format: 'jpeg', quality: 100}});23 } catch (e) {24 console.error(e);25 } finally {26 await closeBrowser();27 }28})();
Using AI Code Generation
1const { openBrowser, goto, screenshot, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await screenshot({ path: 'google.png' });6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12const { openBrowser, goto, screenshot, closeBrowser } = require('taiko');13(async () => {14 try {15 await openBrowser();16 await screenshot({ path: 'google.png', fullPage: true });17 } catch (e) {18 console.error(e);19 } finally {20 await closeBrowser();21 }22})();23const { openBrowser, goto, screenshot, closeBrowser } = require('taiko');24(async () => {25 try {26 await openBrowser();27 await screenshot({ path: 'google.png', fullPage: true, encoding: 'base64' });28 } catch (e) {29 console.error(e);30 } finally {31 await closeBrowser();32 }33})();34const { openBrowser, goto, screenshot, closeBrowser } = require('taiko');35(async () => {36 try {37 await openBrowser();38 await screenshot({ path: 'google.png', fullPage: true, encoding: 'base64' });39 await screenshot({ path: 'google.png', fullPage: true, encoding: 'binary' });40 } catch (e) {41 console.error(e);42 } finally {43 await closeBrowser();44 }45})();46const { openBrowser, goto, screenshot, closeBrowser } = require('taiko');47(async () => {48 try {49 await openBrowser();50 await screenshot({ path: 'google.png', fullPage: true, encoding: 'base64' });51 await screenshot({ path: 'google.png', fullPage: true, encoding: 'binary' });52 await screenshot({ path
Using AI Code Generation
1const { openBrowser, goto, write, click, closeBrowser, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko", into("Search"));6 await click("Google Search");7 await screenshot({ path: "google.png" });8 } catch (e) {9 console.error(e);10 } finally {11 await closeBrowser();12 }13})();14### openBrowser([options])15await openBrowser();16await openBrowser({ headless: true });17await openBrowser({ headless: true, args: ["--window-size=1920,1080"] });18await openBrowser({ args: ["--window-size=1920,1080"] });19await openBrowser({ chromiumArgs: ["--window-size=1920,1080"] });
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await screenshot({ path: 'google.png' });6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12### openBrowser(options)
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser({headless:false});5 await goto("google.com");6 await screenshot({path:'google.png'});7 await closeBrowser();8 } catch (error) {9 console.error(error);10 } finally {11 }12})();
Using AI Code Generation
1(async () => {2 try {3 await openBrowser({ headless: false });4 await goto("google.com");5 await write("Taiko");6 await press("Enter");7 await click("Taiko");8 await takeScreenshot();9 await closeBrowser();10 } catch (e) {11 console.error(e);12 } finally {13 }14})();15(async () => {16 try {17 await openBrowser({ headless: false });18 await goto("google.com");19 await write("Taiko");20 await press("Enter");21 await click("Taiko");22 await takeElementScreenshot("Taiko");23 await closeBrowser();24 } catch (e) {25 console.error(e);26 } finally {27 }28})();29(async () => {30 try {31 await openBrowser({ headless: false });32 await goto("google.com");33 await write("Taiko");34 await press("Enter");35 await click("Taiko");36 await screenshot({37 });38 await closeBrowser();39 } catch (e) {40 console.error(e);41 } finally {42 }43})();44(async () => {45 try {46 await openBrowser({ headheadless: false });47 await goto("google.com");48 await write("Taiko");49 await press("Enter");50 await click("Taiko");51 await screenshot({52 });53 await closeBrowser();54 } catch (e) {55 console.error(e);56 } finally {57 }58})();59(async () => {60 try {61 await openBrowser({ headless: false });62 await goto("google.com");63 await write("Taiko");64 await press("Enter");65 await click("Taiko");66 await screenshot({67 });68 await closeBrowser();69 } catch (e) {70 console.error(e);71 } finally {72 }73})();
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await screenshot({path: 'google.png'});6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12const { openBrowser, goto, closeBrowser, screenshot } = require('taiko');13(async () => {14 try {15 await openBrowser();16 await screenshot({path: 'google.png', fullPage: true});17 } catch (e) {18 console.error(e);19 } finally {20 await closeBrowser();21 }22})();23const { openBrowser, goto, closeBrowser, screenshot, link } = require('taiko');24(async () => {25 try {26 await openBrowser();27 await screenshot(link("Gmail"), {path: 'gmail.png'});28 } catch (e) {29 console.error(e);30 } finally {31 await closeBrowser();32 }33})();
Using AI Code Generation
1const { openBrowser, goto, write, click, closeBrowser, button, $, into, toRightOf, waitFor, screenshot } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await click("Get Started");6 await click("API Docs");7 await click("Installation");8 await click("Node.js");9 await click("Installation");
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!