mirror of https://github.com/zulip/zulip.git
tools: Fix screenshot capturing script to capture the correct area.
As the hotkey might cause the page to be scrolled, thus capturing the wrong area, I view the message by id instead of using '#narrow/near' and remove the 'selected_message' class from the message box to remove the selection highlight on it. Fixes: #17878
This commit is contained in:
parent
27d1f5e0e3
commit
f42729ab0c
|
@ -54,14 +54,14 @@ async function run() {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Navigate to message and capture screenshot
|
// Navigate to message and capture screenshot
|
||||||
await page.goto(`http://${host}/#narrow/near/${options.messageId}`);
|
await page.goto(`http://${host}/#narrow/id/${options.messageId}`);
|
||||||
const messageSelector = `#zfilt${CSS.escape(options.messageId)}`;
|
const messageSelector = `#zfilt${CSS.escape(options.messageId)}`;
|
||||||
await page.waitForSelector(messageSelector);
|
await page.waitForSelector(messageSelector);
|
||||||
// remove unread marker and don't select message
|
// remove unread marker and don't select message
|
||||||
const marker = `#zfilt${CSS.escape(options.messageId)} .unread_marker`;
|
const marker = `#zfilt${CSS.escape(options.messageId)} .unread_marker`;
|
||||||
await page.evaluate((sel) => $(sel).remove(), marker);
|
await page.evaluate((sel) => $(sel).remove(), marker);
|
||||||
const messageBox = await page.$(messageSelector);
|
const messageBox = await page.$(messageSelector);
|
||||||
await page.keyboard.press("KeyK");
|
await page.evaluate((msg) => $(msg).removeClass("selected_message"), messageSelector);
|
||||||
const messageGroup = (await messageBox.$x(".."))[0];
|
const messageGroup = (await messageBox.$x(".."))[0];
|
||||||
// Compute screenshot area, with some padding around the message group
|
// Compute screenshot area, with some padding around the message group
|
||||||
const clip = {...(await messageGroup.boundingBox())};
|
const clip = {...(await messageGroup.boundingBox())};
|
||||||
|
|
Loading…
Reference in New Issue