-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added script to support video recording add to extent report #231
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,13 +3,16 @@ | |||||
import static com.dougnoel.sentinel.elements.ElementFunctions.getElement; | ||||||
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; | ||||||
|
||||||
/** | ||||||
|
@@ -172,4 +175,10 @@ public static void pressBrowserButton(String option) { | |||||
} | ||||||
} | ||||||
|
||||||
} | ||||||
@Then("^video recording (.*?)( was not)?(?: was)? attached to the report?$") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. elementName will never contain "not"
Suggested change
|
||||||
public static void addVideoToReport(String elementName, String assertion) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if(Configuration.toString("addVideoToReport")!=null && !elementName.contains("not")) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
ExtentCucumberAdapter.addTestStepLog("<a href='"+System.getProperty("user.dir")+"\\reports\\extent-cucumber.avi'>Click to see video recording</a>"); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete extra line |
||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
@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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete extra line |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,12 @@ | |
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
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.pages.PageManager; | ||
import com.dougnoel.sentinel.webdrivers.WebDriverFactory; | ||
|
||
import com.dougnoel.sentinel.utilities.*; | ||
import io.cucumber.junit.CucumberOptions; | ||
import io.cucumber.junit.Cucumber; | ||
|
||
|
@@ -20,14 +19,21 @@ | |
, plugin = {"json:target/cucumber.json", | ||
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"} | ||
, strict = true | ||
// , tags = { "@text" } | ||
//, tags = { "@47" } | ||
) | ||
|
||
public class SentinelTests { | ||
private static final Logger log = LogManager.getLogger(SentinelTests.class); // Create a logger. | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() { | ||
WebDriverFactory.instantiateWebDriver(); | ||
if(Configuration.toString("addVideoToReport")!=null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put this in a @before step that will run before each Scenario, and then see if you can read a @record tag for the Cucumber step to turn this on. Then this would be on if either the If @record tag exists and |
||
SentinelScreenRecorder.startRecording("extent-cucumber"); | ||
} | ||
|
||
@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); | ||
|
@@ -36,5 +42,7 @@ public static void tearDownAfterClass() throws SentinelException { | |
if (System.getProperty("leaveBrowserOpen", "false") == "false") { | ||
PageManager.quit(); | ||
} | ||
if(Configuration.toString("addVideoToReport")!=null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to an @after method as I mentioned in previous comments. |
||
SentinelScreenRecorder.stopRecording(); | ||
} | ||
} |
There was a problem hiding this comment.
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.