Cucumber Framework Selenium(BDD) Part - 10 || What are Hooks & @Before @After & Capture Screen Shot

Опубликовано: 01 Январь 1970
на канале: ABHISHEK REDDY S
2,245
14

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
===================================================================


Смотрите видео Cucumber Framework Selenium(BDD) Part - 10 || What are Hooks & @Before @After & Capture Screen Shot онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь ABHISHEK REDDY S 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,245 раз и оно понравилось 14 людям.