package Ġcom . kas per sky . kas press o . device . screenshots Ċ Ċ import Ġcom . kas per sky . kas press o . device . screenshots . screenshot files . Screenshot Directory Provider Ċ import Ġcom . kas per sky . kas press o . device . screenshots . screenshot files . Screenshot File Provider Ċ import Ġcom . kas per sky . kas press o . device . screenshots . screenshot files . Screenshot Name Provider Ċ import Ġcom . kas per sky . kas press o . device . screenshots . screenshot maker . Screenshot Maker Ċ import Ġcom . kas per sky . kas press o . internal . extensions . other . get StackTrace AsString Ċ import Ġcom . kas per sky . kas press o . logger . Ui Test Logger Ċ import Ġjava . io . File Ċ Ċ /** Ċ Ġ* ĠThe Ġimplementation Ġof Ġthe Ġ[ Screenshots ] Ġinterface . Ċ Ġ*/ Ċ class ĠScreenshots Impl ( ĊĠĠĠ Ġprivate Ġval Ġlogger : ĠUi Test Logger , ĊĠĠĠ Ġprivate Ġval Ġscreenshot Maker : ĠScreen shot Maker , ĊĠĠĠ Ġscreenshot Directory Provider : ĠScreen shot Directory Provider , ĊĠĠĠ Ġscreenshot Name Provider : ĠScreen shot Name Provider , ĊĠĠĠ Ġscreenshot Root Dir : ĠFile Ġ= ĠFile (" screenshots ") Ċ ) Ġ: ĠScreenshots , ĠScreen shot Test Start Listener Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġfile Provider Ġ= ĠScreen shot File Provider ( screenshot Directory Provider , Ġscreenshot Name Provider , Ġscreenshot Root Dir ) ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠTakes Ġa Ġscreenshot Ġif Ġit Ġis Ġpossible , Ġotherwise Ġlogs Ġthe Ġerror . ĊĠĠĠĠ Ġ* ĠBy Ġdefault Ġa Ġscreenshot Ġname Ġlooks Ġlike Ġ< device Ġstorage >/ screenshot Root Dir /< test Ġrun Ġnumber >/< test Ġclass Ġname >/< test Ġmethod Ġname >/ [ tag ]. png ĊĠĠĠĠ Ġ* ĠSee Ġ[ Screenshot File Provider ], Ġ[ Screenshot Directory Provider ] Ġfor Ġmore Ġdetails ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* ĠRequired ĠPermissions : ĠWRITE _ EXTERNAL _ STORAGE . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġtag Ġa Ġunique Ġtag Ġto Ġfurther Ġidentify Ġthe Ġscreenshot . ĠMust Ġmatch Ġ[ a - zA - Z 0 - 9 _- ]+ . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġtake ( tag : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Catch ing Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfile Ġ= Ġfile Provider . get Screenshot File ( tag ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscreenshot Maker . take Screenshot ( file ) ĊĠĠĠĠĠĠĠ Ġ}. on Failure Ġ{ Ġe Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . e (" An Ġerror Ġwhile Ġmaking Ġscreenshot Ġoccurred : Ġ${ e . get StackTrace AsString () }") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Test Started () Ġ{ ĊĠĠĠĠĠĠĠ Ġfile Provider . increment Run NumberOf Current Test () ĊĠĠĠ Ġ} Ċ }