In This video, I have explained what are hooks and how to use Hooks.
How to write before and after annotation and how to capture a screenshot.
#cucumberframework #hooks #@Before #@After #screenshot
==================================================
what are hooks in cucumber?
Cucumber supports hooks, which are blocks of code that run before or after each scenario. ... Cucumber Hooks allows us to better manage the code workflow and helps us to reduce the code redundancy.
@Before : To load the property file
@After : Capture the screen shot of failed test cases and close the
browser
Screen shot code :
if (scenario.isFailed()) {
try {
byte[] screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES);
File screenshot_with_scenario_name = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot_with_scenario_name,
new File("./target/test-report/" + scenario.getName() + ".png"));
System.out.println(scenario.getName());
scenario.embed(screenshot, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
======================================================
Technologies Used:
• Selenium WebDriver - v3.0.4 (Open Source)
• JDK 1.8 (Java Development Kit)
• Junit (junit Unit Framework)
• Maven (Build Automation Tool)
• Browser - Google Chrome
• cucumber plugin
===================================================================
cucumber framework playlist: • Cucumber Framework Selenium(BDD) Par...
Youtube subscribe: / realtimeseleniumautomation
Facebook Page: / realtimeseleniumautomation
Facebook group: Selenium Automation Real Time Experience
cucumber framework whats app group: https://chat.whatsapp.com/HoGAlLUwWt2...
tube buddy : https://www.Tubebuddy.com/selenium
===================================================================
Watch video Cucumber Framework Selenium(BDD) Part - 10 || What are Hooks & @Before @After & Capture Screen Shot online without registration, duration hours minute second in high quality. This video was added by user ABHISHEK REDDY S 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,245 once and liked it 14 people.