text
stringlengths
81
112k
Attempts to immediately find elements on the page without waiting @type locator: webdriverwrapper.support.locator.Locator @param locator: Locator object describing @type search_object: webdriverwrapper.WebElementWrapper @param search_object: Optional WebElement to ...
Find all elements matching locator @type locator: webdriverwrapper.support.locator.Locator @param locator: Locator object describing @rtype: list[WebElementWrapper] @return: list of WebElementWrappers def find_all(self, locator, search_o...
Find with dynamic locator @type template_locator: webdriverwrapper.support.locator.Locator @param template_locator: Template locator w/ formatting bits to insert @type variables: dict @param variables: Dictionary of variable substitutions ...
Determines whether an element is present on the page, retrying once if unable to locate @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string used to query the element @type search_object: webdriverwrapper.W...
Determines whether an element is present on the page with no wait @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string used to query the element def is_present_no_wait(self, locator): """ Determines whether an element is present on the page...
Base wait method: called by other wait functions to execute wait @type wait_function: types.FunctionType @param wait_function: Generic function to be executed @type failure_message: str @param failure_message: Message to fail with if exception is raised @type timeout: ...
Waits for an element to be present @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string to search for the element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: ...
Waits for an element to no longer be present @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string to search for the element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @r...
Waits for an element to be invisible @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string to search for the element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: ...
Waits for an element to be clickable @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string to search for the element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: ...
Waits for an element to be stale in the DOM @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string to search for the element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rt...
Waits for title to contain <partial_title> @type partial_title: str @param partial_title: the partial title to locate @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: webdriverw...
Waits for title to be exactly <partial_title> @type title: str @param title: the exact title to locate @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: webdriverwrapper.WebEleme...
Waits for an alert to be present @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: webdriverwrapper.WebElementWrapper @return: Returns the element found def wait_until_alert_i...
Waits for an element's text to contain <text> @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used to find element @type text: str @param text: the text to search for @type timeout: int @par...
Waits for an element's text to not be empty @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used to find element @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out ...
Waits for the page source to contain <text> @type text: str @param text: the text to search for @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @rtype: webdriverwrapp...
Waits for AJAX requests made through @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @return: None def wait_until_jquery_requests_are_closed(self, timeout=None): """Waits for AJAX requests made through @type timeou...
Executor for wait functions @type function_to_execute: types.FunctionType @param function_to_execute: wait function specifying the type of wait @type timeout: int @param timeout: the maximum number of seconds the driver will wait before timing out @type...
Injects a radio button into the page and waits for the user to click it; will raise an exception if the radio to resume is never checked @return: None def pause_and_wait_for_user(self, timeout=None, prompt_text='Click to resume (WebDriver is paused)'): """Injects a radio button into the page a...
Gets the console log of the browser @type levels: @return: List of browser log entries def get_browser_log(self, levels=None): """Gets the console log of the browser @type levels: @return: List of browser log entries """ logs = self.driver.get_log('browser') ...
Close driver and kill all associated displays def quit(self): """Close driver and kill all associated displays """ # Kill the driver def _quit(): try: self.driver.quit() except Exception, err_driver: os.kill(self.driver_pid, sign...
Visit the url, checking for rr errors in the response @param url: URL @return: Visit result def visit(self, url=''): """Visit the url, checking for rr errors in the response @param url: URL @return: Visit result """ result = super(CoyoteDriver, self).visit(url)...
Loads all attributes from source config into target config @type target_config: TestRunConfigManager @param target_config: Config to dump variables into @type source_config: TestRunConfigManager @param source_config: The other config @return: True def load_config_vars(target_config, source_config)...
Read configs from all available configs. It will read files in the following order: 1.) Read all default settings: These are located under: `<project_root>/config/*/default.cfg` 2.) Read the user's config settings: This is located on the path: `~/.aftrc` ...
Runs a series of functions in parallel. Return values are ordered by the order in which their functions were passed. >>> val1, val2 = run_parallel( >>> lambda: 1 + 1 >>> lambda: 0 >>> ) If an exception is raised within one of the processes, that exception will be caught...
Returns an updated copy of the dictionary without modifying the original def copy_and_update(dictionary, update): """Returns an updated copy of the dictionary without modifying the original""" newdict = dictionary.copy() newdict.update(update) return newdict
Retrieves the full path of the static directory @return: Full path of the static directory def get_static_directory(): """Retrieves the full path of the static directory @return: Full path of the static directory """ directory = templates_dir = os.path.join(os.path.dirname(__file__), 'static') ...
Reads the contents of an html file in the css directory @return: Contents of the specified file def read_html_file(filename): """Reads the contents of an html file in the css directory @return: Contents of the specified file """ with open(os.path.join(get_static_directory(), 'html/{filename}'.for...
Parses a valid selenium By and value from a locator; returns as a named tuple with properties 'By' and 'value' locator -- a valid element locator or css string def parse_locator(locator): """ Parses a valid selenium By and value from a locator; returns as a named tuple with pro...
Locate an element using either a webdriver or webelement @param webdriver_or_element: Webdriver or Webelement object used for search @type locator: webdriver.webdriverwrapper.support.locator.Locator @param locator: locator used in search @type find_al...
Asserts that assertion function passed to it will return True, trying every 'step' seconds until 'timeout' seconds have passed. def spin_assert(self, assertion, failure_message='Failed Assertion', timeout=None): """ Asserts that assertion function passed to it will return True, trying e...
Assert the assertion, but throw a WebDriverAssertionException if assertion fails def webdriver_assert(self, assertion, failure_message='Failed Assertion'): """ Assert the assertion, but throw a WebDriverAssertionException if assertion fails """ try: assert assertion() is Tru...
Asserts that a value is true @type value: bool @param value: value to test for True def assert_true(self, value, failure_message='Expected value to be True, was: {}'): """ Asserts that a value is true @type value: bool @param value: value to test for True ...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the '==' operator def assert_equals(self, actual_val, expected_val, failure_message='Expected values to be equal: "{}" and "{}"'): """ Calls smart_assert, but creates its own assertion closure ...
Asserts that two numbers are within an allowed delta of each other def assert_numbers_almost_equal(self, actual_val, expected_val, allowed_delta=0.0001, failure_message='Expected numbers to be within {} of each other: "{}" and "{}"'): """ Asserts that two numbers are...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the '!=' operator def assert_not_equal(self, actual_val, unexpected_val, failure_message='Expected values to differ: "{}" and "{}"'): """ Calls smart_assert, but creates its own assertion closu...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'is' operator def assert_is(self, actual_val, expected_type, failure_message='Expected type to be "{1}," but was "{0}"'): """ Calls smart_assert, but creates its own assertion closure using...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'is not' operator def assert_is_not(self, actual_val, unexpected_type, failure_message='Expected type not to be "{1}," but was "{0}"'): """ Calls smart_assert, but cre...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'in' operator def assert_in(self, actual_collection_or_string, expected_value, failure_message='Expected "{1}" to be in "{0}"'): """ Calls smart_assert, but creates its own assertion closur...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'not in' operator def assert_not_in(self, actual_collection_or_string, unexpected_value, failure_message='Expected "{1}" not to be in "{0}"'): """ Calls smart_assert, ...
Asserts that the page source contains the string passed in expected_value def assert_page_source_contains(self, expected_value, failure_message='Expected page source to contain: "{}"'): """ Asserts that the page source contains the string passed in expected_value """ assertion = lambda:...
Asserts that the union of two sets has at least one member (collections share at least one member) def assert_union(self, collection1, collection2, failure_message='Expected overlap between collections: "{}" and "{}"'): """ Asserts that the union of two sets has at least one member...
Asserts that the union of two sets is empty (collections are unique) def assert_no_union(self, collection1, collection2, failure_message='Expected no overlap between collections: "{}" and "{}"'): """ Asserts that the union of two sets is empty (collections are unique) ""...
Asserts that a superset contains all elements of a subset def assert_subset(self, subset, superset, failure_message='Expected collection "{}" to be a subset of "{}'): """ Asserts that a superset contains all elements of a subset """ assertion = lambda: set(subset).issubset(set(superset)...
Clears the field represented by this element @rtype: WebElementWrapper @return: Returns itself def clear(self): """ Clears the field represented by this element @rtype: WebElementWrapper @return: Returns itself """ def clear_element(): ...
Deletes content in the input field by repeatedly typing HOME, then DELETE @rtype: WebElementWrapper @return: Returns itself def delete_content(self, max_chars=100): """ Deletes content in the input field by repeatedly typing HOME, then DELETE @rtype: WebElementWrapp...
Clicks the element @type force_click: bool @param force_click: force a click on the element using javascript, skipping webdriver @rtype: WebElementWrapper @return: Returns itself def click(self, force_click=False): """ Clicks the element ...
Gets the value of a select or input element @rtype: str @return: The value of the element @raise: ValueError if element is not of type input or select, or has multiple selected options def get_value(self): """Gets the value of a select or input element @rtype: str @ret...
Retrieves specified attribute from WebElement @type name: str @param name: Attribute to retrieve @rtype: str @return: String representation of the attribute def get_attribute(self, name): """ Retrieves specified attribute from WebElement ...
Tests if the element is within the viewport of the screen (partially hidden by overflow will return true) @return: True if on screen, False otherwise def is_on_screen(self): """Tests if the element is within the viewport of the screen (partially hidden by overflow will return true) @return: T...
Send special keys such as <enter> or <delete> @rtype: WebElementWrapper @return: Self def send_special_keys(self, value): """ Send special keys such as <enter> or <delete> @rtype: WebElementWrapper @return: Self """ def send_keys_element()...
Sets an input with a specified value; if force_set=True, will set through javascript if webdriver fails NOTE: if val is None, this function will interpret this to be an empty string @type val: str @param val: string to send to element @type force_set: bool @p...
Submit a webe element @rtype: WebElementWrapper @return: Self def submit(self): """ Submit a webe element @rtype: WebElementWrapper @return: Self """ def submit_element(): """ Wrapper to submit element "...
Get value of CSS property for element @rtype: str @return: value of CSS property def value_of_css_property(self, property_name): """ Get value of CSS property for element @rtype: str @return: value of CSS property """ def value_of_css_prop...
Test if an element has a specific classname @type classname: str @param classname: Classname to test for; cannot contain spaces @rtype: bool @return: True if classname exists; false otherwise def has_class(self, classname): """Test if an element has a specific classname ...
Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked def parent(self): """ Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was inv...
Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked def parent_element(self): """ Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this...
Get the text of the element @rtype: str @return: Text of the element def text(self, force_get=False): """ Get the text of the element @rtype: str @return: Text of the element """ def text_element(): """ Wrapper to g...
Draws a dotted red box around the wrapped element using javascript @rtype: WebElementWrapper @return: Self def highlight(self): """ Draws a dotted red box around the wrapped element using javascript @rtype: WebElementWrapper @return: Self """ ...
Sets the attribute of the element to a specified value @type name: str @param name: the name of the attribute @type value: str @param value: the attribute of the value def set_attribute(self, name, value): """Sets the attribute of the element to a specified value ...
Selects an option by value, text, or index. You must name the parameter @type value: str @param value: the value of the option @type text: str @param text: the option's visible text @type index: int @param index: the zero-based index of the option ...
De-selects an option by value, text, or index. You must name the parameter @type value: str @param value: the value of the option @type text: str @param text: the option's visible text @type index: int @param index: the zero-based index of the option ...
Private method used by select methods @type select_or_deselect: str @param select_or_deselect: Should I select or deselect the element @type value: str @type value: Value to be selected @type text: str @type text: ...
Wrapper to check a checkbox def checkbox_check(self, force_check=False): """ Wrapper to check a checkbox """ if not self.get_attribute('checked'): self.click(force_click=force_check)
Wrapper to uncheck a checkbox def checkbox_uncheck(self, force_check=False): """ Wrapper to uncheck a checkbox """ if self.get_attribute('checked'): self.click(force_click=force_check)
Hovers the element def hover(self): """ Hovers the element """ def do_hover(): """ Perform hover """ ActionChains(self.driver_wrapper.driver).move_to_element(self.element).perform() return self.execute_and_handle_webelement_excepti...
Find wrapper, invokes webDriverWrapper find with the current element as the search object @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @type find_all: bool @param find_all: should I find all elements, or j...
Find wrapper to run a single find @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @type find_all: bool @param find_all: should I find all elements, or just one? @rtype: WebElementWrap...
Find wrapper, finds all elements @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: list @return: A list of WebElementWrappers def find_all(self, locator): """ Find wrap...
Tests to see if an element is present @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: bool @return: True if present, False if not present def is_present(self, locator): """ ...
Waits for the element to go stale in the DOM @type timeout: int @param timeout: override for default timeout @rtype: WebElementWrapper @return: Self def wait_until_stale(self, timeout=None): """ Waits for the element to g...
Private method to be called by other methods to handle common WebDriverExceptions or throw a custom exception @type function_to_execute: types.FunctionType @param function_to_execute: A function containing some webdriver calls @type name_of_action: str @param ...
Makes a request using requests @param uri: The uri to send request @param method: Method to use to send request @param headers: Any headers to send with request @param cookies: Request cookies (in addition to session cookies) @param params: Request parameters @param data...
Saves the body of the last response to a file @param filename: Filename to save to @return: Returns False if there is an OS error, True if successful def save_last_response_to_file(self, filename): """Saves the body of the last response to a file @param filename: Filename to save to ...
Saves the body of the last response to a file @param filename: Filename to save to @return: Returns False if there is an OS error, True if successful def save_response_to_file(self, response, filename): """Saves the body of the last response to a file @param filename: Filename to save...
Validates that the url can be opened and responds with an allowed response code; ignores javascript: urls url -- the string url to ping allowed_response_codes -- a list of response codes that the validator will ignore def validate_url(url, allowed_response_codes=None): """Validates that the url can be ope...
Validates that a list of urls can be opened and each responds with an allowed response code urls -- the list of urls to ping allowed_response_codes -- a list of response codes that the validator will ignore def validate_urls(urls, allowed_response_codes=None): """Validates that a list of urls can be opene...
Instantiates a new WebDriver instance, determining class by environment variables def new_driver(browser_name, *args, **kwargs): """Instantiates a new WebDriver instance, determining class by environment variables """ if browser_name == FIREFOX: return webdriver.Firefox(*args, **kwa...
Build a URL for the /follow page def build_follow_url(host=None, **params): """ Build a URL for the /follow page """ # template = '?{params}' config = ExampleConfig() template = '/follow?{params}' if not host: host = config.get('example_web_hostname...
Encodes all the string keys and values in a collection with specified encoding def encode_collection(collection, encoding='utf-8'): """Encodes all the string keys and values in a collection with specified encoding""" if isinstance(collection, dict): return dict((encode_collection(key), encode_collecti...
Given a list, returns a string representation of that list with specified delimiter and optional string chars _list -- the list or tuple to stringify delimiter -- the the character to seperate all values wrap_values_with_char -- if specified, will wrap all values in list with this character in the represen...
Execute script passed in to function @type string: str @value string: Script to execute @type args: dict @value args: Dictionary representing command line args @rtype: int @rtype: response code def execute_script(self, string, args=None): ...
Execute script from a template @type template_name: str @value template_name: Script template to implement @type args: dict @value args: Dictionary representing command line args @rtype: bool @rtype: Success or...
Execute script from a template and return result @type template_name: str @value template_name: Script template to implement @type variables: dict @value variables: Dictionary representing template construction args @type args: dict @value a...
Build a JS script from a template and args @type template_file: str @param template_file: Script template to implement; can be the name of a built-in script or full filepath to a js file that contains the script. E.g. 'clickElementTemplate.js', ...
Builds a url with a string template and template variables; relative path if host is None, abs otherwise: template format: "/staticendpoint/{dynamic_endpoint}?{params}" def build(template='/', host=None, scheme=None, port=None, **template_vars): """Builds a url with a string template and template v...
Calls the function until bool(return value) is truthy @param step: Wait time between each function call @param timeout: Max amount of time that will elapse. If the function is in progress when timeout has passed, the function will be allowed to complete. @type ignore_exceptions: tuple @param ignore...
Formats the locator with specified parameters def build(self, **variables): """Formats the locator with specified parameters""" return Locator(self.by, self.locator.format(**variables), self.description)
Gets a def random_words_string(count=1, maxchars=None, sep=''): """Gets a """ nouns = sep.join([random_word() for x in xrange(0, count)]) if maxchars is not None and nouns > maxchars: nouns = nouns[0:maxchars-1] return nouns
Tests if a hostname is a subdomain of a reference hostname e.g. www.domain.com is subdomain of reference @param domain: Domain to test if it is a subdomain @param reference: Reference "parent" domain def is_subdomain(domain, reference): """Tests if a hostname is a subdomain of a reference hostname ...
Adds all cookies in the RequestDriver session to Webdriver @type requestdriver: RequestDriver @param requestdriver: RequestDriver with cookies @type webdriverwrapper: WebDriverWrapper @param webdriverwrapper: WebDriverWrapper to receive cookies @param handle_sub_domain: If True, will check driver u...
Adds all cookies in the Webdriver session to requestdriver @type requestdriver: RequestDriver @param requestdriver: RequestDriver with cookies @type webdriver: WebDriverWrapper @param webdriver: WebDriverWrapper to receive cookies @rtype: None @return: None def dump_webdriver_cookies_into_requ...
Gets the firefox binary @rtype: FirefoxBinary def get_firefox_binary(): """Gets the firefox binary @rtype: FirefoxBinary """ browser_config = BrowserConfig() constants_config = ConstantsConfig() log_dir = os.path.join(constants_config.get('logs_dir'), 'firefox') create_directory(log_d...
Raises an assertion error if the page has severe console errors @param driver: ShapewaysDriver @return: None def _log_fail_callback(driver, *args, **kwargs): """Raises an assertion error if the page has severe console errors @param driver: ShapewaysDriver @return: None """ try: l...
Clones the object and updates the clone with the args @param kwargs: Keyword arguments to set @return: The cloned copy with updated values def clone_and_update(self, **kwargs): """Clones the object and updates the clone with the args @param kwargs: Keyword arguments to set @re...
Render the body of the message to a string. def message(self): """ Render the body of the message to a string. """ template_name = self.template_name() if \ callable(self.template_name) \ else self.template_name return loader.render_to_string( ...
Render the subject of the message to a string. def subject(self): """ Render the subject of the message to a string. """ template_name = self.subject_template_name() if \ callable(self.subject_template_name) \ else self.subject_template_name subject = lo...
Return the context used to render the templates for the email subject and body. By default, this context includes: * All of the validated values in the form, as variables of the same names as their fields. * The current ``Site`` object, as the variable ``site``. * A...
Generate the various parts of the message and return them in a dictionary, suitable for passing directly as keyword arguments to ``django.core.mail.send_mail()``. By default, the following values are returned: * ``from_email`` * ``message`` * ``recipient_list`` ...