示例#1
0
    def test_filters_tags(self):
        """ Tests the filter are correct for tags selected
        """

        d = self.driver
        pg = MainPage(d)

        expected_filters = [{
            'section': 'CATEGORIES',
            'items': ['Clothing\n1', 'Jewelry\n1']
        }, {
            'section': 'SECTION',
            'items': ['On Sale\n1', 'Summer Sale\n1']
        }, {
            'section':
            'TAGS',
            'items': ['Tag01\n3', 'Tag02\n2', 'Tag03 looong name\n1']
        }, {
            'section': 'MATERIALS',
            'items': ['iron\n1', 'plastic\n1']
        }]

        pg.select_filter_tab('Active')
        sleep(1)

        cb = pg.filter_checkbox('TAGS', 'Tag02')
        assert cb is not None
        click(cb)
        sleep(2)

        actual_filters = self.get_filters()
        assert actual_filters == expected_filters

        listings = pg.listing_titles_sorted()
        assert listings == ['Fifth something', 'Forth something 123456']
示例#2
0
    def set_individual_sku(self,
                           row: WebElement,
                           sku: str,
                           num: int = 0,
                           enter=True):
        """ Sets sku on a listing using inline edit

        :param row: Listing row web element
        :param sku: string value to set as a sku
        :param num: index of sku input, starting from 0 (first sku input)
        :param enter: confirm the sku by pressing Enter after sending keys
        """
        try:
            # click on div to reveal input(s)
            div_elements = row.find_elements(*self._product_sku_div)
            click(div_elements[num])
            # wait at least for first input to show up
            self.wait_for_child_element(row, self._product_sku_input)
            # find input and set the price
            inputs = self.product_sku_inputs(row)
            inputs[num].clear()
            if enter:
                sku = sku + Keys.ENTER
            send_keys(inputs[num], sku)
        except IndexError:
            print('Invalid sku input index: ' + str(num))
            raise
    def add_option(self,
                   row: WebElement,
                   i: int,
                   name: str,
                   displayed_name: str = None):
        """ Adds predefined option to a variation property

        :param row: row element (bulk edit or listing)
        :param i: property index: 0 - first property, 1 - second property
        :param name: name of the predefined option to be added
        """
        box = self.property_box(row, i)
        option_combo = box.find_element(*self.OPTION_COMBO_LOCATOR)
        click(element_parent=box, locator=self.OPTION_INPUT_LOCATOR)
        self.wait_until_condition(
            lambda: self.is_option_combobox_open(option_combo) is True)
        list_of_options = box.find_element(By.CSS_SELECTOR,
                                           'div.rw-popup-container')
        possible_items = list_of_options.find_elements(
            By.XPATH, '//ul/li/div[contains(text(), "' + name + '")]')
        try:
            for item in possible_items:
                if item.text == name:
                    option_item = item
                    break
        except:
            option_item = possible_items
        self.scroll_to_element(option_item, False)
        click(option_item)
        if displayed_name is None:
            displayed_name = name
        self.wait_until_condition(
            lambda: displayed_name in self.options_names_texts(row, i))
示例#4
0
    def set_individual_price(self,
                             row: WebElement,
                             price: str,
                             num: int = 0,
                             enter=True):
        """ Sets price on a listing using inline edit

        :param row: Listing row web element
        :param price: string value to set as a price
        :param num: index of price input, starting from 0 (first price input)
        :param enter: confirm the price by pressing Enter after sending keys
        """
        try:
            # click on div to reveal input(s)
            div_elements = row.find_elements(*self._product_price_div)
            self.scroll_to_element(div_elements[num], True)
            click(div_elements[num])
            # wait at least for first input to show up
            self.wait_for_child_element(row, self._product_price_input)
            # find input and set the price
            inputs = self.product_price_inputs(row)
            inputs[num].clear()
            if enter:
                price = price + Keys.ENTER
            send_keys(inputs[num], price)
        except IndexError:
            print('Invalid price input index: ' + str(num))
            raise
