0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Playwrightを使ってLPのスクリーンショットを取る

Posted at

ことはじめ

LPのチェックのためにVisualRegressionTestを導入したい!
でも表示しただけでスクリーンショット取ると画像が読み込まれていない!(Lozad.js使ってる)
画像を全部表示してスクリーンショットを取ろう!

test("スクリーンショット",async({ page, browserName})=> {
  test.setTimeout(120000);  // timeoutの時間を変更
  await page.setViewportSize({  // 画面サイズを変更
    width: 1920,
    height: 1080,
  });
  await page.goto(jsonData.url,{
    waitUntil:"domcontentloaded",
  });
  
  //imgタグの入っていないpictureタグを列挙し、それぞれの位置までスクロール
  const pics = await page.$$('picture:not(:has(img))');
  for(const pic of pics){
    await pic.scrollIntoViewIfNeeded();
  }

  //スクリーンショット取得(ぶらうざべつにh)
  await page.screenshot({
    path: `tests/screenshot/actual_${browserName}.png`,
    fullPage: true,
  });
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?