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 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 _populate_book_info(input_data): wait_for(_id='series_title') write(_id='publisher_name', data=input_data.publisher_name) write(_id='publication_date', data=input_data.publication_date) write(_id='publication_place', data=input_data.publication_place) write(_id='series_title', data=input_data.book_title) write(_id='series_volume', data=input_data.book_volume)
def _populate_thesis_info(input_data): wait_for(_id='supervisors-0-name') write(_id='supervisors-0-name', data=input_data.supervisor_name) write( _id='supervisors-0-affiliation', data=input_data.supervisor_affiliation, ) write(_id='thesis_date', data=input_data.thesis_date) write(_id='defense_date', data=input_data.defense_date) write(_id='degree_type', data=input_data.degree_type) write(_id='institution', data=input_data.institution)
def write_institution_thesis(institution, expected_data): def _assert_has_no_errors(): assert ( expected_data == Arsenic().write_in_autocomplete_field( 'supervisors-0-affiliation', institution, ) ) _skip_import_data() _populate_document_type('thesis') wait_for(_id='supervisors-0-affiliation') return ArsenicResponse(assert_has_no_errors_func=_assert_has_no_errors)
def submit_doi_id(doi_id, expected_data): write(_id='doi', data=doi_id) click(_id='importData') click(_id='acceptData') wait_for(_id='doi') _skip_import_data() output_data = { 'year': get_value_of(_id='year'), 'title': get_value_of(_id='title'), 'issue': get_value_of(_id='issue'), 'volume': get_value_of(_id='volume'), 'journal': get_value_of(_id='journal_title'), 'author': get_value_of(_id='authors-0-name'), 'author-1': get_value_of(_id='authors-1-name'), 'author-2': get_value_of(_id='authors-2-name'), 'page-range': get_value_of(_id='page_range_article_id'), } def _assert_has_no_errors(): assert expected_data == output_data return ArsenicResponse(assert_has_no_errors_func=_assert_has_no_errors)
def _populate_chapter_info(input_data): wait_for(_id='book_title') write(_id='book_title', data=input_data.book_title) write(_id='start_page', data=input_data.page_start) write(_id='end_page', data=input_data.page_end)