Home > other >  Is there any selenium/python script for the Screen Recording?
Is there any selenium/python script for the Screen Recording?

Time:08-05

I want to record the screen by using selenium in python, I searched for these, but I only get results for java, and for the screenshots. Please let me know if there is any script by which I can record the screen.

CodePudding user response:

you need record the whone screenshot? try this library

and try this code:

from clicknium import clicknium as cc, locator, ui
cc.get_screenshot("D:\\test.jpg")

CodePudding user response:

Try this, very popular framework for eg. java or python etc.

in cmd line : pip install allure-pytest
go here: https://docs.qameta.io/allure/
section 2.1. Installing a commandline
download the newest version for eg. windows xxx.zip
copy path of bin folder eg: D:\Drivers\allure-2.18.1\bin
and paste it to Environment Variables > find 'Path' and edit it>
add new path with bin path.

to Your test.py file:
import allure
from allure_commons.types import AttachmentType

and add it at the end of Your test in eg.: assertion statement
example:

method_name = self.driver.find_element(By.XPATH, "xxx").text
if method_name == 'some text':
    assert True
else:
    allure.attach(self.driver.get_screenshot_as_png(), name="test_name",
              attachment_type=AttachmentType.PNG)
assert False

In IDE terminal or cmd do this:
pytest -v -s --alluredir="D:\projectPath\raport" Path/to/your/tests
then tests will be executed in terminal do this to read raport wfrom test:
allure serve "D:\raport\Path"

with this allure framework You will have reports of tests with screenshots:

  • Related