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)
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def __init__(self):
     self.__info_notifier = s(NOTIFIES['blue'])
     self.__page_url = SETTINGS_COMMON_URL
     self.__general_url = SETTINGS_GENERAL_URL
     self.__general_address_storage_checkbox_span = s(
         ADDRESS_STORAGE_CHECKBOX_SPAN)
     self.__general_address_storage_checkbox_input = s(
         ADDRESS_STORAGE_CHECKBOX_INPUT)
     self.__settings_branch_url = SETTINGS_BRANCH_URL
     self.__settings_locations_url = SETTINGS_BRANCH_URL
     self.__settings_employee_url = SETTINGS_EMPLOYEE_URL
     self.__settings_status_url = SETTINGS_STATUS_URL
     self.__settings_tags_url = SETTINGS_TAGS_URL
     self.__settings_notifications_url = SETTINGS_NOTIFICATIONS_URL
     self.__settings_services_url = SETTINGS_SERVICES_URL
     self.__settings_book_url = SETTINGS_BOOK_URL
     self.__settings_form_editor_url = SETTINGS_FORM_EDITOR_URL
     self.__settings_templates_url = SETTINGS_TEMPLATES_URL
     self.__settings_price_and_discount_url = SETTINGS_PRICE_AND_DISCOUNT_URL
     self.__settings_marketing_url = SETTINGS_MARKETING_URL
     self.__settings_integrations_url = SETTINGS_INTEGRATIONS_URL
     self.__settings_api_url = SETTINGS_API_URL
     self.__settings_license_url = SETTINGS_LICENSE_URL
     self.__settings_referrals_url = SETTINGS_REFERRALS_URL
     self.__settings_partners_url = SETTINGS_REFERRALS_URL
 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
Ejemplo n.º 5
0
 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 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)
Ejemplo n.º 7
0
 def __get_product_category_element(self, category_name):
     if category_name == 'parts':
         target_category_element = s(self.__new_product_category_parts)
     elif category_name == 'store':
         target_category_element = s(self.__new_product_category_store)
     else:
         target_category_element = s(
             self.__new_product_category_custom.format(category_name))
     return target_category_element
Ejemplo n.º 8
0
 def __add_serial_numbers(self, serial_numbers: list):
     added_numbers = []
     for i in range(len(serial_numbers)):
         serial_for_adding = serial_numbers[i]
         added_numbers.append(serial_for_adding)
         self.__serial_number_input.should(
             be.visible).type(serial_for_adding).press_tab()
         s(self.__serial_number_added.format(serial_for_adding)).should(
             be.visible)
     return added_numbers
Ejemplo n.º 9
0
 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']")
Ejemplo n.º 10
0
 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, 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))
Ejemplo n.º 12
0
 def __set_count_serial(self, count, serials: list):
     if count == len(serials):
         self.__sales_modal_quantity_serial_add_all_button.click()
         for num in serials:
             s(self.__sales_modal_serial_label.format(num)).should(be.visible)
     else:
         added_serials = []
         for _ in range(count):
             num = serials.pop(0)
             added_serials.append(num)
             self.__sales_modal_serial_input.set_value(num)
             s(self.__sales_modal_serial_label.format(num)).should(be.visible)
Ejemplo n.º 13
0
 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]'
         ))
Ejemplo n.º 14
0
 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]'))
Ejemplo n.º 15
0
 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]
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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)
Ejemplo n.º 19
0
 def __init__(self, login: str = None, password: str or int = None):
     super().__init__()
     self.login = login
     self.password = password
     self.__login_input = s(AUTH_LOGIN_INPUT)
     self.__email_input = s(AUTH_EMAIL_INPUT)
     self.__password_input = s(AUTH_PASSWORD_INPUT)
     self.__first_name_input = s(REGISTER_FIRST_NAME_INPUT)
     self.__last_name_input = s(REGISTER_LAST_NAME_INPUT)
     self.__company_name_input = s(REGISTER_COMPANY_NAME_INPUT)
     self.__country_select = REGISTER_COUNTRY_SELECT
     self.__city_input = s(REGISTER_CITY_INPUT)
     self.__phone_input = s(REGISTER_PHONE_INPUT)
     self.__template_select = REGISTER_TEMPLATE_SELECT
     self.__register_submit_button = s(REGISTRATION_SUBMIT_BUTTON)
     self.__submit_button = s(SUBMIT_BUTTON)
Ejemplo n.º 20
0
 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)
Ejemplo n.º 21
0
 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 __get_order_id(self):
     order_id = None
     try:
         order_id = s(self.__target_goods_row).get(
             query.attribute(name='data-order-id'))
     except Exception as e:
         print('\nNo target goods initialized in class!')
         print(type(e))
     return order_id
Ejemplo n.º 23
0
    def set_quantity(self, quantity: int, serials: list or tuple = None):
        """if product is serial - 'serials' should be filled by that product serial numbers"""
        self.__movement_quantity_modal.should(be.visible)
        added_serials = []
        if serials:
            for _ in range(quantity):
                num = serials.pop(0)
                self.__movement_quantity_input_serial.type(num).press_tab()
                s(self.__serial_tag_f.format(num)).should(be.visible)
                added_serials.append(num)
        else:
            self.__movement_quantity_input.should(
                be.clickable).set_value(quantity)

        self.__submit_quantity_modal_button.click()
        self.__movement_quantity_modal.should(be.not_.visible)

        return tuple(added_serials)
Ejemplo n.º 24
0
    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):
     self.__preloader = s(PRELOADER_SPINNER)
     self.__residue_tab = RESIDUE_TAB
     self.__posting_tab = POSTING_TAB
     self.__writeoff_tab = WRITEOFF_TAB
     self.__movements_tab = MOVE_TAB
     self.__stocktaking_tab = STOCKTAKING_TAB
     self.__supplier_refunds_tab = REFUNDS_TAB
     self.__settings_tab = SETTINGS_TAB
     self.__active_tab_prefix = ACTIVE_TAB_PREFIX
     self.tabs = (
         self.__residue_tab, self.__posting_tab, self.__writeoff_tab, self.__movements_tab,
         self.__stocktaking_tab, self.__supplier_refunds_tab, self.__settings_tab)
 def __init__(self, page_url=None):
     super().__init__()
     if page_url:
         self.__page_url = page_url
     self._create_refund_dialog = s(REFUND_DIALOG)
     self.__page_url = WH_POSTING_URL
     self.__preloader = s(PRELOADER_SPINNER)
     self.__document = POSTING_DOCUMENT_LABEL_X
     self.__document_view_dialog = s(POSTING_VIEW_DIALOG)
     self.__document_close_button = s(POSTING_VIEW_DIALOG_CLOSE_BUTTON)
     self.__create_refund_button = CREATE_REFUND_BUTTON
     self.__close_refund_dialog_button = s(REFUND_DIALOG_CLOSE_BUTTON)
     self.__submit_button = s(POSTING_SUBMIT_BUTTON)
     self.__info_notifier = s(NOTIFIES['blue'])
     self.__dialog_mask_active = s(DIALOG_MASK_JS)
Ejemplo n.º 27
0
 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
Ejemplo n.º 28
0
 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]'))
Ejemplo n.º 29
0
 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 test_search_2(self):
        """Fill in the search form, press the search button, check for results
        """

        # type "cheese" into the search field
        s('[name="q"]') \
            .set_value('cheese')

        # click the "Google Search" button
        s('[name="btnK"]') \
            .click()

        # check that results are shown
        s('#resultStats') \
            .should(be.visible)