def write_pdf_link(pdf_link): try: wait_for(_id='url') except (ElementNotVisibleException, WebDriverException): _skip_import_data() field = wait_for(_id='url') field.send_keys(pdf_link) Arsenic().hide_title_bar() Arsenic().click_with_coordinates('state-group-url', 5, 5) try: message_err = get_text_of(_id='state-url') except (ElementNotVisibleException, WebDriverException): message_err = '' Arsenic().show_title_bar() field.clear() def _assert_has_errors(): assert ( 'Please, provide an accessible direct link to a PDF document.' ) in message_err def _assert_has_no_errors(): assert ( 'Please, provide an accessible direct link to a PDF document.' ) not in message_err return ArsenicResponse( assert_has_errors_func=_assert_has_errors, assert_has_no_errors_func=_assert_has_no_errors, )
def write_date_thesis(date_field, error_message_id, date): try: wait_for(_id=date_field) except (ElementNotVisibleException, WebDriverException): _skip_import_data() _populate_document_type('thesis') field = wait_for(_id=date_field) field.send_keys(date) Arsenic().hide_title_bar() Arsenic().click_with_coordinates('state-group-supervisors', 5, 5) try: error_message = get_text_of(_id=error_message_id) except (ElementNotVisibleException, WebDriverException): error_message = '' Arsenic().show_title_bar() field.clear() def _assert_has_errors(): return ( 'Please, provide a valid date in the format YYYY-MM-DD, YYYY-MM ' 'or YYYY.' ) in error_message def _assert_has_no_errors(): return ( 'Please, provide a valid date in the format YYYY-MM-DD, YYYY-MM ' 'or YYYY.' ) not in error_message return ArsenicResponse( assert_has_errors_func=_assert_has_errors, assert_has_no_errors_func=_assert_has_no_errors, )
def get_first_record_info(try_count=0): def _refresh_and_retry(try_count): Arsenic().refresh() return get_first_record_info(try_count=try_count) try: click(xpath=FIRST_RECORD_SHOW_ABSTRACT_LINK) record = get_text_of(xpath=FIRST_RECORD) except (ElementNotVisibleException, WebDriverException): try_count += 1 if try_count >= 15: raise record = _refresh_and_retry(try_count=try_count) if 'Waiting' in record: try_count += 1 if try_count >= 15: raise Exception( 'Timed out waiting for record to get out of Waiting status.') return _refresh_and_retry(try_count=try_count) return record
def _assert_has_no_errors(): message = get_text_of(xpath=SUBMIT_RESULT_ALERT_SUCCESS) assert GOOD_MESSAGE in message