Example #1
0
class ProductEntry:
    def __init__(self, product_entry):
        self.a_link = Find(by=By.CSS_SELECTOR,
                           value="a.s-access-detail-page",
                           context=product_entry)
        self.name = Find(by=By.CSS_SELECTOR,
                         value="h2.s-access-title",
                         context=product_entry).get_attribute('data-attribute')
        self.dash_name = '-'.join(self.name.split(' '))
        self.url = self.a_link.get_attribute('href')

    def get_asin(self):
        return urlparse(self.url).path.split('/')[3]

    def get_unquoted_product_part(self):
        return unquote(urlparse(self.url).path.split('/')[1])

    @allure.step
    def check_url(self):
        logging.info(self.dash_name + '\n' + self.get_unquoted_product_part())
        return self.dash_name.startswith(self.get_unquoted_product_part())

    @allure.step
    def check_asin(self):
        asin = self.get_asin()
        logging.info(asin + ' ' + self.url)
        return len(asin) == 10 and set(asin).issubset(
            set("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"))

    @allure.step
    def open_details_page(self):
        self.a_link.click()
        return DetailsPage(self.get_asin())
 def remove_assignment(self, assignment_value):
     self.wait_for_loading()
     remove_assignment_button = Find(by=By.XPATH, value='//li[contains(text(),"{}")]/span'.format(assignment_value),
                                     context=self)
     remove_assignment_button.click()
     self.update.click()
     self._driver.refresh()
 def click_client(self):
     client_xpath = self.table_xpath + '//td[1]'
     client = Find(by=By.XPATH, value=client_xpath, context=self)
     client_name = client.text
     client.click()
     self.wait_for_loading(10)
     return client_name
 def navigate_created_group(self):
     created_group_btn_xpath = self.created_group_btn_xpath.format(self._sections[-1], self._groups[-1])
     created_group_btn = Find(
         by=By.XPATH, value=created_group_btn_xpath, context=self)
     created_group_btn.click()
     self.wait_for_loading()
     self.wait_for_ember()
     return GroupPage()
Example #5
0
 def random_event(self):
     random_number = random.randint(1, 20)
     join_link = Find(
         by=By.XPATH,
         value=
         "//div[@class='afishaList complete']//div[@class='date__content']["
         + str(random_number) + "]//div["
         "@class='date__text inline-top']/a",
         context=self)
     join_link.click()
 def add_group(self, group_data):
     add_group_btn = Find(by=By.XPATH, value=self.add_group_btn_xpath.format(self._sections[-1]), context=self)
     add_group_btn.click()
     group_name_field = self.get_input_by_label('Group Name')
     self.clear_send_keys(group_name_field, group_data.get('group_name'))
     description_field = self.get_input_by_label('Description')
     self.clear_send_keys(description_field, group_data.get('description'))
     self.add_btn.click()
     self._set_group(group_data.get('group_name'))
     self.wait_for_invisibility_of_element(element={'type': 'xpath', 'value': self.group_form_xpath})
Example #7
0
 def add_object(self, object_title):
     self.wait_for_element_to_be_clickable(element={'type': 'xpath', 'value': self.add_object_btn_xpath})
     add_object_btn = Find(by=By.XPATH, value=self.add_object_btn_xpath, context=self)
     add_object_btn.click()
     object_title_field = self.get_input_by_label('Title')
     self.clear_send_keys(object_title_field, object_title)
     self.create_object_btn.click()
     self.wait_for_loading()
     self.wait_for_ember()
     return ObjectPage()
Example #8
0
 def link_is_present(self):
     try:
         ticket_link = Find(by=By.XPATH,
                            value="//div[@class='performance__ticket']/a",
                            context=self)
         ticket_link.click()
     except:
         print(
             "Возможная причина прерывания теста, из-за того, что к данному событию нет билетов, а есть "
             "кнопка 'Оставить "
             "заявку.")
 def filter_data(self, filter_name, filter_value):
     filter_element = getattr(self, filter_name + '_filter')
     if filter_name == 'status':
         self.status_filter.click()
         value = Find(by=By.XPATH, value='//option[text()="{}"]'.format(filter_value), context=self)
         value.click()
         self.status_filter.send_keys(keys.Keys.RETURN)
     else:
         filter_element.clear()
         filter_element.send_keys(filter_value)
         filter_element.send_keys(keys.Keys.RETURN)
     self.wait_for_loading()
