Robot Framework SeleniumLibrary
SeleniumLibrary.keywords.screenshot.ScreenshotKeywords Class Reference
Inheritance diagram for SeleniumLibrary.keywords.screenshot.ScreenshotKeywords:
SeleniumLibrary.base.librarycomponent.LibraryComponent SeleniumLibrary.base.context.ContextAware

Public Member Functions

def capture_element_screenshot (self, locator, filename='selenium-element-screenshot-{index}.png')
 Captures screenshot from the element identified by locator and embeds it into log file. More...
 
def capture_page_screenshot (self, filename='selenium-screenshot-{index}.png')
 Takes screenshot of the current page and embeds it into log file. More...
 
def set_screenshot_directory (self, path)
 Sets the directory for captured screenshots. More...
 
- Public Member Functions inherited from SeleniumLibrary.base.librarycomponent.LibraryComponent
def assert_page_contains (self, locator, tag=None, message=None, loglevel='TRACE')
 
def assert_page_not_contains (self, locator, tag=None, message=None, loglevel='TRACE')
 
def debug (self, msg, html=False)
 
def get_timeout (self, timeout=None)
 
def info (self, msg, html=False)
 
def log (self, msg, level='INFO', html=False)
 
def log_source (self, loglevel='INFO')
 
def warn (self, msg, html=False)
 
- Public Member Functions inherited from SeleniumLibrary.base.context.ContextAware
def __init__ (self, ctx)
 Base class exposing attributes from the common context. More...
 
def find_element (self, locator, tag=None, required=True, parent=None)
 Find element matching locator. More...
 
def find_elements (self, locator, tag=None, parent=None)
 Find all elements matching locator. More...
 
def is_element_enabled (self, locator, tag=None)
 
def is_text_present (self, text)
 
def is_visible (self, locator)
 

Private Member Functions

def _create_directory (self, path)
 
def _embed_to_log (self, path, width)
 
def _get_screenshot_path (self, filename)
 

Additional Inherited Members

- Public Attributes inherited from SeleniumLibrary.base.context.ContextAware
 ctx
 
- Properties inherited from SeleniumLibrary.base.librarycomponent.LibraryComponent
 log_dir = property
 
- Properties inherited from SeleniumLibrary.base.context.ContextAware
 driver = property
 
 drivers = property
 
 element_finder = property
 

Detailed Description

Definition at line 25 of file screenshot.py.

Member Function Documentation

◆ _create_directory()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords._create_directory (   self,
  path 
)
private

Definition at line 139 of file screenshot.py.

◆ _embed_to_log()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords._embed_to_log (   self,
  path,
  width 
)
private

Definition at line 144 of file screenshot.py.

◆ _get_screenshot_path()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords._get_screenshot_path (   self,
  filename 
)
private

Definition at line 127 of file screenshot.py.

◆ capture_element_screenshot()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords.capture_element_screenshot (   self,
  locator,
  filename = 'selenium-element-screenshot-{index}.png' 
)

Captures screenshot from the element identified by locator and embeds it into log file.

    See `Capture Page Screenshot` for details about ``filename`` argument.
    See the `Locating elements` section for details about the locator
    syntax.

    An absolute path to the created element screenshot is returned.

    Support for capturing the screenshot from a element has limited support
    among browser vendors. Please check the browser vendor driver documentation
    does the browser support capturing a screenshot from a element.

    New in SeleniumLibrary 3.3

    Examples:
    | `Capture Element Screenshot` | id:image_id |                                |
    | `Capture Element Screenshot` | id:image_id | ${OUTPUTDIR}/id_image_id-1.png |

Definition at line 115 of file screenshot.py.

◆ capture_page_screenshot()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords.capture_page_screenshot (   self,
  filename = 'selenium-screenshot-{index}.png' 
)

Takes screenshot of the current page and embeds it into log file.

    ``filename`` argument specifies the name of the file to write the
    screenshot into. The directory where screenshots are saved can be
    set when `importing` the library or by using the `Set Screenshot
    Directory` keyword. If the directory is not configured, screenshots
    are saved to the same directory where Robot Framework's log file is
    written.

    Starting from SeleniumLibrary 1.8, if ``filename`` contains marker
    ``{index}``, it will be automatically replaced with unique running
    index preventing files to be overwritten. Indices start from 1,
    and how they are represented can be customized using Python's
    [https://docs.python.org/3/library/string.html#format-string-syntax|
    format string syntax].

    An absolute path to the created screenshot file is returned.

    Examples:
    | `Capture Page Screenshot` |                                        |
    | `File Should Exist`       | ${OUTPUTDIR}/selenium-screenshot-1.png |
    | ${path} =                 | `Capture Page Screenshot`              |
    | `File Should Exist`       | ${OUTPUTDIR}/selenium-screenshot-2.png |
    | `File Should Exist`       | ${path}                                |
    | `Capture Page Screenshot` | custom_name.png                        |
    | `File Should Exist`       | ${OUTPUTDIR}/custom_name.png           |
    | `Capture Page Screenshot` | custom_with_index_{index}.png          |
    | `File Should Exist`       | ${OUTPUTDIR}/custom_with_index_1.png   |
    | `Capture Page Screenshot` | formatted_index_{index:03}.png         |
    | `File Should Exist`       | ${OUTPUTDIR}/formatted_index_001.png   |

Definition at line 85 of file screenshot.py.

◆ set_screenshot_directory()

def SeleniumLibrary.keywords.screenshot.ScreenshotKeywords.set_screenshot_directory (   self,
  path 
)

Sets the directory for captured screenshots.

    ``path`` argument specifies the absolute path to a directory where
    the screenshots should be written to. If the directory does not
    exist, it will be created. The directory can also be set when
    `importing` the library. If it is not configured anywhere,
    screenshots are saved to the same directory where Robot Framework's
    log file is written.

    The previous value is returned and can be used to restore
    the original value later if needed.

    Returning the previous value is new in SeleniumLibrary 3.0.
    The persist argument was removed in SeleniumLibrary 3.2.

Definition at line 43 of file screenshot.py.


The documentation for this class was generated from the following file: