Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
<sonar.projectKey>dougnoel_sentinel</sonar.projectKey>
<sonar.organization>dougnoel</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<screen-recorder.version>0.7.7.0</screen-recorder.version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this up to line 100 with the rest of the version numbers.

</properties>

<build>
Expand Down Expand Up @@ -369,6 +371,13 @@
<scope>import</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.github.stephenc.monte/monte-screen-recorder -->
<dependency>
<groupId>com.github.stephenc.monte</groupId>
<artifactId>monte-screen-recorder</artifactId>
<version>${screen-recorder.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down Expand Up @@ -534,6 +543,11 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

<dependency>
<groupId>com.github.stephenc.monte</groupId>
<artifactId>monte-screen-recorder</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.dougnoel.sentinel.filemanagers;

import java.awt.*;
import org.monte.media.Format;
import org.monte.media.math.Rational;
import org.monte.screenrecorder.ScreenRecorder;
import static org.monte.media.AudioFormatKeys.*;
import static org.monte.media.VideoFormatKeys.*;

public class SentinelScreenRecorder {
private static ScreenRecorder screenRecorder;

public static void startRecording() throws Exception {

GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
.getDefaultConfiguration();
screenRecorder = new ScreenRecorder(gc, new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey,
Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, Rational.valueOf(30)),
null);
screenRecorder.start();

}

public static void stopRecording() throws Exception {
screenRecorder.stop();
}

}
10 changes: 9 additions & 1 deletion src/main/java/com/dougnoel/sentinel/steps/BaseSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter;
import com.dougnoel.sentinel.configurations.Configuration;
import com.dougnoel.sentinel.configurations.Time;
import com.dougnoel.sentinel.pages.PageManager;

import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

/**
Expand Down Expand Up @@ -173,4 +175,10 @@ public static void pressBrowserButton(String option) {
}
}

}
@Then("^video recording (.*?)( was not)?(?: was)? attached to the report?$")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elementName will never contain "not"

Suggested change
@Then("^video recording (.*?)( was not)?(?: was)? attached to the report?$")
@Then("^video recording was( not)? attached to the report?$")

public static void addVideoToReport(String elementName, String assertion) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static void addVideoToReport(String elementName, String assertion) {
public static void addVideoToReport(String assertion) {

if(Configuration.toString("addVideoToReport")!=null && !elementName.contains("not"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the step exists, you shouldn't have to turn it on in the commandline. Ideally this would happen whether there was a cucumber step or not by adding it to the after step for each method.

Suggested change
if(Configuration.toString("addVideoToReport")!=null && !elementName.contains("not"))
if(Configuration.toString("addVideoToReport")!=null && !assertion.contains("not"))

ExtentCucumberAdapter.addTestStepLog("<a href='"+System.getProperty("user.dir")+"\\reports\\extent-cucumber.avi'>Click to see video recording</a>");

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete extra line

}
}
5 changes: 4 additions & 1 deletion src/test/java/features/47 Swag Labs Login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ Feature: 47 Swag Labs Login
And I click the Login Button
Then I am redirected to the Sauce Demo Main Page
And I verify the App Logo exists
And video recording was attached to the report
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can add a @record tag at the top of this scenario and then read it in the @after step in the TestRunner instead of doing a Cucumber step here.


@47B
Scenario: 47B Failed Login with Locked Out User
Given I am on the Sauce Demo Login Page
When I fill the account information for account LockedOutUser into the Username field and the Password field
And I click the Login Button
Then I verify the Error Message contains the text "Sorry, this user has been locked out."
Then I verify the Error Message contains the text "Sorry, this user has been locked out."
And video recording was not attached to the report

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete extra line

22 changes: 13 additions & 9 deletions src/test/java/tests/SentinelTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

import com.dougnoel.sentinel.configurations.Configuration;
import com.dougnoel.sentinel.exceptions.SentinelException;
import com.dougnoel.sentinel.filemanagers.SentinelScreenRecorder;
import com.dougnoel.sentinel.pages.PageManager;
import com.dougnoel.sentinel.webdrivers.WebDriverFactory;
import io.cucumber.junit.CucumberOptions;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(monochrome = true
Expand All @@ -26,13 +25,16 @@
public class SentinelTests {
private static final Logger log = LogManager.getLogger(SentinelTests.class); // Create a logger.

@BeforeClass
public static void setUpBeforeAnyTestsAreRun() throws SentinelException {
WebDriverFactory.instantiateWebDriver();
}

@BeforeClass
public static void setUpBeforeClass() throws Exception {
WebDriverFactory.instantiateWebDriver();
// if(Configuration.toString("addVideoToReport")!=null)

SentinelScreenRecorder.startRecording();
}

@AfterClass
public static void tearDownAfterClass() throws SentinelException {
public static void tearDownAfterClass() throws Exception {
String totalWaitTime = Configuration.toString("totalWaitTime");
if (totalWaitTime != null) {
log.warn("This test took {} total seconds longer due to explicit waits. Sentinel handles dynamic waits. If you have a reason for adding explicit waits, you should probably be logging a bug ticket to get the framework fixed at: http://https://github.com/dougnoel/sentinel/issues", totalWaitTime);
Expand All @@ -41,5 +43,7 @@ public static void tearDownAfterClass() throws SentinelException {
if (System.getProperty("leaveBrowserOpen", "false") == "false") {
PageManager.quit();
}
// if(Configuration.toString("addVideoToReport")!=null)
SentinelScreenRecorder.stopRecording();
}
}