Example #10
0
 def open_page_number(
     self, number
 ):  #TODO make smart pagination navigation that doesn't depend on current state
     current_page = Find(by=By.CSS_SELECTOR,
                         value="span.pagnCur",
                         context=self)
     logging.info(' '.join([current_page.text, str(number)]))
     if current_page.text == str(number):
         pass
     else:
         xpath_page_link = '//span[contains(@class, "pagnLink")]/a[contains(text(), "%d")]' % number
         logging.info(xpath_page_link)
         page_link = Find(by=By.XPATH, value=xpath_page_link, context=self)
         page_link.click()
     self.update_product_list()
Example #11
0
    def click_active(self):
        try:
            active_xpath_nesting = my_driver.find_element_by_xpath(
                "//svg:g[@class='active']")
            time.sleep(2)
            ActionChains(my_driver).move_to_element(
                active_xpath_nesting).perform()
            time.sleep(5)
            active_xpath_nesting.click()

            time.sleep(3)
            active_xpath = "//*[name()='svg']//*[name()='path' and @class='active' or name()='circle' and " \
                           "@class='active'] "
            active = Find(by=By.XPATH, value=active_xpath, context=self)
            active.click()
        except:
            try:
                active_xpath = "//*[name()='svg']//*[name()='path' and @class='active' or name()='circle' and " \
                               "@class='active'] "
                active = Find(by=By.XPATH, value=active_xpath, context=self)
                active.click()
            except:
                url = my_driver.current_url
                print("Возможная причина прерывания теста в событии: " +
                      str(url) + "из-за того, что на схеме нет билетов "
                      "или они перекрываются другими "
                      "элементами.")
                try:
                    my_driver.execute_script(
                        "alert('Возможные причины прерывания теста в данном событии: 1. В событии "
                        "нет схемы с билетами, а есть только список. 2. На схеме нет "
                        "билетов. 3. Схема перекрывается другими элементами(например: popup и т.д.) "
                        "4. Событие отменено. Запустите тест еще раз.');"
                    ).accept()
                except WebDriverException:
                    pass
Example #12
0
 def add_filter(self, name, _filter, value):
     self.add_filter_btn.click()
     f = Find(by=By.XPATH, value=self.filter_name_xpath.format(name), context=self)
     f.click()
     inner_btn = Find(by=By.XPATH, value=self.filter_btn_xpath.format(name), context=self)
     inner_btn.click()
     self.filter_options_btn.click()
     filter_option = Find(by=By.XPATH, value=self.filter_option_xpath.format(_filter), context=self)
     filter_option.click()
     self.clear_send_keys(self.filter_value_field, value)
     self.form_update_btn.click()
     self.wait_for_loading()
Example #13
0
    def generate_report(self, name, report_type, report_format, fields):
        self.actions_btn.click()
        self.generate_report_btn.click()
        report_name_field = self.get_input_by_label('Report name')
        self.clear_send_keys(report_name_field, name)
        report_type_select = self.get_a_by_label('Report type')
        report_type_select.click()
        report_type = Find(by=By.XPATH, value=self.search_result_xpath.format(report_type), context=self)
        report_type.click()

        report_format_select = self.get_a_by_label('Report format')
        report_format_select.click()
        report_format = Find(by=By.XPATH, value=self.search_result_xpath.format(report_format), context=self)
        report_format.click()

        report_fields_input = self.get_input_by_label('Report Fields')

        for field in fields:
            report_fields_input.click()
            field = Find(by=By.XPATH, value=self.search_result_xpath.format(field), context=self)
            field.click()

        self.form_update_btn.click()
        self.wait_for_loading()
 def click_transaction_plus(self):
     transaction_plus = Find(by=By.CSS_SELECTOR, value='.subgrid-data span.ui-icon-plus', context=self)
     transaction_plus.click()
     self.wait_for_loading(10)
Example #15
0
 def remove_product(self, item_name):
     delete_btn = Find(by=By.XPATH, value='//tr[contains(., "{}")]//a'.format(item_name), context=self)
     delete_btn.click()
