From a25056f21ee38a38a2f7eac6c27b3447bd072fb9 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 13 Sep 2019 16:26:50 +0200 Subject: [PATCH] retry getting the scroll panel when retrying to get the scrolltop --- src/usecases/timeline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usecases/timeline.js b/src/usecases/timeline.js index 580d88ee6a..1770e0df9f 100644 --- a/src/usecases/timeline.js +++ b/src/usecases/timeline.js @@ -20,14 +20,14 @@ module.exports.scrollToTimelineTop = async function(session) { session.log.step(`scrolls to the top of the timeline`); await session.page.evaluate(() => { return Promise.resolve().then(async () => { - const timelineScrollView = document.querySelector(".mx_RoomView_timeline .mx_ScrollPanel"); let timedOut = false; let timeoutHandle = null; // set scrollTop to 0 in a loop and check every 50ms // if content became available (scrollTop not being 0 anymore), // assume everything is loaded after 3s do { - if (timelineScrollView.scrollTop !== 0) { + const timelineScrollView = document.querySelector(".mx_RoomView_timeline .mx_ScrollPanel"); + if (timelineScrollView && timelineScrollView.scrollTop !== 0) { if (timeoutHandle) { clearTimeout(timeoutHandle); }