def test_cards(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     product_layouts = self.browser_page.get_wd(
     ).find_elements_by_css_selector('.product-layout')
     self.close()
     assert len(product_layouts) == 4
Пример #2
0
 def test_img(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     count_elements = wd.find_elements_by_class_name('image-additional')
     print(len(count_elements))
     # self.close()
     assert len(count_elements) > 0
Пример #3
0
 def test_price(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     element = wd.find_element_by_css_selector('.list-unstyled h2')
     price = element.get_attribute('innerHTML')
     price = float(price.replace('$', ''))
     self.close()
     assert price > 0
 def test_banner(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     banner = wd.find_element_by_id('banner0')
     banner.click()
     url = wd.current_url
     self.close()
     assert url != 'http://localhost/index.php?route=product/category&path=20'
 def test_forgotten_password(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     link = wd.find_element_by_css_selector('.form-group a')
     link.click()
     elements = WebDriverWait(wd, 0.5).until(
         EC.url_to_be("http://localhost/index.php?route=account/forgotten"))
     self.close()
     assert elements is True
 def test_iphone(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     iphone = wd.find_elements_by_css_selector('.product-layout h4 > a')
     iphone[1].click()
     elements = WebDriverWait(wd, 0.5).until(
         EC.url_to_be("http://localhost/iphone"))
     self.close()
     assert elements is True
 def test_sorted(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     input_sort = Select(wd.find_element_by_id('input-sort'))
     input_sort.select_by_index(2)
     card = wd.find_elements_by_css_selector('.caption h4 > a')
     first_letter = card[0].get_attribute('innerHTML')
     self.close()
     assert first_letter[0] == 'S'
 def test_menu(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     list_group = wd.find_elements_by_css_selector('.list-group-item')
     list_group[5].click()
     card = wd.find_elements_by_css_selector('.caption  h4 > a')
     card1 = card[0].get_attribute('innerHTML')
     self.close()
     assert card1 == 'Samsung Galaxy Tab 10.1'
 def test_new_customer(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     continue_bt = wd.find_element_by_css_selector('.well:first-child a')
     continue_bt.click()
     elements = WebDriverWait(wd, 0.5).until(
         EC.url_to_be("http://localhost/index.php?route=account/register"))
     self.close()
     assert elements is True
 def test_href(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     logo = self.browser_page.get_wd().find_element_by_css_selector(
         '#logo a')
     logo.click()
     url = wd.current_url
     self.close()
     assert url.find('?route=common/home') > -1
Пример #11
0
 def login(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     login = wd.find_element_by_css_selector('#input-username')
     login.send_keys('user')
     passw = wd.find_element_by_css_selector('#input-password')
     passw.send_keys('bitnami')
     button = wd.find_element_by_css_selector('button[type="submit"]')
     button.click()
     return wd
Пример #12
0
 def test_message(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     like = wd.find_elements_by_css_selector('.button-group button')
     like[1].click()
     message = WebDriverWait(wd, 2).until(
         EC.visibility_of_any_elements_located(
             (By.CSS_SELECTOR, ".alert a")))
     name_card = message[2].get_attribute('innerHTML')
     self.close()
     assert name_card == 'Apple Cinema 30"'
Пример #13
0
 def test_count_elements(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     list_view = wd.find_element_by_id('list-view')
     list_view.click()
     count_elements = wd.find_elements_by_class_name('product-layout')
     print(len(count_elements))
     grid_view = wd.find_element_by_id('grid-view')
     grid_view.click()
     count_elements1 = wd.find_elements_by_class_name('product-layout')
     print(len(count_elements1))
     self.close()
     assert count_elements == count_elements1
 def test_authorization(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     login = wd.find_element_by_css_selector('#input-username')
     login.send_keys('user')
     passw = wd.find_element_by_css_selector('#input-password')
     passw.send_keys('bitnami')
     button = wd.find_element_by_css_selector('button[type="submit"]')
     button.click()
     elements = WebDriverWait(wd, 0.5).until(
         EC.url_changes("http://localhost/admin/"))
     self.close()
     assert elements is True
Пример #15
0
 def test_gallery(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     element = wd.find_element_by_css_selector('.thumbnails .thumbnail')
     href = element.get_attribute('href')
     element.click()
     element_gallery = WebDriverWait(wd, 0.5).until(
         EC.visibility_of_element_located((By.CLASS_NAME, "mfp-img")))
     print(element_gallery)
     href_gallery = element_gallery.get_attribute('src')
     print(href_gallery)
     self.close()
     assert href == href_gallery
 def test_returning_customer(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     login_bt = wd.find_element_by_css_selector('input[type="submit"]')
     login_bt.click()
     index = -1
     message = WebDriverWait(wd, 2).until(
         EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
     if message is not None:
         cl_message = message.get_attribute('class')
         index = cl_message.find('alert-danger')
     self.close()
     assert index > -1
 def test_phone(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     topLinks = wd.find_element_by_id('top-links')
     print(topLinks)
     listInline = topLinks.find_elements_by_class_name('list-inline')
     print(listInline)
     li = listInline[0].find_elements_by_tag_name('li')
     print(li)
     span = li[0].find_element_by_tag_name('span')
     phone = span.get_attribute('innerHTML')
     self.close()
     assert phone == '123456789'
 def test_message_close(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     login = wd.find_element_by_css_selector('#input-username')
     login.send_keys('user')
     button = wd.find_element_by_css_selector('button[type="submit"]')
     button.click()
     message = WebDriverWait(wd, 2).until(
         EC.visibility_of_element_located(
             (By.CSS_SELECTOR, ".alert > .close")))
     message.click()
     message1 = wd.find_elements_by_css_selector('.alert')
     self.close()
     assert len(message1) == 0
Пример #19
0
 def test_count(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     element_product = wd.find_element_by_css_selector('#button-cart')
     element_product.click()
     WebDriverWait(wd, 2).until(
         EC.text_to_be_present_in_element((By.ID, 'cart-total'),
                                          '0 item(s) - $0.00'))
     el = wd.find_element_by_css_selector('#cart-total')
     cart = el.get_attribute('innerHTML')
     print(cart)
     index = cart.find('1 item')
     print(index)
     self.close()
     assert index != -1
 def test_search(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     search = self.browser_page.get_wd().find_element_by_css_selector(
         '#search > .form-control')
     search.send_keys('iphone')
     button = self.browser_page.get_wd().find_element_by_css_selector(
         '#search > .input-group-btn')
     button.click()
     elements = WebDriverWait(wd, 0.5).until(
         EC.url_to_be(
             "http://localhost/index.php?route=product/search&search=iphone"
         ))
     self.close()
     assert elements is True
 def test_user_pass(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     passw = wd.find_element_by_css_selector('#input-password')
     passw.send_keys('bitnami')
     button = wd.find_element_by_css_selector('button[type="submit"]')
     button.click()
     index = -1
     message = WebDriverWait(wd, 2).until(
         EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
     if message is not None:
         cl_message = message.get_attribute('class')
         index = cl_message.find('alert-danger')
     self.close()
     assert index > -1
 def test_user_not_found(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     email = wd.find_element_by_css_selector('#input-email')
     email.send_keys('*****@*****.**')
     password = wd.find_element_by_css_selector('#input-password')
     password.send_keys('123')
     login_bt = wd.find_element_by_css_selector('input[type="submit"]')
     login_bt.click()
     time.sleep(0.5)
     message = wd.find_element_by_css_selector('.alert')
     user_none = message.get_attribute('innerHTML')
     index = user_none.find('E-Mail Address and/or Password')
     self.close()
     assert index != -1
 def test_account(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     email = wd.find_element_by_css_selector('#input-email')
     email.send_keys('*****@*****.**')
     password = wd.find_element_by_css_selector('#input-password')
     password.send_keys('1234')
     login_bt = wd.find_element_by_css_selector('input[type="submit"]')
     login_bt.click()
     account = WebDriverWait(wd, 2).until(
         EC.visibility_of_all_elements_located(
             (By.CSS_SELECTOR, "#content > h2")))
     my_account = account[0].get_attribute('innerHTML')
     index = my_account.find('My Account')
     self.close()
     assert index != -1
Пример #24
0
 def test_reviews(self, browser, url):
     self.browser_page = Browser(browser, url)
     wd = self.browser_page.get_wd()
     element = wd.find_element_by_css_selector('a[href="#tab-review"]')
     element.click()
     name = wd.find_element_by_id('input-name')
     name.send_keys('Oleg')
     review = wd.find_element_by_id('input-review')
     review.send_keys(text)
     rating = wd.find_elements_by_css_selector('input[name="rating"]')
     rating[4].click()
     button_review = wd.find_element_by_id('button-review')
     button_review.click()
     index = -1
     message = WebDriverWait(wd, 2).until(
         EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
     if message is not None:
         cl_message = message.get_attribute('class')
         index = cl_message.find('alert-success')
     self.close()
     assert index > -1
 def test_title(self, browser, url):
     self.browser_page = Browser(browser, url)
     title = self.browser_page.get_wd().title
     self.close()
     assert title == 'Your Store'
Пример #26
0
class TestAdmin:
    """
    авторизация
    """
    def login(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login = wd.find_element_by_css_selector('#input-username')
        login.send_keys('user')
        passw = wd.find_element_by_css_selector('#input-password')
        passw.send_keys('bitnami')
        button = wd.find_element_by_css_selector('button[type="submit"]')
        button.click()
        return wd

    '''
    Проверка, что заголовок = 'Orders'
    '''

    def test_total_orders(self, browser, url):
        wd = self.login(browser, url)
        tile_footer = wd.find_elements_by_css_selector('.tile-footer')
        view_more = tile_footer[0].find_element_by_tag_name('a')
        view_more.click()
        orders = wd.find_element_by_css_selector('h1')
        h1 = orders.get_attribute('innerHTML')
        result = h1.find('Orders')
        self.close()
        assert result != -1

    '''
    Проверка, перехода Systems -> Settings
    '''

    def test_settings(self, browser, url):
        wd = self.login(browser, url)
        menu_system = wd.find_element_by_css_selector('#menu-system a')
        menu_system.click()
        settings = wd.find_element_by_css_selector(
            '#collapse7 > li:first-child a')
        settings.click()
        index = -1
        table = wd.find_element_by_css_selector('.table')
        if table is not None:
            cl_table = table.get_attribute('class')
            index = cl_table.find('table table-bordered table-hover')
        self.close()
        assert index > -1

    '''
    Проверка перехода к разделу с товарами, что появляется таблица с товарами
    '''

    def test_table(self, browser, url):
        wd = self.login(browser, url)
        menu_catalog = wd.find_element_by_css_selector('#menu-catalog a')
        menu_catalog.click()
        product = wd.find_element_by_css_selector(
            '#collapse1 > li:nth-child(2) a')
        product.click()
        index = -1
        table = wd.find_element_by_css_selector('.table')
        if table is not None:
            cl_table = table.get_attribute('class')
            index = cl_table.find('table-bordered table-hover')
        self.close()
        assert index > -1

    '''
    Проверка логина
    '''

    def test_login(self, browser, url):
        wd = self.login(browser, url)
        logout = wd.find_element_by_css_selector(
            '.navbar-right > li:last-child span')
        user_login = logout.get_attribute('innerHTML')
        index = user_login.find('Logout')
        self.close()
        assert index != -1

    '''
    Проверка разлогина
    '''

    def test_logout(self, browser, url):
        wd = self.login(browser, url)
        logout = wd.find_element_by_css_selector(
            '.navbar-right > li:last-child span')
        logout.click()
        url = wd.current_url
        self.close()
        assert url.find('?route=common/login') > -1

    '''
    Закрытие страницы
    '''

    def close(self):
        self.browser_page.closeBrowser()
class TestAccountLogin:
    '''
    New Customer при клике на Continue меняется ссылка
    '''
    def test_new_customer(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        continue_bt = wd.find_element_by_css_selector('.well:first-child a')
        continue_bt.click()
        elements = WebDriverWait(wd, 0.5).until(
            EC.url_to_be("http://localhost/index.php?route=account/register"))
        self.close()
        assert elements is True

    '''
    При отправке пустой формы в Returning Customer, появляется сообщение об ошибке
    '''

    def test_returning_customer(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login_bt = wd.find_element_by_css_selector('input[type="submit"]')
        login_bt.click()
        index = -1
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
        if message is not None:
            cl_message = message.get_attribute('class')
            index = cl_message.find('alert-danger')
        self.close()
        assert index > -1

    '''
    Проверка, что при нажатии Forgotten Password меняется url
    '''

    def test_forgotten_password(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        link = wd.find_element_by_css_selector('.form-group a')
        link.click()
        elements = WebDriverWait(wd, 0.5).until(
            EC.url_to_be("http://localhost/index.php?route=account/forgotten"))
        self.close()
        assert elements is True

    '''
    Проверка, что при вводе не существующего email и пароля, появляется сообщение, что пользователь не найден
    '''

    def test_user_not_found(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        email = wd.find_element_by_css_selector('#input-email')
        email.send_keys('*****@*****.**')
        password = wd.find_element_by_css_selector('#input-password')
        password.send_keys('123')
        login_bt = wd.find_element_by_css_selector('input[type="submit"]')
        login_bt.click()
        time.sleep(0.5)
        message = wd.find_element_by_css_selector('.alert')
        user_none = message.get_attribute('innerHTML')
        index = user_none.find('E-Mail Address and/or Password')
        self.close()
        assert index != -1

    '''
    Проверка, что при вводе существующего email и пароля, пользователь авторизован
    '''

    def test_account(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        email = wd.find_element_by_css_selector('#input-email')
        email.send_keys('*****@*****.**')
        password = wd.find_element_by_css_selector('#input-password')
        password.send_keys('1234')
        login_bt = wd.find_element_by_css_selector('input[type="submit"]')
        login_bt.click()
        account = WebDriverWait(wd, 2).until(
            EC.visibility_of_all_elements_located(
                (By.CSS_SELECTOR, "#content > h2")))
        my_account = account[0].get_attribute('innerHTML')
        index = my_account.find('My Account')
        self.close()
        assert index != -1

    '''
    Закрытие страницы
    '''

    def close(self):
        self.browser_page.closeBrowser()
Пример #28
0
def wd(browser, url):
    browser_page = Browser(browser, url)
    wd = browser_page.get_wd()
    yield wd
    browser_page.closeBrowser()
class TestAccountLoginAdm:
    """
    Проверка, что при отправке пустой формы, появляется предупреждающее собщение
    """
    def test_login_null(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login = wd.find_element_by_css_selector('button[type="submit"]')
        login.click()
        index = -1
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
        if message is not None:
            cl_message = message.get_attribute('class')
            index = cl_message.find('alert-danger')
        self.close()
        assert index > -1

    """
    Проверка, что при вводе в форме только логина, появляется предупреждающее собщение
    """

    def test_user_login(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login = wd.find_element_by_css_selector('#input-username')
        login.send_keys('user')
        button = wd.find_element_by_css_selector('button[type="submit"]')
        button.click()
        index = -1
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
        if message is not None:
            cl_message = message.get_attribute('class')
            index = cl_message.find('alert-danger')
        self.close()
        assert index > -1

    """
    Проверка, что при вводе в форме только пароля, появляется предупреждающее собщение
    """

    def test_user_pass(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        passw = wd.find_element_by_css_selector('#input-password')
        passw.send_keys('bitnami')
        button = wd.find_element_by_css_selector('button[type="submit"]')
        button.click()
        index = -1
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_element_located((By.CLASS_NAME, "alert")))
        if message is not None:
            cl_message = message.get_attribute('class')
            index = cl_message.find('alert-danger')
        self.close()
        assert index > -1

    """
    Проверка, что при ошибке в логине, нажав на крестик сообщения, оно закрывается
    """

    def test_message_close(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login = wd.find_element_by_css_selector('#input-username')
        login.send_keys('user')
        button = wd.find_element_by_css_selector('button[type="submit"]')
        button.click()
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, ".alert > .close")))
        message.click()
        message1 = wd.find_elements_by_css_selector('.alert')
        self.close()
        assert len(message1) == 0

    """
    Проверка, что пользователь авторизован
    """

    def test_authorization(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        login = wd.find_element_by_css_selector('#input-username')
        login.send_keys('user')
        passw = wd.find_element_by_css_selector('#input-password')
        passw.send_keys('bitnami')
        button = wd.find_element_by_css_selector('button[type="submit"]')
        button.click()
        elements = WebDriverWait(wd, 0.5).until(
            EC.url_changes("http://localhost/admin/"))
        self.close()
        assert elements is True

    '''
    Закрытие страницы
    '''

    def close(self):
        self.browser_page.closeBrowser()
Пример #30
0
class TestCatalog:
    '''
    Проверка, что при отображении карточек на странице списком или в гриде, колличество элементов на странице равно
    '''
    def test_count_elements(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        list_view = wd.find_element_by_id('list-view')
        list_view.click()
        count_elements = wd.find_elements_by_class_name('product-layout')
        print(len(count_elements))
        grid_view = wd.find_element_by_id('grid-view')
        grid_view.click()
        count_elements1 = wd.find_elements_by_class_name('product-layout')
        print(len(count_elements1))
        self.close()
        assert count_elements == count_elements1

    '''
    Проверка, что при отображении карточек на странице списком или в гриде, колличество элементов на странице равно
    '''

    def test_sorted(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        input_sort = Select(wd.find_element_by_id('input-sort'))
        input_sort.select_by_index(2)
        card = wd.find_elements_by_css_selector('.caption h4 > a')
        first_letter = card[0].get_attribute('innerHTML')
        self.close()
        assert first_letter[0] == 'S'

    '''
    Проверка, что при нажатии на баннер открывается другая страница
    '''

    def test_banner(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        banner = wd.find_element_by_id('banner0')
        banner.click()
        url = wd.current_url
        self.close()
        assert url != 'http://localhost/index.php?route=product/category&path=20'

    '''
    Проверка, что при нажатии в боковом меню Tablets открывается страница Tablets и на ней есть товар
    '''

    def test_menu(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        list_group = wd.find_elements_by_css_selector('.list-group-item')
        list_group[5].click()
        card = wd.find_elements_by_css_selector('.caption  h4 > a')
        card1 = card[0].get_attribute('innerHTML')
        self.close()
        assert card1 == 'Samsung Galaxy Tab 10.1'

    '''
    Проверка, что при выборе товара в избранное, в сплывающем сообщении присутствует название товара
    '''

    def test_message(self, browser, url):
        self.browser_page = Browser(browser, url)
        wd = self.browser_page.get_wd()
        like = wd.find_elements_by_css_selector('.button-group button')
        like[1].click()
        message = WebDriverWait(wd, 2).until(
            EC.visibility_of_any_elements_located(
                (By.CSS_SELECTOR, ".alert a")))
        name_card = message[2].get_attribute('innerHTML')
        self.close()
        assert name_card == 'Apple Cinema 30"'

    '''
    Закрытие страницы
    '''

    def close(self):
        self.browser_page.closeBrowser()