-1

I have Selenium code running, if the test fail i want to see the entire process from start to finish (not using a screenshot), something know how can record the screen while selenium running.

from selenium import webdriver

driver = webdriver.Chrome()


# If test is fail i want to save video file who recorded the whole process
def test1():
    driver.get(...)
    e = driver.find_element(...)
    e.click()
    assert e.text == 'Some Text'

Thx.

Yakir Tsuberi
  • 237
  • 1
  • 9

2 Answers2

3

Use an external library such as ffmpeg For example:

import subprocess
import time

proc = subprocess.Popen(['ffmpeg', '-f', 'gdigrab', '-framerate', '15', '-offset_x', '0', '-offset_y', '0', '-video_size', '1920x1080', '-i', 'desktop', '-c:v', 'libx264', '-vprofile', 'baseline', '-g', '15', '-crf', '1', '-pix_fmt', 'yuv420p', '-threads', '4', 'output.mkv'])
# Start selenium code...
time.sleep(10)
proc.kill()
Yakir Tsuberi
  • 237
  • 1
  • 9
0

I am facing this problem

I have 3 ideas:

  1. using ffmpeg as above
  2. using chrome extension, u must create crx file of extension by some ways, example at https://crxextractor.com/, then .add_extension read more in Using Extensions with Selenium (Python)
  3. using selenium to open new tab to https://recordscreen.io/

I will take more infomation after

lam vu Nguyen
  • 433
  • 4
  • 9