def __init__(self, cell_name='Ячейка 1'): self._cell_quantity_input = s( SelectorsSales.SALES_MODAL_QUANTITY_INPUT_F.format(cell_name)) self._cell_add_all_button = s( SelectorsSales.SALES_MODAL_QUANTITY_ADD_ALL_BUTTON_F.format( cell_name)) self._warranty_by_days_button = ss( SelectorsSales.SALES_MODAL_WARRANTY_BUTTON)[0] self._warranty_by_months_button = ss( SelectorsSales.SALES_MODAL_WARRANTY_BUTTON)[1] self._modal_discount_absolute_button = ss( SelectorsSales.SALES_MODAL_DISCOUNT_BUTTON)[0] self._modal_discount_percent_button = ss( SelectorsSales.SALES_MODAL_DISCOUNT_BUTTON)[1]
def __init__(self): self.password_input = s('[name="pass"]') self.login_button = s('.auth__submit') self.telephon_input = s('#tel') self.password_eye_button = s('#pass+button') self.fogott_password_link = s('.auth__pass-link') self.register_link = s('.auth__footer a') self.title_name = s('h1') self.input_error_blocks_login = ss('.input-block.has-error')[0].s('#tel') self.input_error_blocks_password = ss('.input-block.has-error')[0].s('#pass') self.input_error_blocks = ss('.input-block.has-error') self.error_text = 'span' self.back_error_text = s('.auth__master-error') self.captcha_block = s('auth__captcha')
def check_filtered_price_is_in_range(self, min_value, max_value): self.spinner.should_not(be.visible) prices = ss('span.price___DElEo') for el in prices: price_text = el.text price_value = int(price_text.split(' ')[1]) assert price_value in range(min_value, max_value)
def check_body_style_is(self, search_filter): self.spinner.should_not(be.visible) body_classes = ss('div.type___2jLsS') for el in body_classes: body_class_text = el.text body_class_name = body_class_text.split(',')[0] assert body_class_name == search_filter
class TestHelperMethods: @pytest.fixture(scope='session') def remonline_start_page(self): browser.open(get_default_url()) @pytest.fixture(scope='session') def google_page(self): browser.open('http://google.com') FIELD_ID = 'l-auth-login' ELEMENTS = {'css': f'#{FIELD_ID}', 'xpath': f"//input[@id='{FIELD_ID}']", 'selenium_element': 'web_element', 'selene_element': s(f'#{FIELD_ID}'), 'selene_collection': ss(f'#{FIELD_ID}'), 'by': by.xpath(f"//input[@id='{FIELD_ID}']")} @pytest.mark.parametrize('field_type', ELEMENTS) def test_is_element_displayed(self, remonline_start_page, field_type): field = self.ELEMENTS[field_type] if field == 'web_element': field = s(f'#{self.FIELD_ID}') assert is_element_displayed(field, timeout=4) @pytest.mark.parametrize('field_type', ELEMENTS) def test_is_element_not_displayed(self, google_page, field_type): field = self.ELEMENTS[field_type] if field == 'web_element': try: field = s(f'#{self.FIELD_ID}') except NoSuchElementException: field = None assert not is_element_displayed(field, 0.5)
class TestHelperMethods(FixturesSettings, FixturesHelper): FIELD_ID = 'l-auth-login' ELEMENTS = { 'css': f'#{FIELD_ID}', 'xpath': f"//input[@id='{FIELD_ID}']", 'selenium_element': 'web_element', 'selene_element': s(f'#{FIELD_ID}'), 'selene_collection': ss(f'#{FIELD_ID}'), 'by': by.xpath(f"//input[@id='{FIELD_ID}']") } @pytest.mark.parametrize('field_type', ELEMENTS) def test_is_element_displayed(self, remonline_start_page, field_type): field = self.ELEMENTS[field_type] if field == 'web_element': field = s(f'#{self.FIELD_ID}') assert is_element_displayed(field, timeout=4) @pytest.mark.parametrize('field_type', ELEMENTS) def test_is_element_not_displayed(self, google_page, field_type): field = self.ELEMENTS[field_type] if field == 'web_element': try: field = s(f'#{self.FIELD_ID}') except NoSuchElementException: field = None assert not is_element_displayed(field, 0.5)
def __init__(self, app: Browser): super().__init__(app) self.wrapper = ss( "//div[contains(@class, 'ant-modal-wrap') and not(@style='display: none;')]" )[-1] self.content = self.wrapper.s( "./descendant::div[@class='ant-modal-content']") self.modal_footer = self.wrapper.s( "./descendant::div[@class='ant-modal-footer']")
def update_table_component(): try: if is_element_displayed(PRELOADER_SPINNER): loaders = ss(PRELOADER_SPINNER) for spinner in loaders: spinner.should(be.not_.visible) except (NoSuchElementException, TimeoutException, StaleElementReferenceException, TypeError): s(PRELOADER_SPINNER).with_(timeout=10).should(be.not_.visible)
def __init__(self, driver): super().__init__(driver) self._input_search = s("#inpHeaderSearch") self._container_search = s( "//div[contains(@class, 'search-results-container')]") self.txt_qty_products_found = s("//div[@class='header-search']").s( "./descendant::small") self._txt_products_not_found = s("//div[@class='header-not-found']") self.first_prod = s("//li[@class='product']") self._products = ss("//li[@class='product']")
def __init__(self): self.__create_new_posting_dialog = s(POSTING_CREATE_DIALOG_FACE) self.__create_new_posting_button = s(POSTING_CREATE_NEW_BUTTON) # SUPPLIER self.__supplier_input = s(POSTING_SUPPLIER_INPUT) self.__supplier_dropdown_target = POSTING_SUPPLIER_DROPDOWN_TARGET_X_F # new client self.__add_new_client_plus_button = s( POSTING_ADD_NEW_CLIENT_PLUS_BUTTON) self.__add_new_client_dropdown_button = s( POSTING_ADD_NEW_CLIENT_DROPDOWN_BUTTON) self.__client_dialog = s(POSTING_CLIENT_DIALOG) self.__client_dialog_name_input = s(POSTING_CLIENT_DIALOG_NAME_INPUT) self.__client_dialog_submit_button = s( POSTING_CLIENT_DIALOG_SUBMIT_BUTTON) # WAREHOUSE self.__warehouse_select = POSTING_WAREHOUSE_SELECT # PRODUCT self.__name_input = s(POSTING_PRODUCT_NAME_INPUT) self.__new_product_area = s(POSTING_NEW_PRODUCT_AREA) self.__new_product_category_dropdown = s( POSTING_NEW_PRODUCT_CATEGORY_DROPDOWN) self.__new_product_category_parts = POSTING_NEW_PRODUCT_CATEGORY_TARGET_PARTS self.__new_product_category_store = POSTING_NEW_PRODUCT_CATEGORY_TARGET_STORE self.__new_product_category_custom = POSTING_NEW_PRODUCT_CATEGORY_TARGET_CUSTOM self.__new_product_quantity_input = s( POSTING_NEW_PRODUCT_QUANTITY_INPUT) self.__new_product_add_button = s(POSTING_NEW_PRODUCT_ADD_BUTTON) # price self.__new_product_price_purchase_input = s( POSTING_NEW_PRODUCT_PRICE_PURCHASE_INPUT) self.__new_product_price_zero_input = s( POSTING_NEW_PRODUCT_PRICE_ZERO_INPUT) self.__new_product_price_repair_input = s( POSTING_NEW_PRODUCT_PRICE_REPAIR_INPUT) self.__new_product_price_retail_input = s( POSTING_NEW_PRODUCT_PRICE_RETAIL_INPUT) # serial self.__new_product_is_serial_checkbox_input = s( POSTING_NEW_PRODUCT_IS_SERIAL_CHECKBOX_INPUT) self.__new_product_is_serial_checkbox_label = s( POSTING_NEW_PRODUCT_IS_SERIAL_CHECKBOX_LABEL) self.__serial_numbers_frame = s( POSTING_NEW_PRODUCT_SERIAL_NUMBERS_FRAME) self.__serial_number_input = s( POSTING_NEW_PRODUCT_SERIAL_NUMBERS_INPUT) self.__serial_number_added = POSTING_NEW_PRODUCT_SERIAL_NUMBERS_ADDED_NUMBER_F # VIEW self._posting_view_product_title = s(POSTING_VIEW_PRODUCT_TITLE) self._posting_view_product_titles = ss(POSTING_VIEW_PRODUCT_TITLE)
def __init__(self): super().__init__() self.__close_refund_dialog_button = s(REFUND_DIALOG_CLOSE_BUTTON) self.__document_row = s(REFUND_DOCUMENT_ROW_X) self.__supplier_row = s(REFUND_SUPPLIER_ROW_X) self.__supplier_passport_dialog = s(REFUND_DIALOG_SUPPLIER_PASSPORT) self.__supplier_passport_close_button = s( REFUND_DIALOG_SUPPLIER_PASSPORT_CLOSE_BUTTON) self.__stock_select = s(REFUND_STOCK_SELECTOR) self.__refund_goods = ss(REFUND_GOODS) self.__refund_goods_row = REFUND_TARGET_GOODS_ROW_F self.__refund_goods_edit_button = REFUND_GOODS_EDIT_BUTTON_X_F self.__refund_goods_edit_modal = s(REFUND_GOODS_EDIT_MODAL_X) self.__refund_goods_edit_modal_quantity_input = s( REFUND_GOODS_EDIT_MODAL_QUANTITY_SINGLE_INPUT) self.__refund_goods_edit_modal_serial_input = s( REFUND_GOODS_EDIT_MODAL_SERIAL_NUMBER_INPUT) self.__refund_goods_edit_modal_serial_dropdown = s( REFUND_GOODS_EDIT_MODAL_SERIAL_NUMBER_DROPDOWN) self.__refund_goods_edit_modal_serial_dropdown_item = REFUND_GOODS_EDIT_MODAL_SERIAL_NUMBER_ITEM_X_F self.__refund_goods_edit_modal_serial_label = REFUND_GOODS_EDIT_MODAL_SERIAL_NUMBER_LABEL_X_F self.__refund_goods_edit_modal_serial_total_count = s( REFUND_GOODS_EDIT_MODAL_SERIAL_ITEMS_TOTAL_COUNT) self.__refund_goods_edit_modal_price_input = s( REFUND_GOODS_EDIT_MODAL_PRICE_INPUT) self.__refund_goods_edit_modal_comment_input = s( REFUND_GOODS_EDIT_MODAL_COMMENT_INPUT) self.__refund_goods_edit_modal_add_all_button = s( REFUND_GOODS_EDIT_MODAL_ADD_ALL) self.__refund_goods_edit_modal_close_button = s( REFUND_GOODS_EDIT_MODAL_CLOSE_BUTTON) self.__refund_goods_edit_modal_save_button = s( REFUND_GOODS_EDIT_MODAL_SAVE_BUTTON) self.__refund_product_curr_quantity = REFUND_GOODS_CURR_QUANTITY_X_F self.__refund_product_aval_quantity = REFUND_GOODS_AVAL_QUANTITY_X_F self.__refund_product_price = REFUND_GOODS_PRICE_X_F self.__refund_product_sum = REFUND_GOODS_SUM_X_F self.__refund_comment = s(REFUND_COMMENT) self.__make_refund_button = s(REFUND_SUBMIT_BUTTON)
def get_search_input(): return ss('.search-input')[1]
def get_price_list(): return reduce((lambda x, y: x + y), [int(el.text[:-4]) for el in ss('tbody .price')])
def get_select_delivery_type(): ss('.react-select-container')[1].click()
def click_my_orders(): ss('.user-menu-profile-body ul a')[2].click()
def click_status(): ss('.react-select-container')[2].click()
def click_select_status(status=None): for el in ss('.react-select__menu div'): if re.match(el.text, status, re.I): el.click() break
def click_button_payment(): ss('.nested-row-header .btn-blue')[0].click()
def click_select_office_sale(office=None): for el in ss('.react-select__menu div'): if re.match(el.text, office, re.I): el.click() break
def get_brand_text_list(): return [ el.text for el in ss('tbody .name > strong').should(have.size_at_least(1)) ]
def options(self): return ss( "//*[contains(@class, 'ant-select-dropdown') " "and not(contains(@class, 'ant-select-dropdown-hidden'))]/div/ul/li" )
def __init__(self, driver): super().__init__(driver) self.products = ss("//div[@class='BasketItem']") self.first_product = s("//div[@class='BasketItem']")
def get_items(): return ss(".searchbar_results-name")
def order_num_list(): return [ el.text for el in ss('tbody p strong:not([class]').should( have.size_at_least(1)) ]
def get_rows_order_part(): return ss(by.xpath('//tr [@class=" "]')).should_be( have.size_at_least(1))
def get_number_list(): return ss('tbody .name a')
def office_list(): return [ el.text for el in ss('tbody .order-office').should(have.size_at_least(1)) ]
def click_office_sale(): ss('.react-select-container')[0].click()
def proceed_to_checkout_on_summary(): ss('a[title="Proceed to checkout"]')[1].click()
def status_list(): return [ el.text for el in ss('tbody .order-status').should(have.size_at_least(1)) ]