diff --git a/test/functional/page_objects/time_picker.ts b/test/functional/page_objects/time_picker.ts index 59513bf350040..366f281277c5e 100644 --- a/test/functional/page_objects/time_picker.ts +++ b/test/functional/page_objects/time_picker.ts @@ -123,8 +123,21 @@ export class TimePickerPageObject extends FtrService { /** * @param {String} fromTime MMM D, YYYY @ HH:mm:ss.SSS * @param {String} toTime MMM D, YYYY @ HH:mm:ss.SSS + * @param {Boolean} force time picker force update, default is false */ - public async setAbsoluteRange(fromTime: string, toTime: string) { + public async setAbsoluteRange(fromTime: string, toTime: string, force = false) { + if (!force) { + const currentUrl = decodeURI(await this.browser.getCurrentUrl()); + const DEFAULT_DATE_FORMAT = 'MMM D, YYYY @ HH:mm:ss.SSS'; + const startMoment = moment.utc(fromTime, DEFAULT_DATE_FORMAT).toISOString(); + const endMoment = moment.utc(toTime, DEFAULT_DATE_FORMAT).toISOString(); + if (currentUrl.includes(`time:(from:'${startMoment}',to:'${endMoment}'`)) { + this.log.debug( + `We already have the desired start (${fromTime}) and end (${toTime}) in the URL, returning from setAbsoluteRange` + ); + return; + } + } this.log.debug(`Setting absolute range to ${fromTime} to ${toTime}`); await this.showStartEndTimes(); let panel!: WebElementWrapper;