Public Member Functions | |
| def | __init__ (self, ctx) |
| Base class exposing attributes from the common context. More... | |
| def | close_all_browsers (self) |
| Closes all open browsers and resets the browser cache. More... | |
| def | close_browser (self) |
| Closes the current browser. More... | |
| def | create_webdriver (self, driver_name, alias=None, kwargs={}, **init_kwargs) |
| Creates an instance of Selenium WebDriver. More... | |
| def | get_location (self) |
| Returns the current browser URL. More... | |
| def | get_selenium_implicit_wait (self) |
| Gets the implicit wait value used by Selenium. More... | |
| def | get_selenium_speed (self) |
| Gets the delay that is waited after each Selenium command. More... | |
| def | get_selenium_timeout (self) |
| Gets the timeout that is used by various keywords. More... | |
| def | get_session_id (self) |
| Returns the currently active browser session id. More... | |
| def | get_source (self) |
| Returns the entire HTML source of the current page or frame. More... | |
| def | get_title (self) |
| Returns the title of current page. More... | |
| def | go_back (self) |
| Simulates the user clicking the back button on their browser. More... | |
| def | go_to (self, url) |
Navigates the active browser instance to the provided url. More... | |
| def | location_should_be (self, url, message=None) |
Verifies that current URL is exactly url. More... | |
| def | location_should_contain (self, expected, message=None) |
Verifies that current URL contains expected. More... | |
| def | log_location (self) |
| Logs and returns the current URL. More... | |
| def | log_source (self, loglevel='INFO') |
| Logs and returns the HTML source of the current page or frame. More... | |
| def | log_title (self) |
| Logs and returns the title of current page. More... | |
| def | open_browser (self, url, browser='firefox', alias=None, remote_url=False, desired_capabilities=None, ff_profile_dir=None, service_log_path=None) |
Opens a new browser instance to the given url. More... | |
| def | reload_page (self) |
| Simulates user reloading page. More... | |
| def | set_browser_implicit_wait (self, value) |
| Sets the implicit wait value used by Selenium. More... | |
| def | set_selenium_implicit_wait (self, value) |
| Sets the implicit wait value used by Selenium. More... | |
| def | set_selenium_speed (self, value) |
| Sets the delay that is waited after each Selenium command. More... | |
| def | set_selenium_timeout (self, value) |
| Sets the timeout that is used by various keywords. More... | |
| def | switch_browser (self, index_or_alias) |
Switches between active browsers using index_or_alias. More... | |
| def | title_should_be (self, title, message=None) |
Verifies that current page title equals title. 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 | warn (self, msg, html=False) |
Public Member Functions inherited from SeleniumLibrary.base.context.ContextAware | |
| 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 | _make_driver (self, browser, desired_capabilities=None, profile_dir=None, remote=None, service_log_path=None) |
| def | _make_new_browser (self, url, browser='firefox', alias=None, remote_url=False, desired_capabilities=None, ff_profile_dir=None, service_log_path=None) |
| def | _monkey_patch_speed (self, driver) |
| def | _wrap_event_firing_webdriver (self, driver) |
Private Attributes | |
| _window_manager | |
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 | |
Definition at line 31 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.__init__ | ( | self, | |
| ctx | |||
| ) |
Base class exposing attributes from the common context.
:param ctx: The library itself as a context object.
:type ctx: SeleniumLibrary.SeleniumLibrary
Reimplemented from SeleniumLibrary.base.context.ContextAware.
Definition at line 33 of file browsermanagement.py.
|
private |
Definition at line 503 of file browsermanagement.py.
|
private |
Definition at line 164 of file browsermanagement.py.
|
private |
Definition at line 514 of file browsermanagement.py.
|
private |
Definition at line 236 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.close_all_browsers | ( | self | ) |
Closes all open browsers and resets the browser cache.
After this keyword new indexes returned from `Open Browser` keyword
are reset to 1.
This keyword should be used in test or suite teardown to make sure
all browsers are closed.
Definition at line 46 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.close_browser | ( | self | ) |
Closes the current browser.
Definition at line 52 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.create_webdriver | ( | self, | |
| driver_name, | |||
alias = None, |
|||
kwargs = {}, |
|||
| ** | init_kwargs | ||
| ) |
Creates an instance of Selenium WebDriver.
Like `Open Browser`, but allows passing arguments to the created
WebDriver instance directly. This keyword should only be used if
functionality provided by `Open Browser` is not adequate.
``driver_name`` must be an WebDriver implementation name like Firefox,
Chrome, Ie, Opera, Safari, PhantomJS, or Remote.
The initialized WebDriver can be configured either with a Python
dictionary ``kwargs`` or by using keyword arguments ``**init_kwargs``.
These arguments are passed directly to WebDriver without any
processing. See [https://seleniumhq.github.io/selenium/docs/api/py/api.html|
Selenium API documentation] for details about the supported arguments.
Examples:
| # Use proxy with Firefox | | | |
| ${proxy}= | `Evaluate` | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver |
| ${proxy.http_proxy}= | `Set Variable` | localhost:8888 | |
| `Create Webdriver` | Firefox | proxy=${proxy} | |
| # Use proxy with PhantomJS | | | |
| ${service args}= | `Create List` | --proxy=192.168.132.104:8888 | |
| `Create Webdriver` | PhantomJS | service_args=${service args} | |
Returns the index of this browser instance which can be used later to
switch back to it. Index starts from 1 and is reset back to it when
`Close All Browsers` keyword is used. See `Switch Browser` for an
example.
Definition at line 216 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_location | ( | self | ) |
Returns the current browser URL.
Definition at line 297 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_selenium_implicit_wait | ( | self | ) |
Gets the implicit wait value used by Selenium.
The value is returned as a human readable string like ``1 second``.
See the `Implicit wait` section above for more information.
Definition at line 423 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_selenium_speed | ( | self | ) |
Gets the delay that is waited after each Selenium command.
The value is returned as a human readable string like ``1 second``.
See the `Selenium Speed` section above for more information.
Definition at line 403 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_selenium_timeout | ( | self | ) |
Gets the timeout that is used by various keywords.
The value is returned as a human readable string like ``1 second``.
See the `Timeout` section above for more information.
Definition at line 413 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_session_id | ( | self | ) |
Returns the currently active browser session id.
New in SeleniumLibrary 3.2
Definition at line 282 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_source | ( | self | ) |
Returns the entire HTML source of the current page or frame.
Definition at line 287 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.get_title | ( | self | ) |
Returns the title of current page.
Definition at line 292 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.go_back | ( | self | ) |
Simulates the user clicking the back button on their browser.
Definition at line 382 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.go_to | ( | self, | |
| url | |||
| ) |
Navigates the active browser instance to the provided url.
Definition at line 387 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.location_should_be | ( | self, | |
| url, | |||
message = None |
|||
| ) |
Verifies that current URL is exactly url.
The ``url`` argument contains the exact url that should exist in browser.
The ``message`` argument can be used to override the default error
message.
``message`` argument new in SeleniumLibrary 3.2.0.
Definition at line 310 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.location_should_contain | ( | self, | |
| expected, | |||
message = None |
|||
| ) |
Verifies that current URL contains expected.
The ``expected`` argument contains the expected value in url.
The ``message`` argument can be used to override the default error
message.
``message`` argument new in SeleniumLibrary 3.2.0.
Definition at line 329 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.log_location | ( | self | ) |
Logs and returns the current URL.
Definition at line 340 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.log_source | ( | self, | |
loglevel = 'INFO' |
|||
| ) |
Logs and returns the HTML source of the current page or frame.
The ``loglevel`` argument defines the used log level. Valid log
levels are ``WARN``, ``INFO`` (default), ``DEBUG``, ``TRACE``
and ``NONE`` (no logging).
Reimplemented from SeleniumLibrary.base.librarycomponent.LibraryComponent.
Definition at line 352 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.log_title | ( | self | ) |
Logs and returns the title of current page.
Definition at line 359 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.open_browser | ( | self, | |
| url, | |||
browser = 'firefox', |
|||
alias = None, |
|||
remote_url = False, |
|||
desired_capabilities = None, |
|||
ff_profile_dir = None, |
|||
service_log_path = None |
|||
| ) |
Opens a new browser instance to the given url.
The ``browser`` argument specifies which browser to use, and the
supported browser are listed in the table below. The browser names
are case-insensitive and some browsers have multiple supported names.
| = Browser = | = Name(s) = |
| Firefox | firefox, ff |
| Google Chrome | googlechrome, chrome, gc |
| Headless Firefox | headlessfirefox |
| Headless Chrome | headlesschrome |
| Internet Explorer | internetexplorer, ie |
| Edge | edge |
| Safari | safari |
| Opera | opera |
| Android | android |
| Iphone | iphone |
| PhantomJS | phantomjs |
| HTMLUnit | htmlunit |
| HTMLUnit with Javascript | htmlunitwithjs |
To be able to actually use one of these browsers, you need to have
a matching Selenium browser driver available. See the
[https://github.com/robotframework/SeleniumLibrary#browser-drivers|
project documentation] for more details. Headless Firefox and
Headless Chrome are new additions in SeleniumLibrary 3.1.0
and require Selenium 3.8.0 or newer.
Optional ``alias`` is an alias given for this browser instance and
it can be used for switching between browsers. When same ``alias``
is given with two `Open Browser` keywords, the first keyword will
open new browser. But the second one will switch to the already
opened browser and will not open new browser. The ``alias``
definition overrules ``browser`` definition. When same ``alias``
is used but different ``browser`` is defined, then switch to
browser with same alias is done and new browser is not opened.
An alternative approach for switching is using an index returned
by this keyword. These indices start from 1, are incremented when new
browsers are opened, and reset back to 1 when `Close All Browsers`
is called. See `Switch Browser` for more information and examples.
Optional ``remote_url`` is the URL for a
[https://github.com/SeleniumHQ/selenium/wiki/Grid2|Selenium Grid].
Optional ``desired_capabilities`` can be used to configure, for example,
logging preferences for a browser or a browser and operating system
when using [http://saucelabs.com|Sauce Labs]. Desired capabilities can
be given either as a Python dictionary or as a string in format
``key1:value1,key2:value2``.
[https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities|
Selenium documentation] lists possible capabilities that can be
enabled.
Optional ``ff_profile_dir`` is the path to the Firefox profile
directory if you wish to overwrite the default profile Selenium
uses. Notice that prior to SeleniumLibrary 3.0, the library
contained its own profile that was used by default.
Optional ``service_log_path`` argument defines the name of the
file where to write the browser driver logs. If the
``service_log_path`` argument contain a marker ``{index}``, it
will be automatically replaced with unique running
index preventing files to be overwritten. Indices start's 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].
Examples:
| `Open Browser` | http://example.com | Chrome |
| `Open Browser` | http://example.com | Firefox | alias=Firefox |
| `Open Browser` | http://example.com | Edge | remote_url=http://127.0.0.1:4444/wd/hub |
Alias examples:
| ${1_index} = | `Open Browser` | http://example.com | Chrome | alias=Chrome | # Opens new browser because alias is new. |
| ${2_index} = | `Open Browser` | http://example.com | Firefox | | # Opens new browser because alias is not defined. |
| ${3_index} = | `Open Browser` | http://example.com | Chrome | alias=Chrome | # Switches to the browser with Chrome alias. |
| ${4_index} = | `Open Browser` | http://example.com | Chrome | alias=${1_index} | # Switches to the browser with Chrome alias. |
| Should Be Equal | ${1_index} | ${3_index} | | | |
| Should Be Equal | ${1_index} | ${4_index} | | | |
| Should Be Equal | ${2_index} | ${2} | | | |
If the provided configuration options are not enough, it is possible
to use `Create Webdriver` to customize browser initialization even
more.
Applying ``desired_capabilities`` argument also for local browser is
new in SeleniumLibrary 3.1.
Using ``alias`` to decide, is the new browser opened is new
in SeleniumLibrary 4.0. Also the ``service_log_path`` is new
in SeleniumLibrary 4.0.
Definition at line 151 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.reload_page | ( | self | ) |
Simulates user reloading page.
Definition at line 393 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.set_browser_implicit_wait | ( | self, | |
| value | |||
| ) |
Sets the implicit wait value used by Selenium.
Same as `Set Selenium Implicit Wait` but only affects the current
browser.
Definition at line 500 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.set_selenium_implicit_wait | ( | self, | |
| value | |||
| ) |
Sets the implicit wait value used by Selenium.
The value can be given as a number that is considered to be
seconds or as a human readable string like ``1 second``.
The previous value is returned and can be used to restore
the original value later if needed.
This keyword sets the implicit wait for all opened browsers.
Use `Set Browser Implicit Wait` to set it only to the current
browser.
See the `Implicit wait` section above for more information.
Example:
| ${orig wait} = | `Set Selenium Implicit Wait` | 10 seconds |
| `Perform AJAX call that is slow` |
| `Set Selenium Implicit Wait` | ${orig wait} |
Definition at line 487 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.set_selenium_speed | ( | self, | |
| value | |||
| ) |
Sets the delay that is waited after each Selenium command.
The value can be given as a number that is considered to be
seconds or as a human readable string like ``1 second``.
The previous value is returned and can be used to restore
the original value later if needed.
See the `Selenium Speed` section above for more information.
Example:
| `Set Selenium Speed` | 0.5 seconds |
Definition at line 439 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.set_selenium_timeout | ( | self, | |
| value | |||
| ) |
Sets the timeout that is used by various keywords.
The value can be given as a number that is considered to be
seconds or as a human readable string like ``1 second``.
The previous value is returned and can be used to restore
the original value later if needed.
See the `Timeout` section above for more information.
Example:
| ${orig timeout} = | `Set Selenium Timeout` | 15 seconds |
| `Open page that loads slowly` |
| `Set Selenium Timeout` | ${orig timeout} |
Definition at line 461 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.switch_browser | ( | self, | |
| index_or_alias | |||
| ) |
Switches between active browsers using index_or_alias.
Indices are returned by the `Open Browser` keyword and aliases can
be given to it explicitly. Indices start from 1.
Example:
| `Open Browser` | http://google.com | ff |
| `Location Should Be` | http://google.com | |
| `Open Browser` | http://yahoo.com | ie | alias=second |
| `Location Should Be` | http://yahoo.com | |
| `Switch Browser` | 1 | # index |
| `Page Should Contain` | I'm feeling lucky | |
| `Switch Browser` | second | # alias |
| `Page Should Contain` | More Yahoo! | |
| `Close All Browsers` | | |
Above example expects that there was no other open browsers when
opening the first one because it used index ``1`` when switching to
it later. If you are not sure about that, you can store the index
into a variable as below.
| ${index} = | `Open Browser` | http://google.com |
| # Do something ... | | |
| `Switch Browser` | ${index} | |
Definition at line 268 of file browsermanagement.py.
| def SeleniumLibrary.keywords.browsermanagement.BrowserManagementKeywords.title_should_be | ( | self, | |
| title, | |||
message = None |
|||
| ) |
Verifies that current page title equals title.
The ``message`` argument can be used to override the default error
message.
``message`` argument is new in SeleniumLibrary 3.1.
Definition at line 372 of file browsermanagement.py.
|
private |
Definition at line 35 of file browsermanagement.py.