def _check_index(index): try: if int(index) - 1 < len(ACTIVE_LIST.web_list): return int(index) - 1 raise QWebValueError('Index can\'t be bigger than length of the list') except TypeError: raise QWebValueError('Index has to be number')
def get_unique_text_element(text, **kwargs): """Get element with text that is unique. First tries to find exact match and if not found then search as a substring. Parameters ---------- text : str Text to be searched. Returns ------- WebElement Webelement that has the text. Raises ------ NoSuchElementException There are not elements with the given text. ValueError Found many elements with the given text. """ web_elements = get_text_elements(text, **kwargs) if not web_elements: raise QWebValueError( 'Text "{}" did not match any elements'.format(text)) if len(web_elements) == 1: return web_elements[0] # pylint: disable=unsubscriptable-object raise QWebValueError( 'Text "{}" matched {} elements. Needs to be unique'.format( text, len(web_elements)))
def get_clickable_cell(self, coordinates, anchor, index=1, **kwargs): if int(index) < 1: raise QWebValueError('Index should be greater than 0.') table_cell = self.get_table_cell(coordinates, anchor) if 'tag' in kwargs: clickable_child = element.get_element_from_childnodes( table_cell, kwargs.get('tag'), dom_traversing=False) if int(index) > len(clickable_child): raise QWebValueError( 'Index exceeds the number of clickable elements in cell.') return clickable_child[int(index) - 1] return table_cell
def switch_window(index, timeout=0): # pylint: disable=unused-argument r"""Switch to another tab. Examples -------- .. code-block:: robotframework SwitchWindow 1 SwitchWindow NEW # Switches to latest opened tab Parameters ---------- index : str Index of the tab starting from one and counting from left to right. OR Special keyword "NEW" which can be used to move to the latest opened tab. timeout : str | int How long we search before failing. Raises ------ ValueError If the window index is out of reach Related keywords ---------------- \`CloseBrowser\`, \`CloseWindow\`, \`CloseOthers\`, \`GoTo\`, \`OpenWindow\` """ window_handles = window.get_window_handles() logger.info("Current browser contains {} tabs".format(len(window_handles))) if index.isdigit(): if int(index) == 0: raise QWebValueError('SwitchWindow index starts at 1.') i = int(index) - 1 if i < len(window_handles): correct_window_handle = window_handles[i] window.switch_to_window(correct_window_handle) return logger.debug('Tried to select tab with index {} but there' ' are only {} tabs open'.format(index, len(window_handles))) elif index == "NEW": window.switch_to_window(window_handles[-1]) return else: raise QWebValueError( 'Given argument "{}" is not a digit or NEW'.format(index)) raise QWebDriverError( 'Tried to select tab with index {} but there are only {} tabs open' .format(index, len(window_handles)))
def execute_javascript(script, variable_name=None): """Execute javascript and save the result to suite variable. Examples -------- .. code-block:: robotframework ExecuteJavascript document.getElementsByTagName("p")[0].innerText="Write text"; ExecuteJavascript return document.title; $TITLE Parameters ---------- script : str Javascript code. variable_name : str Robot framework variable name without {}. (Default None) """ output = javascript.execute_javascript(script) logger.info('Output of execution:\n{}'.format(output)) if variable_name: try: BuiltIn().set_suite_variable(variable_name, output) except Exception as e: logger.warn(e.__str__()) raise QWebValueError("Invalid variable syntax '{}'.".format(variable_name))
def move_files(files_to_move, destination_folder): r"""Move files. Examples -------- .. code-block:: robotframework MoveFiles cat1.jpg C:/secret_cat_pictures MoveFiles cat1.jpg, cat666.jpg, cat4.jpg C:/secret_cat_pictures Parameters ---------- files_to_move : str Files to move, separated by "," in case of multiple files. destination_folder : str Destination folder of the moved files. Related keywords ---------------- \`RemoveFile\`, \`SaveFile\`, \`UploadFile\`, \`VerifyFile\` """ if not os.path.isdir(destination_folder): raise QWebValueError('Destination folder does not exist.') files = files_to_move.split(',') for file in files: file = str(download.get_path(file.strip())) shutil.move(file, destination_folder)
def is_not_in_dropdown(select, option, **kwargs): """"Verifies that the selected option is not in the dropdown list""" option_list = get_select_options(select, **kwargs) if option in option_list: raise QWebValueError("Found the value {} from the dropdown menu: {}." .format(option, option_list)) return True
def input_method(self, input_method): required = ["selenium", "raw"] if input_method not in required: raise QWebValueError( 'Unknown input_method: {}, required: {}'.format( input_method, required)) self._input_method = input_method
def get_unique_element_by_xpath(xpath, **kwargs): """Get element if it is needed to be unique. One use case is that when xpath is written in the test script with the prefix xpath=. Parameters ---------- xpath : str XPath string. If 'xpath=' -prefix is used, it will be omitted. """ if xpath.startswith("xpath="): xpath = xpath.split("=", 1)[1] elements = get_webelements_in_active_area(xpath, **kwargs) # pylint: disable=no-else-return if elements and len(elements) == 1: if CONFIG['SearchMode']: draw_borders(elements[0]) return elements[0] elif not elements: raise QWebElementNotFoundError( 'XPath {} did not find any elements'.format(xpath)) raise QWebValueError( 'XPath {} matched {} elements. Needs to be unique'.format( xpath, len(elements)))
def press_key(locator, key, anchor="1", timeout='0', **kwargs): r"""Simulate user pressing keyboard key on element identified by "locator". The parameter "key" is either a single character or a keyboard key surrounded by '{ }'. Examples -------- .. code-block:: robotframework PressKey text_field q PressKey text_field {ENTER} PressKey text_field {CONTROL + A} # Select all PressKey text_field {CONTROL + C} # Copy selected text PressKey other_field {CONTROL + V} # Paste copied text PressKey text_field {PASTE} # Paste copied text Related keywords ---------------- \`TypeSecret\`, \`TypeText\`, \`WriteText\` """ try: input_element = input_.get_input_elements_from_all_documents( locator, anchor, timeout=timeout, index=1, **kwargs) key = input_handler.check_key(key) input_element.send_keys(key) except AttributeError as e: raise QWebValueError('Could not find key "{}"'.format(key)) from e
def type_texts(input_texts, timeout='0'): """Type text to multiple fields. Accepts a .txt file or Robot FW dictionary as a parameter. If using a text file, the locator and the text should be separated with a comma on each row. Examples -------- .. code-block:: robotframework TypeTexts list_of_locators_and_texts.txt TypeTexts C:/Users/pace/Desktop/textfile.txt ${cool_dict}= Create Dictionary Name=Jane [email protected] ... Phone=04049292243923 Address=Yellow street 33 C 44 TypeTexts ${cool_dict} """ if isinstance(input_texts, dict): for locator in input_texts: logger.info('Typing "{}", locator "{}"'.format(locator, input_texts[locator])) type_text(locator, input_texts[locator]) elif input_texts.endswith('.txt') or input_texts.endswith('.csv'): file = download.get_path(input_texts) with open(file, 'rb') as txt_file: params = [line.rstrip() for line in txt_file] for x in params: x = x.decode('utf-8').split(',') locator, text = x[0].strip(), x[1].strip() logger.info('Typing "{}", locator "{}"'.format(text, locator)) type_text(locator, text, timeout=timeout) else: raise QWebValueError('Unknown input value. Text file or dictionary required.')
def verify_input_values(input_values, timeout='0'): """Verify input fields have given values. Accepts a .txt file or Robot FW dictionary as a parameter. If using a text file, the locator and the expected value should be separated with a comma on each row. Examples -------- .. code-block:: robotframework VerifyInputValues list_of_locators_and_values.txt VerifyInputValues C:/Users/pace/Desktop/textfile.txt ${cool_dict}= Create Dictionary Name=Jane [email protected] ... Phone=04049292243923 Address=Yellow street 33 C 44 VerifyInputValues ${cool_dict} """ if isinstance(input_values, dict): for locator in input_values: logger.info('Locator: {}, Expected value: {}'.format(locator, input_values[locator]), also_console=True) verify_input_value(locator, input_values[locator]) elif input_values.endswith('.txt') or input_values.endswith('.csv'): file = download.get_path(input_values) with open(file, 'rb') as txt_file: params = [line.rstrip() for line in txt_file] for x in params: x = x.decode('utf-8').split(',') locator, value = x[0].strip(), x[1].strip() logger.info('Locator: {}, Expected value: {}'.format(locator, value), also_console=True) verify_input_value(locator, value, timeout=timeout) else: raise QWebValueError('Unknown input value. Text file or dictionary required.')
def _get_profile_dir(option_str): try: profile = option_str.split()[1] if not os.path.isdir(profile): raise QWebValueError("Profile path is not a valid path!!") except IndexError: profile = None return profile
def get_element_text(web_element, expected=None, timeout=0): # pylint: disable=unused-argument real_text = web_element.text.strip() if expected is not None: try: return _compare_texts(real_text, expected.strip(), timeout) except QWebValueMismatchError as e: raise QWebValueError('Expected {}, found {}'.format(expected, real_text)) from e if real_text is not None: return real_text raise QWebValueMismatchError('Text not found')
def input_value(input_element, timeout, **kwargs): blind = util.par2bool(kwargs.get('blind', CONFIG['BlindReturn'])) if input_handler.is_editable_text_element(input_element): value = input_element.get_attribute('innerText') else: value = input_element.get_attribute('value') if value: return value.strip() if blind: return '' raise QWebValueError('No Value found after {} sec'.format(timeout))
def verify_no_element(xpath, timeout=0, **kwargs): # pylint: disable=unused-argument r"""Wait element can not be found on the page. Examples -------- .. code-block:: robotframework VerifyNoElement //*[@id\="do_not_wait_me"] This keyword has timeout functionality. If the element is still visible after given timeout, error is raised. For example. .. code-block:: robotframework VerifyNoElement //*[@id\="wait_me"] 20 #waits 20 seconds Parameters ---------- xpath : str Xpath expression without xpath= prefix. The equal sign "=" must be escaped with a "\\". timeout : str | int Timeout for the element to disappear. If the element is visible after given timeout, error is raised. The str is converted to integer using robot.utils.timestr_to_secs. (default 10 seconds) kwargs : | Accepted kwargs: | tag : html tag of preferred elemenr - | If tag is used then element is found | by some of it's attribute (xpath is not needed) | partial_match: True. If element is found by it's attribute set partial_match | to True to allow partial match Raises ------ NoSuchElementException Page did contain the element Related keywords ---------------- \`VerifyElement\` """ kwargs['element_kw'] = True if 'tag' in kwargs: web_elements = element.get_visible_elements_from_elements( element.get_elements_by_attributes(kwargs.get('tag'), xpath, **kwargs)) else: web_elements = element.get_webelements(xpath) if not web_elements: return raise QWebValueError( 'Page contained element with XPath "{}" after timeout'.format(xpath))
def set_current_browser(index): # pylint: disable=global-statement global _current_browser if index.isdigit(): if int(index) == 0: raise QWebValueError('SwitchBrowser index starts at 1.') i = int(index) - 1 if i < len(_open_browsers): _current_browser = _open_browsers[i] else: raise QWebDriverError( f'Tried to select browser with index {index} but there are \ {len(_open_browsers)} browsers open') elif index == "NEW": _current_browser = _open_browsers[-1] else: raise QWebValueError( 'Given argument "{}" is not a digit or NEW'.format(index))
def _raw_writer(input_element, input_text): """ Control keyboard and text input with pyautogui. This doesn't do any checks for the element state. """ # Sanity check even if the input_element is not required for the input if not input_element: raise QWebValueError('Input element is not available.') if os.getenv('QWEB_HEADLESS', None): raise QWebEnvironmentError( 'Running in headless environment. Pynput is unavailable.') keyboard = Controller() keyboard.type(input_text)
def get_element_using_anchor(elements, anchor, **kwargs): """Determine correct element from list of elements using anchor. Parameters ---------- elements : :obj:`list` of :obj:`WebElement` anchor Returns ------- WebElement """ if anchor is None: # Element was not unique and anchor was not used. raise QWebValueError( 'Found {} elements. Use anchor to determine which is wanted'. format(len(elements))) # Select by index unless anchor type is text if anchor.isdigit() and kwargs.get("anchor_type", "auto").lower() != "text": anchor = int(anchor) - 1 if anchor < len(elements): return elements[anchor] raise QWebInstanceDoesNotExistError( 'Found {} elements. Given anchor was {}'.format( len(elements), anchor + 1)) if isinstance(anchor, str): # Get closest element to anchor kwargs['stay_in_current_frame'] = True anchor_element = None if CONFIG['MultipleAnchors']: anchor_elements = [] logger.debug( 'Multiple anchors enabled, trying to find first exact match') try: anchor_elements = _get_exact_text_element(anchor, **kwargs) except NoSuchFrameException: logger.debug('Got no such frame from get exact text') if len(anchor_elements) > 0: # Using first exact match as anchor anchor_element = anchor_elements[0] else: # No exact matches found, trying to find partial anchor_elements = get_text_elements(anchor, **kwargs) if len(anchor_elements) > 0: logger.debug( 'No exact match found, using first partial match') anchor_element = anchor_elements[0] else: anchor_element = get_unique_text_element(anchor, **kwargs) return element.get_closest_element(anchor_element, elements) raise TypeError("Unknown argument type {}".format(type(anchor)))
def get_row(self, locator, anchor, row_index=False, **kwargs): skip_header = util.par2bool(kwargs.get('skip_header', False)) rows = self.get_all_rows() if locator.startswith('//last'): if skip_header: return len(rows) - 1 return len(rows) matches, index = self._get_row_by_locator_text(rows, locator, anchor) if row_index: if skip_header: return index return index + 1 if matches: return matches raise QWebValueError( 'Matching table row not found for locator {}.'.format(locator))
def verify_list(text, index=None, timeout=0): # pylint: disable=unused-argument """Verify list contains given text. Examples -------- .. code-block:: robotframework UseList Qentinel VerifyList Pace Robot #list contains given text (text can be anywhere) VerifyList Test Automation 2 #List index 2 contains given text """ if _list_exists(): active = ACTIVE_LIST.update_list() if index: index = _check_index(index) if active.contains(text, index): return raise QWebValueError('List didn\'t contain text "{}"'.format(text))
def get_cell_by_locator(self, locator): rows = self.get_all_rows() for i, r in enumerate(rows): # pylint: disable=unused-variable cells = self.get_cells_from_row(r) for index, c in enumerate(cells): cell_text = "" if c.text: cell_text += c.text elif javascript.execute_javascript( 'return arguments[0].querySelector("input, textarea")', c): value = javascript.execute_javascript( 'return arguments[0].value', c) if value: cell_text += str(value) if locator in cell_text: return index + 1 raise QWebValueError( 'Matching table cell not found for locator {}.'.format(locator))
def verify_alert_text(text, timeout=0): """Verify alert text. Examples -------- .. code-block:: robotframework VerifyAlertText Qentinel Parameters ---------- text : str | int Text to Verify timeout : str | int How long we wait for text to disappear before failing. Default 10 (seconds) """ alert_ = alert.wait_alert(timeout=timeout) if text in alert_.text: return raise QWebValueError('Text {} is not presented in Alert'.format(text))
def zip_files(name_of_zip, files_to_zip): """Zip files. Examples -------- .. code-block:: robotframework ZipFiles my_zip_file rabbit.txt ZipFiles my_zip_file_2 dog.txt ZipFiles my_zip_file_3 rabbit.txt, dog.txt ZipFiles my_zip_file_4 C:/Users/pace/secrets/cat.txt ZipFiles my_zip_file_5 C:/Users/pace/secrets/cat.txt, C:/automation/kangaroo.txt Parameters ---------- name_of_zip : str Name of the zip file created. files_to_zip : str Files to be zipped, separated by "," in case of multiple files. """ if not name_of_zip.endswith('.zip'): name_of_zip += '.zip' files = files_to_zip.split(',') try: with ZipFile(name_of_zip, 'w') as zipped: for file in files: file = download.get_path(file.strip()) if os.path.isdir(file): for root, _, files2 in os.walk(file): for file2 in files2: zipped.write(os.path.join(root, file2)) else: zipped.write(file, basename(file)) except OSError as e: raise QWebValueError('\nFile name "{}" contained illegal characters.' '\nError message: {}'.format(name_of_zip, str(e))) logger.info('Zipped files {} into the file {}'.format( str(files), name_of_zip), also_console=True)
def get_draggable_element(text, index, anchor): attribute_match = '[title^="{0}"][draggable="true"],[alt^="{0}"][draggable="true"],' \ '[tooltip^="{0}"][draggable="true"],' \ '[data-tooltip^="{0}"][draggable="true"],' \ '[data-icon^="{0}"][draggable="true"],' \ '[aria-label^="{0}"][draggable="true"],' \ '[title^="{0}"][class*="draggableCell"]'.format(text) web_elements = [] matches = [] if text.startswith('xpath=') or text.startswith('//'): web_element = element.get_unique_element_by_xpath(text) if web_element: return web_element raise QWebElementNotFoundError('Draggable element not found by locator {}'.format(text)) try: index = int(index) - 1 except ValueError as e: raise QWebValueError('Index needs to be number') from e web_elements = javascript.execute_javascript( 'return document.querySelectorAll(\'{}\')'.format(attribute_match)) if web_elements: return web_elements[index] web_elements = javascript.execute_javascript( 'return document.querySelectorAll(\'[draggable="true"]\')') if web_elements: matches = _find_matches(web_elements, text) if matches: return matches[index] if text == 'index': logger.warn('Text is not matching to any draggable element. Found {} ' 'draggable elements. Using index..'.format(len(web_elements))) return web_elements[index] web_elements = get_text_using_anchor(text, anchor) if web_elements: return web_elements raise QWebElementNotFoundError('Draggable element not found by locator {}'.format(text))
def verify_title(title, timeout=0): # pylint: disable=unused-argument r"""Verifies that current page's title matches expected title. Examples -------- .. code-block:: robotframework VerifyTitle Google VerifyTitle Google timeout=3 Parameters ---------- title : str The expected title timeout : str | int How long we wait for title to change before failing. Raises ------ QWebValueError If the expected title differs from actual page title Related keywords ---------------- \`GetTitle\`, \`GetUrl\`, \`VerifyUrl\` """ driver = browser.get_current_browser() if driver is None: raise QWebDriverError("No browser open. Use OpenBrowser keyword" " to open browser first") actual = driver.title if actual != title: raise QWebValueError(f"Page title '{actual}'' does not match expected '{title}'")
def verify_url(url, timeout=0): # pylint: disable=unused-argument r"""Verifies that current page url/location matches expected url. Examples -------- .. code-block:: robotframework VerifyUrl https://www.google.com VerifyUrl https://www.google.com timeout=5 Parameters ---------- url : str The expected url timeout : str | int How long we wait for url to change before failing. Raises ------ QWebValueError If the expected url differs from current url Related keywords ---------------- \`GetTitle\`, \`GetUrl\`, \`VerifyTitle\` """ driver = browser.get_current_browser() if driver is None: raise QWebDriverError("No browser open. Use OpenBrowser keyword" " to open browser first") current = driver.current_url if current.lower() != url.lower(): raise QWebValueError(f"Current url '{current}'' does not match expected url '{url}'")
def verify_input_status(locator, status, anchor="1", timeout=0, index=1, **kwargs): r"""Verify input field is enabled or disabled. In other words verify can user interact with an input field or not. Element is considered to be disabled if disabled or readonly attribute exists Examples -------- .. code-block:: robotframework VerifyInputStatus Password Enabled VerifyInputStatus SSN Disabled VerifyInputStatus SSN ReadOnly With table(Pick table with use table keyword first): .. code-block:: robotframework VerifyInputStatus r1c1 Enabled VerifyInputStatus r-1c-1 Disabled #last row, last cell Parameters ---------- locator : str Text that locates the input field. The input field that is closest to the text is selected. Also one can use xpath by adding xpath= prefix and then the xpath. Error is raised if the xpath matches to multiple elements. When using XPaths, the equal sign "=" must be escaped with a "\\". status : str Status for the input field. Either enabled, readonly or disabled. anchor : str Index number or text near the input field's locator element. If the page contains many places where the locator is then anchor is used to select the wanted item. Index number selects the item from the list of matching entries starting with 1. Text selects the entry with the closest distance. timeout : str | int How long we find element before failing. Default 10 (seconds) index : int If table cell contains more than one input elements or if there is some kind of nested structure inside of given input index may needed. Default = 1 (first) kwargs : | Accepted kwargs: | limit_traverse : False. If limit traverse is set to false we are heading up to | fifth parent element if needed when finding relative input element for some label. | partial_match: True. If element is found by it's attribute set partial_match | to True to allow partial match Raises ------ QWebValueError If the field interaction is not the same Related keywords ---------------- \`GetInputValue\`, \`VerifyInputElement\`, \`VerifyInputValue\`, \`VerifyInputValues\` """ input_element = input_.get_input_elements_from_all_documents( locator, anchor, timeout=timeout, index=index, enable_check=True, **kwargs) if status.lower() == "enabled": if not element.is_enabled(input_element) or element.is_readonly( input_element): raise QWebValueError('The input field was disabled') elif status.lower() == "disabled": if element.is_enabled(input_element): raise QWebValueError('The input field was enabled') elif status.lower() == "readonly": if not element.is_readonly(input_element): raise QWebValueError('readonly attr not found') else: raise QWebValueError('Unkown status: "{}"'.format(status))
def get_attribute(locator, attribute, anchor='1', element_type=None, timeout=0, **kwargs): r"""Get attribute value of an element. Examples -------- Using attributes or xpaths like with ClickElement etc. kw:s without specified element_type. If element_type is not specified end result is a type of list: .. code-block:: robotframework ${attribute_value} GetAttribute click_me id tag=button ${attribute_value} GetAttribute //*[@id\="click_me"] id ${attribute_value} GetAttribute xpath\=//*[@id\="click_me"] name GetAttribute using element_type attribute to locate element. Text elements works as ClickText, VerifyText, GetText etc.: .. code-block:: robotframework ${attribute_value} GetAttribute Log In type element_type=text ${attribute_value} GetAttribute Contact id element_type=text anchor=Qentinel ${attribute_value} GetAttribute Contact class parent=div Item, Input, Dropdown, Checkbox elements: .. code-block:: robotframework ${attribute_value} GetAttribute Log In id element_type=item ${attribute_value} GetAttribute Username placeholder element_type=input ${attribute_value} GetAttribute Country value element_type=dropdown ${attribute_value} GetAttribute Gender checked element_type=checkbox All flags are available for using (timeout, anchor, index, visibility, parent, child etc.). in same way as you are using those with Pacewords like ClickText/Item, TypeText, Dropdown etc. Parameters ---------- locator : str Visible text, attribute value or Xpath expression with or without xpath= prefix. The equal sign "=" must be escaped with a "\\". attribute: str Attribute which value we want to get. anchor : int Used when element_type is defined. Default=1 (first match) element_type : string Define element type/preferred searching method (available types: text, input, checkbox, item, dropdown). timeout : int How long we wait element to appear. Default=10 sec kwargs : | Accepted kwargs: | Any available for picked searching method. | See interacting with text, item, input etc. elements from | documentation Returns ------- value : Value of attribute (true if attribute exist but does not have value) Related keywords ---------------- \`VerifyAttribute\`, \`VerifyElement\` """ webelement = get_webelement(locator, anchor, element_type, timeout, **kwargs) if not webelement: raise QWebElementNotFoundError( 'Could not find element {} with attribute {}'.format( locator, attribute)) if not isinstance(webelement, list): return webelement.get_attribute(attribute) if len(webelement) == 1: return webelement[0].get_attribute(attribute) raise QWebValueError( 'Found {} occurences of locator {}. ' 'Use index etc. to uniquely identify the element'.format( len(webelement), locator))
def verify_attribute(locator, attribute, value, anchor='1', element_type=None, timeout=0, **kwargs): r"""Verify attribute value of an element. Examples -------- Using attributes or xpaths like with ClickElement etc. kw:s without specified element_type. If element_type is not specified end result is a type of list: .. code-block:: robotframework VerifyAttribute click_me id my_button tag=button VerifyAttribute //*[@id\="click_me"] name click_here VerifyAttribute xpath\=//*[@id\="click_me"] name click_here GetAttribute using element_type attribute to locate element. Text elements works as ClickText, VerifyText, GetText etc.: .. code-block:: robotframework VerifyAttribute Log In id login element_type=text VerifyAttribute Contact value abc element_type=text anchor=Qentinel VerifyAttribute Contact name contact1 parent=div Item, Input, Dropdown, Checkbox elements: .. code-block:: robotframework VerifyAttribute Log In id login element_type=item VerifyAttribute Username placeholder username element_type=input VerifyAttribute Country value Finland element_type=dropdown VerifyAttribute Gender checked checked element_type=checkbox All flags are available for using (timeout, anchor, index, visibility, parent, child etc.). in same way as you are using those with Pacewords like ClickText/Item, TypeText, Dropdown etc. Parameters ---------- locator : str Visible text, attribute value or Xpath expression with or without xpath= prefix. The equal sign "=" must be escaped with a "\\". attribute: str Attribute which value we want to get. value: str Expected attribute value to verify against. anchor : int Used when element_type is defined. Default=1 (first match) element_type : string Define element type/preferred searching method (available types: text, input, checkbox, item, dropdown). timeout : int How long we wait element to appear. Default=10 sec kwargs : | Accepted kwargs: | Any available for picked searching method. | See interacting with text, item, input etc. elements from | documentation Related keywords ---------------- \`GetAttribute\`, \`VerifyElement\` """ attr_val = get_attribute(locator, attribute, anchor, element_type, timeout, **kwargs) if attr_val != value: raise QWebValueError( "Expected attribute value differs from real value: {}/{}".format( value, attr_val))