示例#1
0
    def __init__(self):
        # header section
        self.header_wrap = s('.navigation-menu')
        self.header_logo = self.header_wrap.s('.logo')
        self.header_setting_icon = self.header_wrap.s('.settings')

        # table with online devices
        self.sync_device_table = s("#sync-devices")
        self.all_add_link = ss('#sync-devices-button')
        self.add_link = s('#sync-devices-button')
        self.setting_icon = s('.edit-device-menu-item.edit-item')

        # add online drive drop-down
        self.add_online_drive_link = s('.open').s(by.text('Online Drive'))
        self.all_add_dropdown_open = ss('.dropdown-menu .drive-device')

        # modal window 'create new item'
        self.modal_wrap = s('.modal.in')
        self.modal_name_input = self.modal_wrap.s('#name')
        self.modal_save_button = self.modal_wrap.s('.btn-success')
        self.modal_delete_icon = self.modal_wrap.s('.delete-item')

        # modal alert for confirm delete item
        self.confirm_delete_yes_button = s(
            by.xpath("//a[contains(@id, 'yes-button')]"))

        # error message popup
        self.error_alert_popup = s('.message.alert.alert-error')

        # header logout alert
        self.logout_alert = self.header_setting_icon.s('.open .dropdown-menu')
        self.logout_alert_sign_out_button = self.logout_alert.s('#logout')
示例#2
0
def test_indexed_selement_search_fails_with_message_when_implicitly_waits_for_condition_failed_on_collection(
):
    GIVEN_PAGE.opened_with_body('''
    <div>
        <button id='button'>Try to click me</button>
    </div>
    ''')
    config.timeout = 0.1

    with pytest.raises(TimeoutException) as ex:
        ss('button')[1].click()

    assert exception_message(ex) == \
        ['failed while waiting 0.1 seconds',
         'to assert Visible',
         "for all_by('css selector', 'button')[1]",
         '',
         'reason: TimeoutException: Message:',
         'failed while waiting 0.1 seconds',
         'to assert SizeAtLeast',
         "for all_by('css selector', 'button')",
         '',
         'reason: ConditionMismatchException: condition did not match',
         'expected: >= 2',
         'actual: 1',
         '',
         'screenshot: //.selene/screenshots/*/screen_*.png']
