nerodia package¶
Subpackages¶
- nerodia.elements package
- Submodules
- nerodia.elements.area module
- nerodia.elements.button module
- nerodia.elements.cell module
- nerodia.elements.check_box module
- nerodia.elements.d_list module
- nerodia.elements.element module
- nerodia.elements.file_field module
- nerodia.elements.font module
- nerodia.elements.form module
- nerodia.elements.hidden module
- nerodia.elements.html_elements module
- nerodia.elements.i_frame module
- nerodia.elements.image module
- nerodia.elements.input module
- nerodia.elements.link module
- nerodia.elements.list module
- nerodia.elements.option module
- nerodia.elements.radio module
- nerodia.elements.radio_set module
- nerodia.elements.row module
- nerodia.elements.select module
- nerodia.elements.svg_elements module
- nerodia.elements.table module
- nerodia.elements.table_cell module
- nerodia.elements.table_data_cell module
- nerodia.elements.table_row module
- nerodia.elements.table_section module
- nerodia.elements.text_area module
- nerodia.elements.text_field module
- Module contents
- nerodia.wait package
Submodules¶
nerodia.after_hooks module¶
-
class
nerodia.after_hooks.
AfterHooks
(browser)[source]¶ Bases:
object
After hooks are blocks that run after certain browser events. They are generally used to ensure application under test does not encounter any error and are automatically executed after following events:
- Open URL.
- Refresh page.
- Click, double-click or right-click on element.
- Alert closing.
-
add
(method=None, after_hook=None)[source]¶ Adds new after hook :param method: callable method :param after_hook: callable object
Example: from __future__ import print_function browser.after_hooks.add(method=lambda b: ‘Server Error’ in browser.text and print(‘Application exception or 500 error!’) browser.goto(‘watir.github.io/404’) #=> ‘Application exception or 500 error!’
-
delete
(after_hook)[source]¶ Deletes after hook :param after_hook: hook to delete
Example: from __future__ import print_function browser.after_hooks.add(method=lambda b: ‘Server Error’ in browser.text and print(‘Application exception or 500 error!’) browser.goto(‘watir.github.io/404’) #=> ‘Application exception or 500 error!’ browser.after_hooks.delete(browser.after_hooks[0]) browser.refresh
nerodia.alert module¶
-
class
nerodia.alert.
Alert
(browser)[source]¶ Bases:
nerodia.wait.wait.Waitable
-
close
()[source]¶ Closes alert or cancels prmopts/confirms
Example: browser.alert.close() browser.alert.exists #=> False
-
exists
¶ Returns True if alert, confirm, or prompt is present and False otherwise :rtype: bool
Example: browser.alert.exists #=> True
-
ok
()[source]¶ Closes alert or accepts prompts/confirms
Example: browser.alert.ok browser.alert.exists #=> False
-
present
¶ Returns True if alert, confirm, or prompt is present and False otherwise :rtype: bool
Example: browser.alert.exists #=> True
-
selector_string
¶
-
set
(value)[source]¶ Enters text to prompt :param value: keys to send
Example: browser.alert.set(‘Text for prompt’) browser.alert.ok()
-
text
¶ Returns the text of the alert :rtype: str
Example: browser.alert.text #=> ‘ok’
-
nerodia.browser module¶
-
class
nerodia.browser.
Browser
(browser='chrome', *args, **kwargs)[source]¶ Bases:
nerodia.container.Container
,nerodia.has_window.HasWindow
,nerodia.wait.wait.Waitable
,nerodia.elements.scroll.Scrolling
-
alert
¶ Handles Javascript alerts, confirms and prompts :rtype: nerodia.alert.Alert
-
browser
¶
Handles cookies :rtype: nerodia.cookies.Cookies
-
execute_script
(script, *args)[source]¶ Executes JavaScript snippet :param script: Javascript Snippet to execute :type script: str :param args: Arguments will be available in the given script in the ‘arguments’ pseudo-array :return: result of script
-
exist
¶ True if browser is not closed and False otherwise :rtype: bool
-
exists
¶ True if browser is not closed and False otherwise :rtype: bool
-
goto
(uri)[source]¶ Goes to the given URL :param uri: the URL :type uri: str :return: the url you end up at :rtype: str
-
html
¶ Returns HTML code of the current page :rtype: str
-
locator_namespace
¶ Whether the locators should be used from a different namespace. Defaults to nerodia.locators :return:
-
name
¶ Returns the browser name :rtype: str
-
quit
()¶ Closes the browser
-
ready_state
¶ Returns the readyState of the document :rtype: str
-
screenshot
¶ Handles screenshots of current pages :rtype: nerodia.screenshot.Screenshot
-
selector_string
()¶ x.__repr__() <==> repr(x)
-
send_keys
(*args)[source]¶ Sends sequence of keystrokes to currently active element :param args: keystrokes
-
static
start
(url, browser='chrome', *args, **kwargs)[source]¶ Creates a Browser instance :param url: url to navigate to after starting browser :type url: str :param browser: firefox, ie, chrome, remote or Selenium WebDriver instance :type browser: selenium.webdriver.remote.webdriver.WebDriver or str :param args: args passed to the underlying driver :param kwargs: kwargs passed to the underlying driver
-
status
¶ Returns the text of the status bar :return:
-
text
¶ Returns the text of the page body :return:
-
timer
¶
-
title
¶ Returns the title of the current page :rtype: str
-
url
¶ Returns the URL of the current page :rtype: str
-
wait
(timeout=5)[source]¶ Waits until the readyState of document is complete, raises a TimeoutException if timeout is exceeded :param timeout: time to wait :type timeout: int
-
wd
¶
-
See also
See nerodia.container.Container
for all possible element containers.
See also
See nerodia.has_window.HasWindow
for accessing windows.
See also
See nerodia.wait.wait.Waitable
for wait methods.
nerodia.container module¶
nerodia.cookies module¶
Bases:
object
Adds new cookie
Example: browser.cookies.add(‘my_session’, ‘BAh7B0kiD3Nlc3Npb25faWQGOgZFRkk’, domain=’mysite.com’)
Deletes all cookies
Deletes cookie by given name
Loads cookies from file
Parameters: file – file path Example: browser.cookies.load(‘.cookies’)
Save cookies to file
Parameters: file – file path Example: browser.cookies.save(‘.cookies’)
nerodia.element_collection module¶
-
class
nerodia.element_collection.
ElementCollection
(query_scope, selector)[source]¶ Bases:
nerodia.locators.class_helpers.ClassHelpers
,nerodia.js_snippet.JSSnippet
-
browser
¶ Returns the browser of the current query_scope
Return type: nerodia.browser.Browser
-
eql
(other)¶ Returns true if two element collections are equal.
Parameters: other – other collection Return type: bool Example: browser.select_list(name=’new_user_languages’).options == browser.select_list(id=’new_user_languages’).options #=> True
browser.select_list(name=;new_user_role’).options == browser.select_list(id=’new_user_languages’).options #=> false
-
is_empty
¶ Returns True if no elements are found
Example: browser.select_list(name=’new_user_languages’).options(class_name=’not_here’).is_empty
Example: browser.select_list(name=’new_user_languages’).options(id=’danish’).is_empty
Returns: True if no elements are found Return type: bool
-
locate
()[source]¶ Locate all elements and return self
Return type: ElementCollection
-
to_list
¶ This collection as a list
Return type: list[nerodia.elements.element.Element]
-
nerodia.has_window module¶
-
class
nerodia.has_window.
HasWindow
[source]¶ Bases:
object
-
original_window
¶ Returns original window if defined, current window if not :rtype: Window
Example: browser.window(title=’closeable window’).use() browser.original_window.use()
-
nerodia.logger module¶
nerodia.screenshot module¶
-
class
nerodia.screenshot.
Screenshot
(browser)[source]¶ Bases:
object
-
base64
()[source]¶ Represents screenshot as Base64 encoded string :rtype: str
Example: browser.screenshot.base64 #=> ‘7HWJ43tZDscPleeUuPW6HhN3x+z7vU/lufmH0qNTtTum94IBWMT46evImci1vnFGT’
-
nerodia.window module¶
-
class
nerodia.window.
Window
(browser, selector)[source]¶ Bases:
nerodia.wait.wait.Waitable
-
eql
(other)¶ Returns True if two windows are equal :param other: the other window :rtype: bool
Example: browser.window(index=0) == browser.window(index=1) #=> False
-
exist
¶ Returns True if the window exists :rtype: bool
-
exists
¶ Returns True if the window exists :rtype: bool
-
handle
¶
-
is_current
¶ Returns True if the window is current
Example: browse.window.is_current
Return type: bool
-
move_to
(x, y)[source]¶ Moves window to given x and y coordinates :param x: horizontal position :param y: vertical position
Example: browser.window().move_to(300, 200)
-
position
¶ Returns window position :rtype: dict
Example: browser.window().position #=> {x: 92, y: 76}
-
present
¶ Returns True if the window exists :rtype: bool
-
resize_to
(width, height)[source]¶ Resizes window to given width and height :param width: width to resize to :param height: height to resize to
Example: browser.window().resize_to(1600, 1200)
-
selector_string
¶
-
size
¶ Returns window size :rtype: dict
Example: browser.window().size #=> {width: 1600, height: 1200}
-
title
¶ Returns the window title :rtype: str
-
unuse
()[source]¶ Returns to the original window
Example: window = browser.window(title=’closeable window’).use() window.unuse() :rtype: Window
-
url
¶ Returns the window URL :rtype: str
-