示例#5
0
    def set_individual_quantity(self,
                                row: WebElement,
                                quantity: str,
                                num: int = 0,
                                enter=True):
        """ Sets price on a listing using inline edit

        :param row: Listing row web element
        :param quantity: string value to set as a quantity
        :param num: index of quantity input, starting from 0 (first quantity input)
        :param enter: confirm the quantity by pressing Enter after sending keys
        """
        try:
            # click on div to reveal input(s)
            div_elements = row.find_elements(*self._product_quantity_div)
            click(div_elements[num])
            # wait at least for first input to show up
            self.wait_for_child_element(row, self._product_quantity_input)
            # find input and set the quantity
            inputs = self.product_quantity_inputs(row)
            inputs[num].clear()
            if enter:
                quantity = quantity + Keys.ENTER
            send_keys(inputs[num], quantity)
        except IndexError:
            print('Invalid quantity input index: ' + str(num))
            raise
示例#6
0
    def go_to_subpage(self, sub_page: str):
        """ Open Admin sub-page, i.e. Shops or Users

        :param sub_page: name of sub page to open
        """
        sub_page_link = self.driver.find_element_by_xpath(
            '//ul[@id="nav-mobile"]//a[text()="%s"]' % sub_page)
        click(sub_page_link)
示例#7
0
    def go_to_search_shop_details(self, shop_name: str):
        """ Go to details of a shop in search results

        :param shop_name: name of the shop to display its details
        """
        row = self._search_results_shop_row(shop_name)
        link_next = row.find_element(*self.SEARCH_DETAILS_LINK)
        click(link_next)
        self.ts.wait_for_element_visible(self.SHOP_DETAILS_LISTINGS_SUMMARY)
    def select_inventory_tab(self, row: WebElement, label: str):
        """ Go to inventory subpage (Variations, Price, Qty, SKU, Visibility) in bulk edit are or listing row

        :param row: row element (bulk edit or listing)
        :param label: label of the tab
        """
        click(self.inventory_tab(row, label))
        self.wait_until_condition(lambda: 'selected' in self.inventory_tab(
            row, label).get_attribute('class'))
    def add_all_options(self, row: WebElement, i: int):
        """ Adds all variation property predefined options

        :param box: variation property box element
        """
        orig_count = self.options_count(row, i)
        box = self.property_box(row, i)
        click(element_parent=box, locator=self.OPTION_COMBO_LOCATOR)
        option_combo = box.find_element(*self.OPTION_COMBO_LOCATOR)
        self.wait_until_condition(
            lambda: self.is_option_combobox_open(option_combo) is True)
        click(element_parent=box, locator=self.ADD_ALL_OPTIONS_LOCATOR)
        self.wait_until_condition(
            lambda: self.options_count(row, i) > orig_count)
    def delete_property(self, row: WebElement, i: int):
        """ Delete variation property

        :param row: row element (bulk edit or listing)
        :param i: property index: 0 - first property, 1 - second property
        """
        orig_property_texts = self.property_settings_texts(row, i)
        box = self.property_box(row, i)

        element = box.find_element(*self.PROPERTY_DELETE_CROSS)
        click(element)
        # wait until the box is redrawn
        self.wait_until_condition(lambda: self.property_settings_texts(row, i)
                                  != orig_property_texts)
示例#11
0
    def test_login_err(self):
        """ Tests that the user cannot log in with incorrect password
        """
        d = self.driver
        lpg = LoginPage(d)
        lpg.click_login_link()

        user_name = lpg.user_name()
        password = lpg.password()
        submit = lpg.submit_button()

        send_keys(user_name, 'user1')
        send_keys(password, 'foo')
        click(submit)
        sleep(1)
        assert 'Username or password incorrect' in d.page_source
    def set_custom_property(self, row: WebElement, i: int, property_name: str):
        """ Set custom variation property - its name

        :param row: row element (bulk edit or listing)
        :param i: property index: 0 - first property, 1 - second property
        :param property_name: name of the custom variation property
        """
        box = self.property_box(row, i)
        prop = self.wait_for_child_element(box, self.PROPERTY_DROPDOWN_LOCATOR)
        self.open_dropdown(prop)
        self.wait_until_condition(
            lambda: self.property_input(row, i).is_displayed(
            ) and self.property_input(row, i).is_enabled())
        property_input = self.property_input(row, i)
        click(property_input)
        send_keys(property_input, property_name)
        click(element_parent=box, locator=self.PROPERTY_ADD_BUTTON)
