sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def get_single_instance(sql, class_type, *args, **kwargs): """Returns an instance of class_type populated with attributes from the DB record; throws an error if no records are found @param sql: Sql statement to execute @param class_type: The type of class to instantiate and populate wit...
Returns an instance of class_type populated with attributes from the DB record; throws an error if no records are found @param sql: Sql statement to execute @param class_type: The type of class to instantiate and populate with DB record @return: Return an instance with attributes set to...
entailment
def get_all_instances(sql, class_type, *args, **kwargs): """Returns a list of instances of class_type populated with attributes from the DB record @param sql: Sql statement to execute @param class_type: The type of class to instantiate and populate with DB record @return: Return a list ...
Returns a list of instances of class_type populated with attributes from the DB record @param sql: Sql statement to execute @param class_type: The type of class to instantiate and populate with DB record @return: Return a list of instances with attributes set to values from DB
entailment
def escape_dictionary(dictionary, datetime_format='%Y-%m-%d %H:%M:%S'): """Escape dictionary values with keys as column names and values column values @type dictionary: dict @param dictionary: Key-values """ for k, v in dictionary.iteritems(): if isinstance(v, dateti...
Escape dictionary values with keys as column names and values column values @type dictionary: dict @param dictionary: Key-values
entailment
def get_insert_fields_and_values_from_dict(dictionary, datetime_format='%Y-%m-%d %H:%M:%S', db_escape=True): """Formats a dictionary to strings of fields and values for insert statements @param dictionary: The dictionary whose keys and values are to be inserted @param db_escape: If true, will d...
Formats a dictionary to strings of fields and values for insert statements @param dictionary: The dictionary whose keys and values are to be inserted @param db_escape: If true, will db escape values @return: Tuple of strings containing string fields and values, e.g. ('user_id, username', '5, "p...
entailment
def get_kwargs(**kwargs): """This method should be used in query functions where user can query on any number of fields >>> def get_instances(entity_id=NOTSET, my_field=NOTSET): >>> kwargs = CoyoteDb.get_kwargs(entity_id=entity_id, my_field=my_field) """ d = dict() ...
This method should be used in query functions where user can query on any number of fields >>> def get_instances(entity_id=NOTSET, my_field=NOTSET): >>> kwargs = CoyoteDb.get_kwargs(entity_id=entity_id, my_field=my_field)
entailment
def get_update_clause_from_dict(dictionary, datetime_format='%Y-%m-%d %H:%M:%S'): """Builds the update values clause of an update statement based on the dictionary representation of an instance""" items = [] CoyoteDb.escape_dictionary(dictionary, datetime_format=datetime_format) ...
Builds the update values clause of an update statement based on the dictionary representation of an instance
entailment
def get_where_clause_from_dict(dictionary, join_operator='AND'): """Builds a where clause from a dictionary """ CoyoteDb.escape_dictionary(dictionary) clause = join_operator.join( (' {k} is {v} ' if str(v).lower() == 'null' else ' {k} = {v} ').format(k=k, v=v) # IS should be...
Builds a where clause from a dictionary
entailment
def get_dictionary_representation_of_object_attributes(obj, omit_null_fields=False): """Returns a dictionary of object's attributes, ignoring methods @param obj: The object to represent as dict @param omit_null_fields: If true, will not include fields in the dictionary that are null @re...
Returns a dictionary of object's attributes, ignoring methods @param obj: The object to represent as dict @param omit_null_fields: If true, will not include fields in the dictionary that are null @return: Dictionary of the object's attributes
entailment
def get_object_from_dictionary_representation(dictionary, class_type): """Instantiates a new class (that takes no init params) and populates its attributes with a dictionary @type dictionary: dict @param dictionary: Dictionary representation of the object @param class_type: type ...
Instantiates a new class (that takes no init params) and populates its attributes with a dictionary @type dictionary: dict @param dictionary: Dictionary representation of the object @param class_type: type @return: None
entailment
def build_where_clause(mappings, operator='AND'): """Constructs the where clause based on a dictionary of values >>> build_where_clause({'id': 456, 'name': 'myrecord'}, operator='OR') >>> 'WHERE id = 456 OR name = "myrecord" ' """ where_clause_mappings = {} where_clause...
Constructs the where clause based on a dictionary of values >>> build_where_clause({'id': 456, 'name': 'myrecord'}, operator='OR') >>> 'WHERE id = 456 OR name = "myrecord" '
entailment
def execute(*args, **kwargs): """Executes the sql statement, but does not commit. Returns the cursor to commit @return: DB and cursor instance following sql execution """ # Inspect the call stack for the originating call args = CoyoteDb.__add_query_comment(args[0]) db =...
Executes the sql statement, but does not commit. Returns the cursor to commit @return: DB and cursor instance following sql execution
entailment
def execute_read_only(*args, **kwargs): # TODO: consolidate with execute """Executes the sql statement, but does not commit. Returns the cursor to commit @return: DB and cursor instance following sql execution """ # Inspect the call stack for the originating call args =...
Executes the sql statement, but does not commit. Returns the cursor to commit @return: DB and cursor instance following sql execution
entailment
def execute_and_commit(*args, **kwargs): """Executes and commits the sql statement @return: None """ db, cursor = CoyoteDb.execute(*args, **kwargs) db.commit() return cursor
Executes and commits the sql statement @return: None
entailment
def insert_instance(instance, table, **kwargs): """Inserts an object's values into a given table, will not populate Nonetype values @param instance: Instance of an object to insert @param table: Table in which to insert instance values @return: ID of the last inserted row """ ...
Inserts an object's values into a given table, will not populate Nonetype values @param instance: Instance of an object to insert @param table: Table in which to insert instance values @return: ID of the last inserted row
entailment
def update(sql, *args, **kwargs): """Updates and commits with an insert sql statement, returns the record, but with a small chance of a race condition @param sql: sql to execute @return: The last row inserted """ assert "update" in sql.lower(), 'This function requires an...
Updates and commits with an insert sql statement, returns the record, but with a small chance of a race condition @param sql: sql to execute @return: The last row inserted
entailment
def delete(sql, *args, **kwargs): """Deletes and commits with an insert sql statement""" assert "delete" in sql.lower(), 'This function requires a delete statement, provided: {}'.format(sql) CoyoteDb.execute_and_commit(sql, *args, **kwargs)
Deletes and commits with an insert sql statement
entailment
def update_object_from_dictionary_representation(dictionary, instance): """Given a dictionary and an object instance, will set all object attributes equal to the dictionary's keys and values. Assumes dictionary does not have any keys for which object does not have attributes @type dictionary: d...
Given a dictionary and an object instance, will set all object attributes equal to the dictionary's keys and values. Assumes dictionary does not have any keys for which object does not have attributes @type dictionary: dict @param dictionary: Dictionary representation of the object @par...
entailment
def format_time(time): """Formats a time to be Shapeways database-compatible @param time: Datetime or string object to format @rtype: str @return: Time formatted as a string """ # Handle time typing try: time = time.isoformat() except Attribut...
Formats a time to be Shapeways database-compatible @param time: Datetime or string object to format @rtype: str @return: Time formatted as a string
entailment
def format_date(date): """Formats a date to be Shapeways database-compatible @param date: Datetime or string object to format @rtype: str @return: Date formatted as a string """ # Handle time typing try: date = date.isoformat() except Attribut...
Formats a date to be Shapeways database-compatible @param date: Datetime or string object to format @rtype: str @return: Date formatted as a string
entailment
def visit(self, url=''): """ Driver gets the provided url in the browser, returns True if successful url -- An absolute or relative url stored as a string """ def _visit(url): if len(url) > 0 and url[0] == '/': # url's first character is a forward sla...
Driver gets the provided url in the browser, returns True if successful url -- An absolute or relative url stored as a string
entailment
def is_alert_present(self): """Tests if an alert is present @return: True if alert is present, False otherwise """ current_frame = None try: current_frame = self.driver.current_window_handle a = self.driver.switch_to_alert() a.text exc...
Tests if an alert is present @return: True if alert is present, False otherwise
entailment
def find(self, locator, find_all=False, search_object=None, force_find=False, exclude_invisible=False): """ Attempts to locate an element, trying the number of times specified by the driver wrapper; Will throw a WebDriverWrapperException if no element is found @type locator: we...
Attempts to locate an element, trying the number of times specified by the driver wrapper; Will throw a WebDriverWrapperException if no element is found @type locator: webdriverwrapper.support.locator.Locator @param locator: the locator or css string used to query the element ...
entailment
def _find_immediately(self, locator, search_object=None): ''' Attempts to immediately find elements on the page without waiting @type locator: webdriverwrapper.support.locator.Locator @param locator: Locator object describing @type search_object: webdriverwra...
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 ...
entailment
def find_all(self, locator, search_object=None, force_find=False): ''' Find all elements matching locator @type locator: webdriverwrapper.support.locator.Locator @param locator: Locator object describing @rtype: list[WebElementWrapper] @...
Find all elements matching locator @type locator: webdriverwrapper.support.locator.Locator @param locator: Locator object describing @rtype: list[WebElementWrapper] @return: list of WebElementWrappers
entailment
def find_by_dynamic_locator(self, template_locator, variables, find_all=False, search_object=None): ''' Find with dynamic locator @type template_locator: webdriverwrapper.support.locator.Locator @param template_locator: Template locator w/ formatting bits to insert ...
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 ...
entailment
def is_present(self, locator, search_object=None): """ 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...
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...
entailment
def is_present_no_wait(self, locator): """ 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 """ # first attempt to locate the el...
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
entailment
def wait_until(self, wait_function, failure_message=None, timeout=None): """ 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 @p...
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: ...
entailment
def wait_until_present(self, locator, timeout=None, failure_message='Timeout waiting for element to be present'): """ 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 @...
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: ...
entailment
def wait_until_not_present(self, locator, timeout=None): """ 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...
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...
entailment
def wait_until_invisibility_of(self, locator, timeout=None): """ 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 max...
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: ...
entailment
def wait_until_clickable(self, locator, timeout=None): """ 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 n...
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: ...
entailment
def wait_until_stale(self, locator, timeout=None): """ 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 maximu...
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...
entailment
def wait_until_title_contains(self, partial_title, timeout=None): """ 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 seco...
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...
entailment
def wait_until_title_is(self, title, timeout=None): """ 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 befo...
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...
entailment
def wait_until_alert_is_present(self, timeout=None): """ 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 ...
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
entailment
def wait_until_text_contains(self, locator, text, timeout=None): """ 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 tex...
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...
entailment
def wait_until_text_is_not_empty(self, locator, timeout=None): """ 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...
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 ...
entailment
def wait_until_page_source_contains(self, text, timeout=None): """ 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...
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...
entailment
def wait_until_jquery_requests_are_closed(self, timeout=None): """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 """ timeout = timeout if timeout is not Non...
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
entailment
def execute_and_handle_webdriver_exceptions(self, function_to_execute, timeout=None, locator=None, failure_message=None): """ Executor for wait functions @type function_to_execute: types.FunctionType @param function_to_execute: wait function specifying the type of wait @type ti...
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...
entailment
def pause_and_wait_for_user(self, timeout=None, prompt_text='Click to resume (WebDriver is paused)'): """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 """ timeout = timeout i...
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
entailment
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') self.browser_logs += logs if levels is not None: logs = [entry for entry in log...
Gets the console log of the browser @type levels: @return: List of browser log entries
entailment
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, signal.SIGKILL) raise f...
Close driver and kill all associated displays
entailment
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) source = self.page_source() return result
Visit the url, checking for rr errors in the response @param url: URL @return: Visit result
entailment
def load_config_vars(target_config, source_config): """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 @retur...
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
entailment
def _readall(self): """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 locate...
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` ...
entailment
def run_parallel(*functions): """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 pro...
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...
entailment
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
Returns an updated copy of the dictionary without modifying the original
entailment
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') return directory
Retrieves the full path of the static directory @return: Full path of the static directory
entailment
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}'.format(filename=filename))) as f: contents = f.read() return contents
Reads the contents of an html file in the css directory @return: Contents of the specified file
entailment
def parse_locator(locator): """ 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 """ # handle backwards compatibility to support new Locator class if i...
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
entailment
def find_by_locator(webdriver_or_element, locator, find_all_elements=False): """ 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.loc...
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...
entailment
def spin_assert(self, assertion, failure_message='Failed Assertion', timeout=None): """ Asserts that assertion function passed to it will return True, trying every 'step' seconds until 'timeout' seconds have passed. """ timeout = self.timeout if timeout is None else timeout ...
Asserts that assertion function passed to it will return True, trying every 'step' seconds until 'timeout' seconds have passed.
entailment
def webdriver_assert(self, assertion, failure_message='Failed Assertion'): """ Assert the assertion, but throw a WebDriverAssertionException if assertion fails """ try: assert assertion() is True except AssertionError: raise WebDriverAssertionException.Web...
Assert the assertion, but throw a WebDriverAssertionException if assertion fails
entailment
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 """ assertion = lambda: bool(value) self.webdriver_assert(assertion, unicode(failure_m...
Asserts that a value is true @type value: bool @param value: value to test for True
entailment
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 using the expected and provided values with the '==' operator """ assertion = lambda: expected_val == act...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the '==' operator
entailment
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 within an allowed delta of each other """ assertion...
Asserts that two numbers are within an allowed delta of each other
entailment
def assert_not_equal(self, actual_val, unexpected_val, failure_message='Expected values to differ: "{}" and "{}"'): """ Calls smart_assert, but creates its own assertion closure using the expected and provided values with the '!=' operator """ assertion = lambda: unexpected_val !...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the '!=' operator
entailment
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 the expected and provided values with the 'is' operator """ assertion = lambda: expected_type is actual_...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'is' operator
entailment
def assert_is_not(self, actual_val, unexpected_type, failure_message='Expected type not to be "{1}," but was "{0}"'): """ Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'is not' operator """ assertio...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'is not' operator
entailment
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 closure using the expected and provided values with the 'in' operator """ assertion = lambda: expected_value in...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'in' operator
entailment
def assert_not_in(self, actual_collection_or_string, unexpected_value, failure_message='Expected "{1}" not to be in "{0}"'): """ Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'not in' operator """ a...
Calls smart_assert, but creates its own assertion closure using the expected and provided values with the 'not in' operator
entailment
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: expected_value in self.driver_wrapper.page_source() self.webdriver...
Asserts that the page source contains the string passed in expected_value
entailment
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 (collections share at least one member) """ assertion = lambda: len(collection1 or ...
Asserts that the union of two sets has at least one member (collections share at least one member)
entailment
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) """ assertion = lambda: len(set(collection1).intersection(set(co...
Asserts that the union of two sets is empty (collections are unique)
entailment
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)) failure_message = unicode(failure_message).format...
Asserts that a superset contains all elements of a subset
entailment
def clear(self): """ Clears the field represented by this element @rtype: WebElementWrapper @return: Returns itself """ def clear_element(): """ Wrapper to clear element """ return self.element.clear() self.e...
Clears the field represented by this element @rtype: WebElementWrapper @return: Returns itself
entailment
def delete_content(self, max_chars=100): """ Deletes content in the input field by repeatedly typing HOME, then DELETE @rtype: WebElementWrapper @return: Returns itself """ def delete_content_element(): chars_deleted = 0 while len(self.get_...
Deletes content in the input field by repeatedly typing HOME, then DELETE @rtype: WebElementWrapper @return: Returns itself
entailment
def click(self, force_click=False): """ 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 """ js_exec...
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
entailment
def get_value(self): """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_element_value(): if self.tag_name() ==...
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
entailment
def get_attribute(self, name): """ Retrieves specified attribute from WebElement @type name: str @param name: Attribute to retrieve @rtype: str @return: String representation of the attribute """ def get_attribute_element(): ...
Retrieves specified attribute from WebElement @type name: str @param name: Attribute to retrieve @rtype: str @return: String representation of the attribute
entailment
def is_on_screen(self): """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 """ width = self.get_width() height = self.get_height() loc = self.location() el_x_lef...
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
entailment
def send_special_keys(self, value): """ Send special keys such as <enter> or <delete> @rtype: WebElementWrapper @return: Self """ def send_keys_element(): """ Wrapper to send keys """ return self.element.send_keys(va...
Send special keys such as <enter> or <delete> @rtype: WebElementWrapper @return: Self
entailment
def set(self, val, force_set=False): """ 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 se...
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...
entailment
def submit(self): """ Submit a webe element @rtype: WebElementWrapper @return: Self """ def submit_element(): """ Wrapper to submit element """ return self.element.submit() self.execute_and_handle_webelement_...
Submit a webe element @rtype: WebElementWrapper @return: Self
entailment
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_property_element(): """ Wrapper to get css property """ return...
Get value of CSS property for element @rtype: str @return: value of CSS property
entailment
def has_class(self, classname): """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 element_has_class(): ...
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
entailment
def parent(self): """ Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked """ def parent_element(): """ Wrapper to retrieve parent element """ return...
Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked
entailment
def parent_element(self): """ Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked """ def parent_element(): """ Wrapper to get parent element """ par...
Get the parent of the element @rtype: WebElementWrapper @return: Parent of webelementwrapper on which this was invoked
entailment
def text(self, force_get=False): """ Get the text of the element @rtype: str @return: Text of the element """ def text_element(): """ Wrapper to get text of element """ return self.element.text def force_tex...
Get the text of the element @rtype: str @return: Text of the element
entailment
def highlight(self): """ Draws a dotted red box around the wrapped element using javascript @rtype: WebElementWrapper @return: Self """ js_executor = self.driver_wrapper.js_executor def highlight_element(): """ Wrapper to highlight ...
Draws a dotted red box around the wrapped element using javascript @rtype: WebElementWrapper @return: Self
entailment
def set_attribute(self, name, value): """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 """ js_executor = self.driver_wrapper.js_e...
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
entailment
def select_option(self, value=None, text=None, index=None): """ 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...
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 ...
entailment
def deselect_option(self, value=None, text=None, index=None): """ 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 ...
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 ...
entailment
def set_select(self, select_or_deselect = 'select', value=None, text=None, index=None): """ 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 val...
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: ...
entailment
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 check a checkbox
entailment
def checkbox_uncheck(self, force_check=False): """ Wrapper to uncheck a checkbox """ if self.get_attribute('checked'): self.click(force_click=force_check)
Wrapper to uncheck a checkbox
entailment
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_exceptions(do_hover, 'hover...
Hovers the element
entailment
def find(self, locator, find_all=False, search_object=None, exclude_invisible=None, *args, **kwargs): """ Find wrapper, invokes webDriverWrapper find with the current element as the search object @type locator: webdriverwrapper.support.locator.Locator @param locator: lo...
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...
entailment
def find_once(self, locator): """ 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 on...
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...
entailment
def find_all(self, locator): """ Find wrapper, finds all elements @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: list @return: A list of WebElementWrappers ""...
Find wrapper, finds all elements @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: list @return: A list of WebElementWrappers
entailment
def is_present(self, locator): """ 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 pr...
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
entailment
def wait_until_stale(self, timeout=None): """ Waits for the element to go stale in the DOM @type timeout: int @param timeout: override for default timeout @rtype: WebElementWrapper @return: Self """ timeout...
Waits for the element to go stale in the DOM @type timeout: int @param timeout: override for default timeout @rtype: WebElementWrapper @return: Self
entailment
def execute_and_handle_webelement_exceptions(self, function_to_execute, name_of_action): """ 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_execut...
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 ...
entailment
def request(self, uri, method=GET, headers=None, cookies=None, params=None, data=None, post_files=None,**kwargs): """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 @...
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...
entailment
def save_last_response_to_file(self, filename): """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 """ response = self.get_last_response() return self.save_response_to_f...
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
entailment
def save_response_to_file(self, response, filename): """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 """ try: last_response = self.get_last_response() ...
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
entailment
def validate_url(url, allowed_response_codes=None): """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 """ allowed_response_codes...
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
entailment
def validate_urls(urls, allowed_response_codes=None): """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 """ for url in urls: valid...
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
entailment