0

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

0

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")
justin
  • 197
  • 6
  • [Clicknium](https://marketplace.visualstudio.com/items?itemName=ClickCorp.clicknium): Clicknium extension helps you capture and manage UI locators easily. Locators are generated by just clicking the target UI element, and with clicknium python module, you can start automation for web and desktop right away. The extension also provides locator intellisense in coding, centralized locator management in cloud, and project for distribution. – undetected Selenium Jul 28 '22 at 06:51
  • This is for just taking screenshot, I am asking for record the screen during the automated test execution – Ekta Verma Jul 29 '22 at 10:36
0

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:

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 12 '22 at 11:55