Extent Reports:
For Extent report initialization just use below code
public static void ExtentReportsInitialize(){
extent.init(reportLocation + "Report.html", true,DisplayOrder.BY_OLDEST_TO_LATEST,GridType.MASONRY);
extent.config().insertJS("$(document).ready(function(){"
+ " $('img.report-img').each(function(){"
+ "$(this).attr('data-featherlight','');"
+ " $(this).attr('src',$(this).attr('src').replace('file:///','')); "
+ "$(this).attr('href',$(this).attr('src'));"
+ " $(this).attr('data-featherlight','image');"
+ " })});");
extent.config().addCustomStyles(css);
}
public static String createScreenshot(WebDriver driver) {
// generate screenshot as a file object
return "data:image/png;base64,"+((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
}
With this code we can take the screenshot for all the failed cases and embed the screenshot in the report itself and click on image from the report will open the light box. With this no need to always maintain ‘Screenshot’ folder in separate. Images will be shown even if we share just ‘report.html’ file to any user (As images are embedded within the report).
if you have any question please comment below.
Thanks!
How to add lightbox to your extent reports?
Lightbox in Javascript: A typical lightbox image display. Lightbox is a JavaScript library that displays images and videos by filling the screen, and dimming out the rest of the web page. (Source: Wikipedia0Issue while using Extent reports:
For failed cases screenshot will be captured and whenever user opens report.html for failed cases we can see images (local machine). Now if user shares the report to other person, if other person tries to access the images for failed cases it doesnt shows up :(
So here is one of the solutions which i found is implementing lightbox using javasriptFor Extent report initialization just use below code
public static void ExtentReportsInitialize(){
extent.init(reportLocation + "Report.html", true,DisplayOrder.BY_OLDEST_TO_LATEST,GridType.MASONRY);
extent.config().insertJS("$(document).ready(function(){"
+ " $('img.report-img').each(function(){"
+ "$(this).attr('data-featherlight','');"
+ " $(this).attr('src',$(this).attr('src').replace('file:///','')); "
+ "$(this).attr('href',$(this).attr('src'));"
+ " $(this).attr('data-featherlight','image');"
+ " })});");
extent.config().addCustomStyles(css);
}
public static String createScreenshot(WebDriver driver) {
// generate screenshot as a file object
return "data:image/png;base64,"+((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
}
With this code we can take the screenshot for all the failed cases and embed the screenshot in the report itself and click on image from the report will open the light box. With this no need to always maintain ‘Screenshot’ folder in separate. Images will be shown even if we share just ‘report.html’ file to any user (As images are embedded within the report).
if you have any question please comment below.
Thanks!
The blog gave me idea to add light box to extended reports and issues with the extended reports are explained in an understandable manner
ReplyDeleteSelenium Training in Chennai
I want to thank you for providing me the information.
ReplyDeleteYour articles are always so thoughtful.
It always tell me about new things.
Thanks a lot.
b.tech college in north india
Antalya
ReplyDeleteAntep
Burdur
Sakarya
istanbul
U4EN56
Adana
ReplyDeleteElazığ
Kayseri
Şırnak
Antep
C5T4
Yalova
ReplyDeleteHatay
Muş
Bursa
Mersin
LF2
van
ReplyDeletezonguldak
yalova
urfa
gümüşhane
C3SU5
görüntülüshow
ReplyDeleteücretli show
X8XZKW
Mersin Lojistik
ReplyDeleteAmasya Lojistik
Kayseri Lojistik
Kırklareli Lojistik
Erzurum Lojistik
KDOH5X
C788C
ReplyDeleteKırıkkale Evden Eve Nakliyat
Afyon Evden Eve Nakliyat
Tunceli Parça Eşya Taşıma
Osmaniye Evden Eve Nakliyat
Osmaniye Lojistik
63334
ReplyDeleteYozgat Parça Eşya Taşıma
Sakarya Şehir İçi Nakliyat
Gümüşhane Evden Eve Nakliyat
Bartın Evden Eve Nakliyat
Trabzon Evden Eve Nakliyat
Bitmart Güvenilir mi
Tekirdağ Fayans Ustası
Ankara Asansör Tamiri
Bitcoin Nasıl Alınır
ED38F
ReplyDeleteÜnye Yol Yardım
Sinop Lojistik
Gümüşhane Şehir İçi Nakliyat
Yozgat Evden Eve Nakliyat
Kırklareli Lojistik
Afyon Parça Eşya Taşıma
Siirt Şehir İçi Nakliyat
Sivas Şehir İçi Nakliyat
Etimesgut Parke Ustası
4F228
ReplyDeleteAydın Lojistik
Eskişehir Parça Eşya Taşıma
Çorlu Lojistik
Karabük Lojistik
Batıkent Parke Ustası
Karapürçek Boya Ustası
Kırıkkale Şehir İçi Nakliyat
Kütahya Şehirler Arası Nakliyat
Uşak Lojistik
51C50
ReplyDeleteApenft Coin Hangi Borsada
Mersin Lojistik
Afyon Şehir İçi Nakliyat
Silivri Boya Ustası
Kırıkkale Şehir İçi Nakliyat
Elazığ Şehir İçi Nakliyat
Eryaman Parke Ustası
Ankara Parke Ustası
Sonm Coin Hangi Borsada
FA1D0
ReplyDeletereferanskodunedir.com.tr
99150
ReplyDeleteSohbet
Bitcoin Kazanma
Bitcoin Kazanma Siteleri
Madencilik Nedir
Binance Hesap Açma
Bitcoin Oynama
Luffy Coin Hangi Borsada
Youtube İzlenme Hilesi
Binance Madenciliği Nedir
AF8D9
ReplyDeleteTwitter Trend Topic Hilesi
Tumblr Takipçi Satın Al
Referans Kimliği Nedir
Binance Borsası Güvenilir mi
Onlyfans Takipçi Satın Al
Instagram Beğeni Satın Al
Spotify Dinlenme Satın Al
Binance Referans Kodu
Bitcoin Nasıl Alınır