示例#13
0
    def test_login_ok(self):
        """ Tests that the user can successfully log in
        """

        d = self.driver
        lpg = LoginPage(d)
        lpg.click_login_link()

        user_name = lpg.user_name()
        password = lpg.password()
        submit = lpg.submit_button()

        send_keys(user_name, 'user1')
        send_keys(password, 'pass1')
        click(submit)
        sleep(2)
        assert os.environ['QA_PRODUCT_HOST'] in d.current_url
        assert d.title == 'Vela'
    def add_custom_option(self, row: WebElement, i: int, name: str):
        """ Adds custom option to a variation property

        :param row: row element (bulk edit or listing)
        :param i: property index: 0 - first property, 1 - second property
        :param name: name of the custom option to be added
        """

        orig_names = self.options_names_texts(row, i)
        box = self.property_box(row, i)
        click(element_parent=box, locator=self.OPTION_INPUT_LOCATOR)
        option_input = self.option_input(row, i)
        send_keys(option_input, name)
        click(element_parent=box, locator=self.OPTION_ADD_BUTTON_LOCATOR)
        # wait until option names are updated
        self.wait_until_condition(
            lambda: orig_names != self.options_names_texts(row, i),
            'Options are still the same')
示例#15
0
    def test_create_account(self, test_whitespaces):
        """ Tests that the user can create an account and log in with it
        """
        d = self.driver
        cap = CreateAccountPage(d)
        self.stop_all()
        self.set_etsy_testcase('listings_09')
        run_sql('AUTH', 'auth_01', retry=2)
        self.restart_all()

        # go to create account page
        d.get(self.login_url_https + "createAccount")
        sleep(1)

        # create account
        send_keys(cap.firstname(), 'Test')
        send_keys(cap.lastname(), 'User')
        email_text = '*****@*****.**'
        if test_whitespaces == Whitespaces.yes:
            # the case when whitespaces are around email in input field
            email_text = '   ' + email_text + ' '
        send_keys(cap.email(), email_text)
        send_keys(cap.password(), 'secret123')
        send_keys(cap.password2(), 'secret123')
        click(cap.submit_button())

        # check DB
        db_data = run_sql('AUTH', 'select_test_user', True)
        assert db_data == [['Test', 'User']]

        # log in using the new account
        d.delete_all_cookies()
        lp = LoginPage(d)
        lp.login(user='******',
                 password='******',
                 page=self.login_url_http)
        mp = MainPage(d)
        assert mp.is_displayed(), 'Login failed, main page is not displayed'
示例#16
0
 def change_individual_sku(self, product_name, sku):
     row = self.product_row_by_name(product_name)
     click(row.find_element(By.CSS_SELECTOR, 'div.checkbox'), delay=2)
     sku_text = row.find_element_by_css_selector(
         'div.body div.property-value-column')
     click(sku_text)
     input_individual = self.product_sku_input(row)
     input_individual.clear()
     send_keys(input_individual, sku)
     sleep(0.3)
     click(
         self.driver.find_element(
             By.CSS_SELECTOR, '.bulk-edit--selected > div:nth-child(1)'))
示例#17
0
    def test_reset_password_ok(self, test_whitespaces):
        """ Tests that the user can reset a password
        """
        new_pass = '******'
        d = self.driver
        lpg = LoginPage(d)

        lpg.click_login_link()
        click(lpg.reset_link())
        sleep(2)

        # enter e-mail address for password reset
        input_field = lpg.reset_password_input()
        submit_btn = lpg.reset_password_button()

        self.clean_email(self.user1)

        email_text = self.user1['email']
        if test_whitespaces == Whitespaces.yes:
            # the case when whitespaces are around email in input field
            email_text = '  ' + email_text + ' '
        send_keys(input_field, email_text)
        click(submit_btn)

        # check for e-mail, extract URL from it
        url = self.reset_password_received(self.user1)
        assert url is not None, 'Reset password link not found in mailbox'

        # Go to the URL from the email
        d.get(url)
        sleep(1)

        # Fill in the new password
        p1 = d.find_element_by_css_selector('form input[name="password"]')
        p2 = d.find_element_by_css_selector('form input[name="password2"]')
        btn = d.find_element_by_xpath(
            "//form//button[contains(text(),'Reset Password')]")
        send_keys(p1, new_pass)
        send_keys(p2, new_pass)
        sleep(1)
        click(btn)
        sleep(2)

        # Login with the new password
        d.get(self.base_url)

        lpg = LoginPage(d)
        lpg.login(page=self.login_url_http)
        mp = MainPage(d)
        assert mp.is_displayed(), 'Login failed, main page is not displayed'