Example #16
0
 def open_name_link(self, name):
     link = Find(by=By.XPATH, value='//a[contains(text(),"{}")]'.format(name), context=self)
     link.click()
 def get_item(self, item_name):
     item_name = item_name.replace(' ', '-').replace('/', '-').lower()
     item = Find(by=By.CSS_SELECTOR, value='section > a[href*="{}"]'.format(item_name), context=self)
     item.click()
     return ServiceItemPage()
 def add_package(self, package_name):
     package = Find(by=By.XPATH, value='//td[contains(., "{}")]/a'.format(package_name), context=self)
     package.click()
     return package.get_attribute('data-id')
 def delete_inventory_group(self, inventorygroup_info):
     delete_link = Find(by=By.XPATH, value="//a[contains(@href,'delete?id={}')]".format(inventorygroup_info['id']),
                        context=self)
     delete_link.click()
Example #20
0
 def update_user(self, user_username, user_info):
     self.filter_data('login', user_username)
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'update?id={}')]".format(user_info['id']), context=self)
     update_link.click()
Example #21
0
 def view_opportunity(self, opportunity_id):
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'update?id={}')]".format(opportunity_id),
                        context=self)
     update_link.click()
Example #22
0
 def close_modal_window(self):
     link = Find(by=By.XPATH, value='//button[@class="close"]', context=self)
     link.click()
Example #23
0
 def open_page(self, text):
     self._driver.execute_script("$('a[target=_blank]').removeAttr('target')")
     link = Find(by=By.XPATH, value='//td/a[@href="/page/0/{}"]'.format(text), context=self)
     link.click()
 def open_product(self, product_title):
     self._driver.execute_script("$('a[target=_blank]').removeAttr('target')")
     product_link = Find(by=By.XPATH, value='//a[text()="{}"]'.format(product_title), context=self)
     product_link.click()
 def view_inventory_group(self, inventory_group_id):
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'update?id={}')]".format(inventory_group_id),
                        context=self)
     update_link.click()
 def view_partner(self, partner_name, partner_info):
     self.filter_data('name', partner_name)
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'update?id={}')]".format(partner_info['id']),
                        context=self)
     update_link.click()
Example #27
0
 def open_additional_page(self, text):
     link = Find(by=By.XPATH, value='//a[contains(text(),"{}")]'.format(text), context=self)
     link.click()
 def add_assignment(self, assignment_value):
     self.assignments_seartch_field.send_keys(assignment_value)
     assignment = Find(value='.select2-results__option--highlighted', context=self)
     assignment.click()
     self.update.click()
     self._driver.refresh()
 def choose_option(self, option):
     option = Find(by=By.XPATH, value='//option[.="{}"]'.format(option), context=self)
     option.click()
 def view_item(self, item_id):
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'items/update?id={}')]".format(item_id),
                        context=self)
     update_link.click()
Example #31
0
 def click_cart(self):
     cart_xpath = "//div[@class='delete_from_cart cart__close inline-top']/*[name()='svg']"
     cart = Find(by=By.XPATH, value=cart_xpath, context=self)
     cart.click()
 def to_previous_page(self):
     time.sleep(4)
     page = Find(by=By.XPATH, value='//div[@id="clientsList"]//div[.=" <"]', context=self)
     page.click()
     time.sleep(2)
Example #33
0
 def open_view_link(self, slug):
     link = Find(by=By.XPATH, value='//a[@href="/group/{}"]'.format(slug), context=self)
     link.click()
 def activate_first_client(self):
     switcher = Find(by=By.CSS_SELECTOR, value='.iSwitcher a', context=self)
     switcher.click()
     term = Find(by=By.XPATH, value='//span[.="Long Term"]', context=self)
     term.click()
     self.wait_for_loading(5)
Example #35
0
 def get_item(self, item_name):
     item = Find(by=By.XPATH, value='//h3[contains(., "{}")]/..//a'.format(item_name), context=self)
     item.click()
     return GuideItemPage()
 def view_product(self, product_title, product_info):
     self.filter_data('title', product_title)
     update_link = Find(by=By.XPATH, value="//a[contains(@href,'update?id={}')]".format(product_info['id']),
                        context=self)
     update_link.click()