robotpageobjects.Page

Library version:1.7.2
Library scope:test suite
Named arguments:supported

Introduction

This is the base Page Object from which all other Page Objects should inherit. It contains all base Selenium2Library actions and browser-wrapping behavior used by this class and its descendents.

It is a robotframework library which implements the dynamic API.

All keywords listed in the Selenium2Library documentation are also available in this Page Object. See http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html

Shortcuts

Close · Get Hash · Go To · Hash Should Be · Is Visible · Log · Open · Resolve Selector · Wait For · Wait Until Alert Is Present

Keywords

Keyword Arguments Documentation
Close

Wrapper for Selenium2Library's close_browser. :returns: None

Get Hash

Alias: Get Hash On Page

Get the current location hash. :return: the current hash

Go To *args

Wrapper to make go_to method support uri templates.

Hash Should Be expected_value

Alias: Hash On Page Should Be

Is Visible selector

Get the visibility of an element by selector or locator :param selector: The selector or locator :type selector: str :return: whether the element is visible

Log msg, level=INFO, is_console=True

Logs either to Robot log file or to a file called po_log.txt at the current directory.

:param msg: The message to log :param level: The level to log at :type level: String corresponding to Robot or Python logging levels. See http://robot-framework.readthedocs.org/en/2.8.4/autodoc/robot.api.html?#log-levels for Robot log levels and http://docs.python.org/2/library/logging.html#levels for Python logging levels outside Robot.

:param is_console: Whether or not to log to stdout :type is_console: Boolean

Possible Robot levels are:

  • "WARN"
  • "INFO"
  • "DEBUG"
  • "TRACE"

In Robot, you set the logging threshold using the --loglevel, or -L option to filter out logging chatter. For example, by default the logging level is set to "INFO" so if you logged "DEBUG" messages, the messages would not get reported.

Robot logging messages get logged to stdout and to log.html.

Outside of Robot, possible logging levels are:

  • "CRITICAL"
  • "ERROR"
  • "WARNING"
  • "INFO"
  • "DEBUG"
  • "NOSET"

...and you set the logging threshold level using the PO_LOG_LEVEL environment variable or log_level variable in a variable file.

The Python logging module provides more logging levels than Robot provides; therefore, logging levels passed as strings to boththe log() method and the threshold level, are mapped to the closest supported Robot logging level and vice versa.

The default threshold for both Robot and Python is "INFO".

Open *args

Wrapper for Selenium2Library's open_browser() that calls resolve_url for url logic and self.browser. It also deletes cookies after opening the browser.

:param *args: A list or dictionary of variables mapping to a page object's uri template. For example given a template like this::

class MyPageObject(PageObject): uri = "category/{category}"

...

calling in Python::

... my_page_object.open({"category": "home-and-garden"})

or in Robot Framework::

... Open My Page Object category=home-and-garden

...would open the browser at: /category/home-and-garden

If no uri_var is passed the page object tries to open the browser at its uri attribute.

:param delete_cookies: If set to True, deletes browser's cookies when called. :type delete_cookies: Boolean :returns: _BaseActions instance

Resolve Selector selector, **keywords

Expands a selector template and returns a locator for use by Selenium2Library methods like click_element(). Pass the name of the selector template followed by keyword arguments matching the variables in the template.

:param selector: The name of the selector :type selector: String

Usage::

class MyPage(Page):

self.selectors = { "nth-para": "xpath=//p[{n}", ...

...

def click_nth_para(self, n): loc = self.resolve_selector("nth-para", n=n) self.click_element(loc)

Wait For condition, timeout=None, message=

Waits for a condition defined by the passed function to become True. :param condition: The condition to wait for :type condition: callable :param timeout: How long to wait for the condition, defaults to the selenium implicit wait :type condition: number :param message: Message to show if the wait times out :type condition: string :returns: None

Wait Until Alert Is Present timeout=None