<commit_before>from __future__ import absolute_import, unicode_literals

from abc import ABCMeta
from contextlib import contextmanager
import warnings

import robot.api
from robot.libraries.BuiltIn import BuiltIn

from selenium.webdriver.support.expected_conditions import staleness_of
from selenium.webdriver.support.ui import WebDriverWait

import six

from .locatormap import LocatorMap


class PageObject(six.with_metaclass(ABCMeta, object)):
    """Base class for page objects

    Classes that inherit from this class need to define the
    following class variables:

    PAGE_TITLE   the title of the page; used by the default
                 implementation of _is_current_page
    PAGE_URL     this should be the URL of the page, minus
                 the hostname and port (eg: /loginpage.html)

    By default, the PageObjectLibrary keyword 'the current page should
    be' calls the method _is_current_page. A default implementation is
    provided by this class. It compares the current page title to the
    class variable PAGE_TITLE. A class can override this method if the
    page title is not unique or is indeterminate.

    Classes that inherit from this class have access to the
    following properties:

    * selib     a reference to an instance of SeleniumLibrary
    * browser   a reference to the current webdriver instance
    * logger    a reference to robot.api.logger
    * locator   a wrapper around the page object's ``_locators`` dictionary

    This class implements the following context managers:

    * _wait_for_page_refresh

    This context manager is designed to be used in page objects when a
    keyword should wait to return until the html element has been
    refreshed.

    """

    PAGE_URL = None
    PAGE_TITLE = None

    def __init__(self):
        self.logger = robot.api.logger
        self.locator = LocatorMap(getattr(self, "_locators", {}))
        self.builtin = BuiltIn()

    # N.B. selib, browser use @property so that a
    # subclass can be instantiated outside of the context of a running
    # test (eg: by libdoc, robotframework-hub, etc)
    @property
    def se2lib(self):
        warnings.warn("se2lib is deprecated. Use selib intead.", warnings.DeprecationWarning)
        return self.selib

    @property
    def selib(self):
        return self.builtin.get_library_instance("SeleniumLibrary")

    @property
    def browser(self):
        return self.selib._current_browser()

    def __str__(self):
        return self.__class__.__name__<commit_msg>updated to work with latest version of SeleniumLibrary<commit_after>from __future__ import absolute_import, unicode_literals

from abc import ABCMeta
from contextlib import contextmanager
import warnings

import robot.api
from robot.libraries.BuiltIn import BuiltIn

from selenium.webdriver.support.expected_conditions import staleness_of
from selenium.webdriver.support.ui import WebDriverWait

import six

from .locatormap import LocatorMap


class PageObject(six.with_metaclass(ABCMeta, object)):
    """Base class for page objects

    Classes that inherit from this class need to define the
    following class variables:

    PAGE_TITLE   the title of the page; used by the default
                 implementation of _is_current_page
    PAGE_URL     this should be the URL of the page, minus
                 the hostname and port (eg: /loginpage.html)

    By default, the PageObjectLibrary keyword 'the current page should
    be' calls the method _is_current_page. A default implementation is
    provided by this class. It compares the current page title to the
    class variable PAGE_TITLE. A class can override this method if the
    page title is not unique or is indeterminate.

    Classes that inherit from this class have access to the
    following properties:

    * selib     a reference to an instance of SeleniumLibrary
    * browser   a reference to the current webdriver instance
    * logger    a reference to robot.api.logger
    * locator   a wrapper around the page object's ``_locators`` dictionary

    This class implements the following context managers:

    * _wait_for_page_refresh

    This context manager is designed to be used in page objects when a
    keyword should wait to return until the html element has been
    refreshed.

    """

    PAGE_URL = None
    PAGE_TITLE = None

    def __init__(self):
        self.logger = robot.api.logger
        self.locator = LocatorMap(getattr(self, "_locators", {}))
        self.builtin = BuiltIn()

    # N.B. selib, browser use @property so that a
    # subclass can be instantiated outside of the context of a running
    # test (eg: by libdoc, robotframework-hub, etc)
    @property
    def se2lib(self):
        warnings.warn("se2lib is deprecated. Use selib intead.", warnings.DeprecationWarning)
        return self.selib

    @property
    def selib(self):
        return self.builtin.get_library_instance("SeleniumLibrary")

    @property
    def browser(self):
        return self.selib.driver

    def __str__(self):
        return self.__class__.__name__
{'fraction_non_alphanumeric': 0.05158495766883245, 'fraction_numerical': 0.0007875566056310297, 'mean_word_length': 3.184514003294893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5913630', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1318, 'n_words': 552}