<s> import os <EOL> import robot <EOL> from keywordgroup import KeywordGroup <EOL> from util import * <EOL> class Screenshot ( KeywordGroup ) : <EOL> def __init__ ( self ) : <EOL> self . _screenshot_index = <NUM_LIT:0> <EOL> def capture_page_screenshot ( self , filename = None ) : <EOL> """<STR_LIT>""" <EOL> path , link = self . _get_screenshot_paths ( filename ) <EOL> if hasattr ( Util . driver , '<STR_LIT>' ) : <EOL> Util . driver . get_screenshot_as_file ( path ) <EOL> else : <EOL> Util . driver . save_screenshot ( path ) <EOL> self . _html ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( link , link ) ) <EOL> def _get_screenshot_paths ( self , filename ) : <EOL> if not filename : <EOL> self . _screenshot_index += <NUM_LIT:1> <EOL> if Util . device == '<STR_LIT>' : <EOL> filename = '<STR_LIT>' % ( Util . platform , self . _screenshot_index ) <EOL> else : <EOL> filename = '<STR_LIT>' % ( Util . platform , Util . device , self . _screenshot_index ) <EOL> else : <EOL> filename = filename . replace ( '<STR_LIT:/>' , os . sep ) <EOL> logdir = self . _get_log_dir ( ) <EOL> path = os . path . join ( logdir , filename ) <EOL> link = robot . utils . get_link_path ( path , logdir ) <EOL> return path , link </s>
