- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to record a video in Selenium webdriver?
We can record a video with Selenium. There is no default technique in Selenium to record videos. The videos can be captured in the below processes−
ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar files need to be downloaded and saved within the project folder.
Next, add the above two jars to the project Build path. Right-click on project−> Click on Properties−> Choose Java Build Path−> Click on the Libraries tab−> Click on Add External Jars−> Browser and select the ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar−> Click on Apply−> Click OK.
Have a folder to hold the videos within the project.
Example
@BeforeMethod public void bmethod(Method m){ // format of the date and time defined DateFormat d = new SimpleDateFormat("yy−mm−dd HH−mm−ss"); // get the current date Date dt = new Date(); try { // video capture file name recorder = new ATUTestRecorder(System.getProperty("userdir") + "\TestVideos\" , m.getName() + "_" + d.format(dt), false); } catch (Exception e){ Log.error("Error capturing videos"); } //begin recording try { recorder.start(); } catch (Exception e){ Log.error("Error in beginning videos"); } }
Example
@AfterMethod public void amethod(iTestResult result) { try { recorder.stop(); } catch (Exception e){ Log.error("Error in stopping videos"); } }
For a Maven project, the pom.xml should have the setting −
Advertisements