def open_product_edit_dialog(self, product_name: str): s(by.xpath(self.__refund_goods_row.format(product_name))).hover() s(by.xpath( self.__refund_goods_edit_button.format(product_name))).should( be.clickable).click() self.__refund_goods_edit_modal.should(be.visible) return True
def __init__(self): super().__init__() self.container = s(by.xpath(self._container_locator)) self.tab = s(by.xpath('//a[@data-tab="smart-id"]')) self.personal_code_input = s( by.xpath( f'{self._container_locator}//input[@id="sid-personal-code"]')) self.continue_btn = s( by.xpath( '//*[@id="smartIdForm"]//button[contains(@class, "c-btn c-btn--primary")]' ))
def __init__(self, header_locator: str): self._locator = f'({header_locator}//*[contains(@class, "menu-dropdown-root")])[1]' self.button = s(by.xpath(f'{self._locator}//button')) self.current_lang = s( by.xpath(f'{self._locator}//button//*[@class="value"]')) self.en_lang = s( by.xpath( '(//ul//a[contains(@class, "dropdown-item")][contains(text(), "ENG")])[1]' )) self.est_lang = s( by.xpath( '(//ul//a[contains(@class, "dropdown-item")][contains(text(), "EST")])[1]' ))
def __init__(self, text: str = "", index: int = None): self._locator_by_text = f'//*[contains(text(), "{text}")]/ancestor::*[@class="message"]' self._locator_by_index = f'({self._locator})[{index}]' self._locator = self._locator_by_text if text else self._locator_by_index self.container = s(by.xpath(self._locator)) self.title = s( by.xpath(f'{self._locator}//*[contains(@class, "title")]')) self.details = s(by.xpath(f'{self._locator}//*[@class="properties"]')) self.unread_indicator = s( by.xpath( f'{self._locator}//*[contains(@class, "unread-indicator")]')) self.see_message_link = s( by.xpath(f'({self._locator}//*[@class="actions"]//a)[1]'))
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)
def get_current_residue(self, product_name: str, stock_name: str = None): if stock_name: self.set_stock(stock_name) row_sel = self.__target_row_f.format(product_name) residue_sel = row_sel + '/div[@data-body-cell="residue"]' residue = s(by.xpath(residue_sel)).should(be.visible).get(query.text) return int(residue)
def _set_client(self, client_name=None): client_input = self.__sales_dialog_client_input.should(be.visible) client_input.should(be.clickable).click() client_input.set_value(client_name or self.__client_name) target = by.xpath(self.__sales_dialog_client_target.format(client_name or self.__client_name)) s(target).should(be.clickable).click() s(target).should(be.not_.visible)
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 open_document(self, label): sel = self.__document.format(label) target = s(by.xpath(sel)) s(DIALOG_MASK_JS).should(be.not_.visible) target.should(be.clickable).click() self.__document_view_dialog.should(be.visible) return True
def set_supplier(self, supplier, quick=True): # for now, supplier is supplier name. In future, it be dict with enhanced data self.__supplier_input.should(be.clickable).type(supplier) target = by.xpath(self.__supplier_dropdown_target.format(supplier)) if is_element_displayed(target): s(target).should(be.match.element_has_text(supplier)).click() else: self.__create_new_supplier(supplier, quick)
def __init__(self, goods_name=None): self.__page_url = WH_RESIDUE_URL self.__residue_table = s(TABLE_BODY['table']) self.__residue_row = s(TABLE_BODY['row']) self.__goods_row = TABLE_BODY['row'] self.__target_row_f = TABLE_BODY['row_by_title'] self.__target_goods_dialog_f = TARGET_GOODS_DIALOG_XPH_F self.__stock_select = s(WAREHOUSE_FILTER_SELECT) if goods_name: self.__target_goods_row = by.xpath( TABLE_BODY['row_by_title'].format(name=goods_name))
def _get_refund_goods_details(self, goods_name: str): curr_qty_sel = self.__refund_product_curr_quantity.format(goods_name) curr_quantity: int = s(by.xpath(curr_qty_sel)).get(query.value) aval_quantity: int = int( s(by.xpath( self.__refund_product_aval_quantity.format(goods_name))).get( query.text).replace('/', '').strip()) price: int = int( s(by.xpath(self.__refund_product_price.format(goods_name))).get( query.text)) total_price: int = int( s(by.xpath(self.__refund_product_sum.format(goods_name))).get( query.text)) comment: str = self.__refund_comment.get(query.value) data = dict(current_quantity=curr_quantity, avaliable_quantity=aval_quantity, price=price, total_price=total_price, comment=comment) return data
def __init__(self): super().__init__() self._container_locator = '//*[@class="the-mailbox-root content"]//*[@class="container"]' self.tab = s(by.xpath('(//*[@class="nav nav-tabs"]//li)[3]')) self.to_input = s(by.xpath(f'({self._container_locator}//input)[1]')) self.subject_input = s(by.xpath(f'({self._container_locator}//input)[2]')) self.text_area = s(by.xpath(f'{self._container_locator}//textarea')) self.attach_files_btn = s(by.xpath( f'{self._container_locator}//i[contains(@class, "material-icons-outlined")]' f'/ancestor::button')) self.sign_with_id_card_btn = s(by.xpath( f'{self._container_locator}//*[contains(@class, "sign-icon")]/ancestor::button')) self.send_message_btn = s(by.xpath( f'{self._container_locator}//button[@variant="primary"][2]'))
def __init__(self): self.container = s(by.xpath(self._locator)) self.subject = s( by.xpath(f'{self._locator}//*[contains(@class, "subject")]')) self.details = s( by.xpath(f'{self._locator}//*[contains(@class, "details")]')) self.timestamp = s(by.xpath(f'{self._locator}//*[@class="timestamp"]')) self.body = s( by.xpath(f'{self._locator}//*[contains(@class, "body")]')) self.back_btn = s( by.xpath( f'{self._locator}//button[contains(@class, "c-btn--primary")]') )
def set_product_quantity(self, quantity: int, serials: list = None): if serials: added_serials = [] for _ in range(quantity): num = serials.pop(0) added_serials.append(num) self.__refund_goods_edit_modal_serial_input.set_value(num) self.__refund_goods_edit_modal_serial_dropdown.should( be.visible) element = by.xpath( self.__refund_goods_edit_modal_serial_dropdown_item.format( num)) s(element).should(be.clickable).click() s(self.__refund_goods_edit_modal_serial_label.format( num)).should(be.visible) is_set_correctly = int( self.__refund_goods_edit_modal_serial_total_count.get( query.value)) == quantity else: self.__refund_goods_edit_modal_quantity_input.set_value(quantity) val = int( self.__refund_goods_edit_modal_quantity_input.get(query.value)) is_set_correctly = val == quantity return is_set_correctly
def __init__(self): self.container = s(by.xpath(self._container_locator)) self.tab: SeleneElement = NotImplementedError
def __init__(self): self.container = s(by.xpath(self._container_locator)) self.log_out_link = s(by.xpath( f'{self._container_locator}//*[contains(@class, "logout")]//a[@href="/logout"]')) self.role_1 = self._get_role_by_index(1) self.role_2 = self._get_role_by_index(2)
def _get_role_by_index(index: int): return s(by.xpath(f'(//*[contains(@class, "list-group")]//button)[{index}]'))
def product_row_join(self, product_name): element = s(by.xpath(self.__target_row_f.format(product_name))) element.double_click() s(by.xpath(self.__target_goods_dialog_f.format(product_name))).should( be.visible)
def __init__(self): super().__init__() self.container = s(by.xpath('(//*[@class="message-list-root"])[2]')) self.tab = s(by.xpath('(//*[@class="nav nav-tabs"]//li)[2]'))
def is_current_user(self, first_name, last_name): self.__avatar.should(be.visible) s(by.xpath( f"//li[contains(text(), '{first_name} {last_name}')]")).should( be.in_dom) return True
from selene.api import by MOVEMENT_ADD_NEW_BUTTON = '#warehouse_move_table [data-cid="table-btn-add"]' MOVEMENT_CREATE_FRAME = by.xpath("//div[text()='Новое перемещение']//ancestor::div[contains(@class, 'js-header-root')]") MOVEMENT_STOCK_FROM = 'select[id$="move"]' MOVEMENT_STOCK_TO = 'select[id$="move-target"]' MOVEMENT_NAME_INPUT = '.js-prodpicker-prod-drop input' MOVEMENT_DROPDOWN_TARGET = "//tr[contains(@class, 'b-dropdown__item')]//div[text()='{}']" MOVEMENT_QUANTITY_MODAL = '[data-cid="winbox-modal-root"]' MOVEMENT_QUANTITY_MODAL_INPUT = f'{MOVEMENT_QUANTITY_MODAL} input[name^="qty"]' MOVEMENT_QUANTITY_MODAL_INPUT_SERIAL = f'{MOVEMENT_QUANTITY_MODAL} input[name="serial_numbers"]' MOVEMENT_QUANTITY_ADD_ALL_BUTTON = '.js-qtypicker-cell span[class*="add-all"]' MOVEMENT_QUANTITY_ADD_ALL_BUTTON_SERIAL = '.js-serialpicker-root span[class*="add-all"]' MOVEMENT_SUBMIT_QUANTITY_MODAL_BUTTON = '.js-prodedit-submit' MOVEMENT_COMMENTS_AREA = '#l-wh-comments' MOVEMENT_SUBMIT_BUTTON = '.js-wh-move-create-submit'
def __init__(self): self.container = s(by.xpath(self._container_locator)) self.header = Header() self.inbox_tab = InboxTab() self.outbox_tab = OutboxTab() self.new_message_tab = NewMessageTab()
def __init__(self): self.en_lang = s(by.xpath('//nav//a[@lang="en"]')) self.ru_lang = s(by.xpath('//nav//a[@lang="ru"]'))
def __init__(self): self.container = s(by.xpath(self._container_locator)) self.header = Header() self.mobile_id_tab = MobileIdTab() self.smart_id_tab = SmartIdTab()
def _set_product(self, product_name): self.__sales_dialog_product_input.set_value(product_name) target = by.xpath(self.__sales_dialog_product_target.format(product_name)) s(target).should(be.clickable).click() s(target).should(be.not_.visible)
from selene.api import by, s, ss 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}']") }