示例#3
0
def test_filter_tasks():
    config.browser_name = 'chrome'

    browser.open_url('https://todomvc4tasj.herokuapp.com')
    clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
    browser.wait_to(have.js_returned_true(clear_completed_js_loaded),
                    timeout=config.timeout * 3)

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()
    ss('#todo-list li').should(have.exact_texts('a', 'b', 'c'))

    ss('#todo-list li').element_by(
        have.exact_text('b')).element('.toggle').click()
    s(by.link_text('Active')).click()
    ss('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'c'))

    s(by.link_text('Completed')).click()
    ss('#todo-list li').filtered_by(be.visible).should(have.exact_texts('b'))

    s(by.link_text('All')).click()
    ss('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'b', 'c'))
示例#4
0
 def open_contact_detail(self, email):
     # browser.execute_script("location.reload()")
     self.search_input.set(email).press_enter()
     s('*[data-body-fixed="0"]').should_be(visible)
     s('.page-loading').should_not_be(visible)
     ss('div[id^="list_item"] div[data-field-id="name"]').find_by(
         text(email)).s("a").click()
     return ContactDetailSection()
示例#5
0
def test_filter_tasks():
    browser.visit('file://' + os.path.abspath(os.path.dirname(__file__)) + '/../../resources/todomvcapp/home.html')

    s('#new-todo').should(be.enabled).set_value('a').press_enter()
    s('#new-todo').should(be.enabled).set_value('b').press_enter()
    s('#new-todo').should(be.enabled).set_value('c').press_enter()

    ss("#todo-list>li").should(have.texts('a', 'b', 'c'))
示例#6
0
def test_add_tasks():
    browser.open_url(todomvc_url)
    browser.should(have.js_returned_true(is_TodoMVC_loaded))

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()

    ss("#todo-list>li").should(have.texts('a', 'b', 'c'))
示例#7
0
 def open_contact_list_section(self):
     self.menu.s('div[data-entity="catalogs"]').hover()
     s('.h-elevated').should_be(visible)
     ss('ul.aside__list li').find_by(text('Контакты')).click()
     s('.page-loading').should_not_be(visible)
     s('.h-text-overflow').should_have(exact_text('КОНТАКТЫ'))
     browser.execute_script(
         'var element = document.getElementById("left-menu-overlay");'
         'element.classList.remove("default-overlay-visible");'
         'element.classList.remove("hover-overlay");')
     return ContactListSection()
示例#8
0
def test_filter_tasks():
    browser.open_url('file://' + os.path.abspath(os.path.dirname(__file__)) + '/../../resources/todomvcapp/home.html')

    s('#new-todo').should(be.enabled).set_value('a').press_enter()
    s('#new-todo').should(be.enabled).set_value('b').press_enter()
    s('#new-todo').should(be.enabled).set_value('c').press_enter()

    config.timeout = 0.5
    with pytest.raises(TimeoutException) as ex:
        ss("#todo-list>li").should(have.size(3))

    assert "actual: 6" in ex.value.msg
def xtest_add_tasks():
    browser.open_url(todomvc_url)
    browser.should(have.js_returned_true(is_TodoMVC_loaded))

    s('#new-todo').set_value('a').press_enter()
    s('#new-todo').set_value('b').press_enter()
    s('#new-todo').set_value('c').press_enter()

    config.timeout = 0.5
    with pytest.raises(TimeoutException) as ex:
        ss("#todo-list>li").should(have.size(3))

    assert "actual: 6" in ex.value.msg
    def __init__(self):
        self.login = s("#j_username")
        self.password = s("#j_password")
        self.submit = s("#submit")

        self.projects_button = s("a[href='/projects']")
        self.projects = ss("#projects-container > div > div > table > tbody a")
        self.repos = ss(
            "#repositories-container > div > div.paged-table-container > table > tbody a"
        )

        self.clone_button = s("#clone-repo-button")
        self.actual_href_element = s(
            "#clone-repo-dialog-content > div.clone-url.ssh-clone-url-default > div.aui-buttons > input"
        )
示例#11
0
    def set_city(self, input_text, result, hint_list):
        self.event_city.scroll_to()
        self.event_city.set_value(input_text)  #Вводим значение для поля
        tooltip_holder = s("div.token-input-dropdown-timepad ul")
        tooltip_holder.should(visible)
        tooltips_all = ss("div.token-input-dropdown-timepad ul li")
        assert len(tooltips_all) > 0, f"Для поля город отстутствуют подсказки"

        value_to_select = None
        for tooltip_el in tooltips_all:
            hint_text = tooltip_el.text
            if hint_text in hint_list:
                hint_list.remove(hint_text)
            if hint_text == result:
                value_to_select = tooltip_el
        assert value_to_select is not None, (
            f"Необходимое значение {result} для поля город"
            f" отстутствует в списке подсказок")
        assert len(
            hint_list
        ) <= 0, f"В выпадающем списке подсказок отсутствует: {hint_list}"

        value_to_select.click()
        selected_value = s("li.token-input-token-timepad p")
        selected_value.should_have(text(result))
示例#12
0
 def __init__(self):
     self.title = s('.sub-header')
     self.organizationField = s(
         by.xpath("//*[text()='Наименование организации']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.userNameField = s(
         by.xpath("//*[text()='Ф.И.О. пользователя полностью']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.emailField = s(
         by.xpath("//*[text()='Рабочая электронная почта']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.phoneField = s(
         by.xpath("//*[text()='Номер телефона для связи с пользователем']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.mobileOsField = s(
         by.xpath("//*[text()='Операционная система мобильного устройства']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.googlePlayField = s(
         by.xpath("//*[text()='Учётная запись в Google Play']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.loginCheckBox = s(by.xpath("//input[@type='checkbox']"))
     self.loginField = s(
         by.xpath("//*[text()='Логин пользователя']"
                  "/ancestor::div[contains(@class, 'ErrorNotificator')]"))
     self.scanUpload = s(
         by.xpath("//input[@type='file' and @class='upload-input']"))
     self.loginButton = s(
         by.xpath("//*[text()='Отправить']/ancestor::button"))
     self.formErrors = ss('.error')
示例#13
0
    def get_label_list(self, tag_xpath: str) -> list:
        """
        Возвращает список лейблов в заданном теге.
            :param tag_xpath: Xpath тега
            :return label_list: Список лейблов в тегах
        """
        self.log.debug(
            f"Work '{self.get_method_name()}' with tag_xpath '{tag_xpath}'")

        label_list = []
        tag_elements = ss(by.xpath(tag_xpath))

        self.log.debug(f"Size tag_elements: {tag_elements.size()}")

        for label in tag_elements:
            try:
                if label.is_displayed():
                    label_text = label.text
                    if label_text != "":
                        label_list.append(label_text)
            except TimeoutException as ex:
                # self.log.debug(f"Exception: Label with xpath '{tag_xpath}' not found")
                self.log.debug(f"Exception: '{ex}'")

        self.log.debug(f"Size label_list: {len(label_list)}")
        return label_list
示例#14
0
class DroppablePage(BasePage):
    def __init__(self):
        super().__init__(
            f'{way2automation["hostname"]}{way2automation["droppable_page"]}')
        self._page_content = '//h1[contains(text(), "Droppable")]'

    tabs = ss('.responsive-tabs > li')

    draggable_elements = ss('div[id="draggable"]')
    droppable_elements = ss('div[id="droppable"]')

    default_tab = tabs[0]
    default_functionality_frame = s('iframe[src="droppable/default.html"]')
    drag_from = draggable_elements[0]
    drop_to = droppable_elements[0]
    accept_tab_frame = s('iframe[src="droppable/default2.html"]')
    accept_tab_drag_from_not_valid = s('div[id="draggable-nonvalid"]')
    accept_tab = tabs[1]
示例#15
0
    def __init__(self):
        super().__init__()
        self.url = "https://sprintboards.io/boards"

        self.green_plus = s(by.css("button.text-success>svg[data-icon=plus-circle]"))
        self.red_plus = s(by.css("button.text-danger>svg[data-icon=plus-circle]"))

        self.add_card_modal = s(by.css("#add-card-modal"))
        self.add_card_title = s(by.xpath("//div[h5[text()=\"Title\"]]//input"))
        self.add_card_description = s(by.xpath("//div[h5[text()=\"Description\"]]//textarea"))
        self.add_card_button = s(by.css("div.modal-footer button"))

        self.red_cards = ss(by.css("div.card.border-danger"))
        self.green_cards = ss(by.css("div.card.border-success"))

        self.modal_title = s(by.css("div.modal-title"))
        self.modal_body = s(by.css("div.modal-body"))
        self.modal_confirm_button = s(by.css("div.modal-footer button.btn-danger"))
示例#16
0
 def remove_all_jobs(self):
     time.sleep(1)
     jobs = ss(by.xpath('//button[starts-with(@id,"jobsListJobDeleteButton")]'))
     count = len(jobs)
     while count >= 1:
             jobs[count - 1].click()
             time.sleep(0.1)
             count -= 1
     return self
示例#17
0
def step_impl(context, price1, price2):
    """Проверяет, что в листинге товаров диапазон цен от {price1} до {price2}"""
    selectors = ss('.items [cc="item"] .wrapper__price div')
    for selector in selectors:
        price = selector.text[2:]
        price = float(price)
        price1 = float(price1)
        price2 = float(price2)
        assert price1 < price < price2, 'Фильтр по цене работает не корректно %s' % price
示例#18
0
def step_impl(context):
    """Открывает все слайдеры на странице faq"""
    selectors = ss('.faq_item')
    context.count = 0
    for selector in selectors:
        try:
            sleep(0.5)
            selector.hover().click()
            context.count += 1
        except TimeoutException:
            pass
示例#19
0
    def test_filter_tasks(self):
        browser.visit(APP_URL)

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
示例#20
0
    def get_inputs_attr_list(self, attr: str) -> list:
        """
        Возвращает список значений заданных атрибутов в тегах "input"
            :return attr_value_list: Список значений атрибутов
        """
        self.log.debug(f"Work '{self.get_method_name()}'. Attribute: '{attr}'")

        attr_value_list = []
        input_xpath = f"//input[@{attr} and @name!='csrfmiddlewaretoken']"
        input_elements = ss(by.xpath(input_xpath))

        for element in input_elements:
            attr_value_list.append(element.get_attribute(f"{attr}"))

        return attr_value_list
示例#21
0
    def get_button_attr_list(self, attr: str) -> list:
        """
        Возвращает список значений заданных атрибутов в тегах "button"
            :return attr_value_list: Список значений атрибутов
        """
        self.log.debug(f"Work '{self.get_method_name()}'. Attribute: '{attr}'")

        attr_value_list = []
        button_xpath = f"//button[@{attr}]"
        button_elements = ss(by.xpath(button_xpath))

        for element in button_elements:
            attr_value_list.append(element.get_attribute(f"{attr}"))

        return attr_value_list
示例#22
0
    def test_filter_tasks(self):
        browser.open_url(APP_URL)
        clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
        browser.wait_to(have.js_returned_true(clear_completed_js_loaded))

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
示例#23
0
 def __init__(self):
     self._header = s('app-lbl[ng-reflect-key="Header_Toolbar_WelcomeTo"]')
     self.pl = s(by.xpath('//div[text()="PL"]'))
     self.en = s(by.xpath('//div[text()="EN"]'))
     ############################################################
     self._new_job_mane = s('#jobsListNewJobNameInput')
     self._add_button = s('#jobsListNewJobNameButton')
     self.jobs_list = ss(by.xpath(' //*[starts-with(@id,"jobsListJob")]//h3'))
     self.first_job = browser.element(by.xpath(' (//*[starts-with(@id,"jobsListJob")]//h3)[1]'))
     self.removes = browser.elements(by.xpath('//h3[@class="mat-line"]/../../button'))
     self._body = s('mat-toolbar.mat-primary > span:nth-child(1)')
     self.job = 'h3.mat-line'
     self.work_plate = '#canvasPanel'
     ############################################################
     self.allert = s(by.xpath('//snack-bar-container//span'))
     ############################################################
     self.work_tab = s(by.xpath('//app-lbl[text()="Work"]'))
示例#24
0
    def test_filter_tasks(self):
        browser.open_url('https://todomvc4tasj.herokuapp.com/')
        clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
        browser.wait_to(have.js_returned_true(clear_completed_js_loaded), timeout=config.timeout*3)
        browser.wait_to(have.title(u'TroopJS • TodoMVC'))

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
示例#25
0
    def get_div_label_list(self, tag_xpath: str) -> list:
        """
        Возвращает список лейблов (текст) в теге "div"
            :param tag_xpath: Xpath тега
            :return label_list: Список лейблов
        """
        self.log.debug(
            f"Work '{self.get_method_name()}' with tag_xpath '{tag_xpath}'")

        label_list = []
        tag_div_elements = ss(by.xpath(tag_xpath))

        self.log.debug(f"Tag_div_elements: {tag_div_elements}")

        for label in tag_div_elements:
            # label.text
            self.log.debug(f"Div label element: {label}")

        return label_list
示例#26
0
    def add_cf(self, cf_type, entity):
        (
            self
            .cf_type_select
            .click()
            .ss('ul.control--select--list-opened li span')
            .filter(text(cf_type.value)).first()
            .scroll_to()
            .click()
        )

        self.name_input.set('_'.join([entity.value, cf_type.name]))

        if cf_type in [CFType.LIST, CFType.MULTI_LIST, CFType.SWITCHER]:
            opt_inputs = ss('input[placeholder="Вариант"]')

            for i, opt_input in zip(range(1, 6), opt_inputs):
                opt_input.set('_'.join([cf_type.value, str(i)]))

        self.save_btn.click()
        self.cf_props_container.should_not_be(visible)
示例#27
0
    def close_frames(self, wait_time: int = 60) -> None:
        """
        Закрыть все 'iframes' путём нажатия крестика в закладке
            :param wait_time: Время ожидания в секундах
        """

        self.log.debug(
            f"Work '{self.get_method_name()}'. Wait time: {wait_time} seconds."
        )

        close_frame_xpath = "//div[@id='mainTabs']//div[@class='close-button']"

        frames_count_for_close = 10  # Бывали зацикливания какие-то в Webdriver
        while frames_count_for_close > 0:

            crosses_closing_frames = ss(by.xpath(close_frame_xpath))
            frames_count = crosses_closing_frames.size()
            self.log.debug(f"Opened frames: {frames_count} ")
            if frames_count > 0:

                # Обработка долгого автоматического обновления фрейма
                self.check_show_control_with_adaptive_waiting(
                    close_frame_xpath, wait_time)

                self.highlight(crosses_closing_frames[0])

                try:
                    crosses_closing_frames[0].click()
                except WebDriverException:
                    self.log.debug(
                        f"Cross click error - wait {config_file.WAIT_TIMEOUT} second"
                    )
                    time.sleep(config_file.WAIT_TIMEOUT)
                    crosses_closing_frames[0].click()

                frames_count_for_close -= 1
            else:
                break
示例#28
0
 def __init__(self):
     self.details = self.Details(s('#order_details'))
     self.add_item = s('#add_item')
     self.items = self.Items(ss('[id^="item"]'))
示例#29
0
def step_impl(context, value):
    """Проверяет, что листинг товаров отсортирован по фильтру качества {value}"""
    sleep(3)
    selectors = ss('.items [cc="item"] .s_c .r')
    for selector in selectors:
        assert selector.text == value, 'листинг товаров не отфлильтрофан по филтру качества %s или нет предметов, которые подходяд под условие' % value
示例#30
0
 def __init__(self):
     self.search_results = ss("a > h3")