Beispiel #1
0
    def setUp(self):
        self.login = os.environ.get('ADMIN_LOGIN')
        self.password = os.environ.get('ADMIN_PASSWORD')

        browser = os.environ.get('BROWSER', 'CHROME')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        address_page = AddressPage(self.driver)
        address_page.open()
        address_page.start_address('Россия, Москва, Знаменская улица, 53')

        auth_page = AuthPage(self.driver)
        auth_page.open()
        auth_page.wait_open()
        auth_page.auth(self.login, self.password)

        profile_page = ProfilePage(self.driver)
        profile_page.wait_open()

        self.main_page = MainPage(self.driver)
        self.main_page.open()

        self.main_form = self.main_page.main_form
def test_upload_button(app_browser_main):
    start_page = MainPage(app_browser_main)
    start_page.load_page()

    # start_page.test_button()

    app_browser_main.find_element_by_xpath('/html/body/div/div/form/div/div[1]/button').click()

    sleep(5)
def test_title(app_browser_main):
    start_page = MainPage(app_browser_main)

    start_page.load_page()

    title_data = 'Picture locator'
    assert app_browser_main.title == title_data
    assert app_browser_main.current_url == "http://127.0.0.1:5000/"
    sleep(5)

    app_browser_main.find_element_by_xpath('/html/body/div/div/form/div/div[2]/input').click()
    sleep(5)
Beispiel #4
0
    def setUp(self):
        browser = os.environ.get('BROWSER', 'FIREFOX')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        auth_page = AuthPage(self.driver)
        auth_page.open()
        auth_form = auth_page.form
        auth_form.set_login(self.USEREMAIL)
        auth_form.set_password(self.PASSWORD)
        auth_form.submit()

        self.main_page = MainPage(self.driver)
        self.main_page.waitForVisible()
class TestEmptyFields():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_empty_fields_validation(self):
        # Click to the email input box, without enter any value
        self.driver.find_element_by_xpath(locators.EMAIL_INPUT_BOX).click()
        # Click to the password input box, without enter any value
        self.driver.find_element_by_xpath(locators.PASSW_INPUT_BOX).click()
        # Click to the login form area to see the error
        self.driver.find_element_by_xpath(locators.LOGIN_FORM_AREA).click()
        # Verify that the validation appears at the email input box
        assert self.driver.find_element_by_xpath(
            locators.VALIDATION_ERROR_EMAIL).is_displayed(
            ), 'The validation doesn\'t appear for email input box'
        # Verify that the validation appears at the password input box
        assert self.driver.find_element_by_xpath(
            locators.VALIDATION_ERROR_PASSW).is_displayed(
            ), 'The validation doesn\'t appear for password input box'

    def test_teardown(self):
        self.driver.quit()
Beispiel #6
0
def test_guest_cant_see_product_in_basket_opened_from_main_page(browser):
    page = MainPage(browser, link)
    page.open()
    page.openBasket()
    basket_page = BasketPage(browser, browser.current_url)
    basket_page.should_be_not_items_in_basket()
    basket_page.should_be_message_about_0_items_in_basket()
Beispiel #7
0
    def setUp(self):
        browser = os.environ.get('BROWSER', 'CHROME')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        #Open site page before using local storage
        AddressPage(self.driver).open()
        storage = LocalStorage(self.driver)

        storage.set('deliveryGeo', self.ADDRESS)
        storage.set('longitude', self.LONGITUDE)
        storage.set('latitude', self.LATITUDE)

        self.driver.refresh()
        self.driver.maximize_window()

        main_page = MainPage(self.driver)
        main_page.wait_visible()

        main_page.auth(self.LOGIN, self.PASSWORD)

        self.add_rest = AddRestaurantPage(self.driver)
        self.add_rest.open()
Beispiel #8
0
    def testDeleteTagFromRestaurant(self):
        self.filler.add_tag_to_restaurant(self.TAG_NAME,
                                          self.filler.TEST_REST_NAME.format(0))

        self.driver.refresh()

        self.form.wait_visible()
        self.form.unset_tag(self.tag_id)
        self.form.submit()

        WebDriverWait(self.driver, 5,
                      0.1).until(lambda d: self.form.message() != '')

        self.assertEqual(self.form.message(), 'Теги успешно изменены')

        main_page = MainPage(self.driver)
        main_page.open()

        main_form = main_page.main_form
        main_form.wait_open()
        main_form.set_tag(self.tag_id)

        WebDriverWait(self.driver, 5,
                      0.1).until(lambda d: d.current_url == self.MAIN_URL)

        self.driver.refresh()

        main_page.wait_visible()
        self.assertEqual(
            self.driver.find_element_by_xpath(self.REST_LIST).text,
            'К сожалению, мы пока не доставляем в ваш район 🙁')
Beispiel #9
0
    def testAddTagToRestaurant(self):
        self.form.set_tag(self.tag_id)
        self.form.submit()

        self.form.wait_visible()
        WebDriverWait(self.driver, 5,
                      0.1).until(lambda d: self.form.message() != '')

        self.assertEqual(self.form.message(), 'Теги успешно изменены')

        main_page = MainPage(self.driver)
        main_page.open()

        main_form = main_page.main_form
        main_form.wait_open()
        main_form.set_tag(self.tag_id)

        WebDriverWait(self.driver, 5,
                      0.3).until(lambda d: d.current_url == self.MAIN_URL)

        main_page.wait_visible()
        WebDriverWait(
            self.driver, 5, 0.3).until(lambda d: d.find_element_by_xpath(
                self.REST_LIST).find_element_by_xpath(
                    self.REST_ELEMENT.format(self.rest_id)).is_displayed())
        rest_el = self.driver.find_element_by_xpath(
            self.REST_LIST).find_element_by_xpath(
                self.REST_ELEMENT.format(self.rest_id))
        self.assertEqual(
            rest_el.find_element_by_xpath(self.REST_NAME).text,
            self.filler.TEST_REST_NAME.format(0))
Beispiel #10
0
    def setUp(self):
        browser = os.environ.get('BROWSER', 'CHROME')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        AddressPage(self.driver).open()
        storage = LocalStorage(self.driver)

        storage.set('deliveryGeo', self.ADDRESS)
        storage.set('longitude', self.LONGITUDE)
        storage.set('latitude', self.LATITUDE)

        self.driver.refresh()
        self.driver.maximize_window()

        main_page = MainPage(self.driver)
        main_page.wait_visible()

        main_page.auth(self.LOGIN, self.PASSWORD)

        self.filler = DatabaseFiller()
        self.filler.admin_auth()
        self.filler.create_test_restaurants(1)

        self.rest_id = self.filler.get_restaurant_id_by_name(
            self.filler.TEST_REST_NAME.format(0))
        self.rest_list_page = AdminRestaurantsPage(self.driver)

        self.rest_list_page.open()
        self.rest_list_page.wait_visible()
class TestSignUpForm():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()
        self.main_page.open_registration_form(email_reg_value)

    def test_registration_new_account(self):
        # Enter values at the form
        self.driver.find_element_by_xpath(
            locators.EMAIL_ADDRESS).send_keys(email_reg_value)
        self.driver.find_element_by_xpath(
            locators.PASSWORD).send_keys(password_value)
        self.driver.find_element_by_xpath(
            locators.CONFIRM_PASSWORD).send_keys(password_value)
        self.driver.find_element_by_xpath(locators.CHECKBOX_CIVIL_MISS).click()
        self.driver.find_element_by_xpath(
            locators.LAST_NAME).send_keys('Sandy')
        self.driver.find_element_by_xpath(
            locators.FIRST_NAME).send_keys('Katrin')
        self.driver.find_element_by_xpath(locators.BIRTH_DAY).send_keys('11')
        self.driver.find_element_by_xpath(locators.BIRTH_MONTH).send_keys('10')
        self.driver.find_element_by_xpath(
            locators.BIRTH_YEAR).send_keys('1985')
        self.driver.find_element_by_xpath(
            locators.STREET).send_keys('1234 Avenue de Rode')
        self.driver.find_element_by_xpath(
            locators.APPT).send_keys('Appartment 123')
        self.driver.find_element_by_xpath(
            locators.RESIDENCE).send_keys('Batiment li')
        # Zip Code Miami - 33111
        self.driver.find_element_by_xpath(locators.ZIP_CODE).send_keys('33111')

        # Verify that after the ZIP Code entered - the City value auto filled
        city_value = self.driver.find_element_by_xpath(locators.CITY)
        assert city_value == "Miami", "The city not correct"

        self.driver.find_element_by_xpath(locators.STATE).send_keys('Florida')
        self.driver.find_element_by_xpath(
            locators.MOBILE_PHONE).send_keys(email_reg_value)
        self.driver.find_element_by_xpath(
            locators.HOME_PHONE).send_keys(email_reg_value)
        self.driver.find_element_by_xpath(locators.CHECKBOX_NEWSLETTER).click()
        self.driver.find_element_by_xpath(locators.CONTINUE_BUTTON).click()
        # assert that registration performed successfully

    def test_teardown(self):
        self.driver.quit()
class TestForgotPassword():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_(self):
        self.driver.find_element_by_xpath(locators.LINK_FORGOT_PASSW).click()
        # Verify that needed page is opened
        assert self.driver.find_element_by_xpath(locators.FORGOT_PASSWORD_PAGE_VALIDATION), \
            "The Password recovery page isn't opened"

    def test_teardown(self):
        self.driver.quit()
Beispiel #13
0
class TestLoginPositive():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_login(self):
        # Enter the email value into the 'Email address' input box.
        self.driver.find_element_by_xpath(locators.EMAIL_INPUT_BOX).send_keys(email_value)
        # Enter the password value into the 'Password' input box.
        self.driver.find_element_by_xpath(locators.PASSW_INPUT_BOX).send_keys(passw_value)
        self.driver.find_element_by_xpath(locators.SIGN_IN_BUTTON).click()
        # assert if login performed successfully

    def test_teardown(self):
        self.driver.quit()
class TestLogin():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_login(self):
        # Enter the email value not correct - without @ to the 'Email address' input box.
        self.driver.find_element_by_xpath(locators.EMAIL_INPUT_BOX).send_keys(email_value)
        # Enter the password value into the 'Password' input box.
        self.driver.find_element_by_xpath(locators.PASSW_INPUT_BOX).send_keys(passw_value)

        assert self.driver.find_element_by_xpath(
            locators.VALIDATION_ERROR_EMAIL).is_displayed(), \
            "The validation error doesn't appear"

    def test_teardown(self):
        self.driver.quit()
Beispiel #15
0
class TestSignUp():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_email_field_validation(self):
        #  Enter the Not valid email value into the 'Email address' input box at the Registration area.
        self.driver.find_element_by_xpath(
            locators.EMAIL_FOR_REG_INPUT_BOX).send_keys('not_valid_email')
        # Click "Create an account" button to open the Sig Up form
        self.driver.find_element_by_xpath(
            locators.CREATE_ACCOUNT_BUTTON).click()
        # Verify that validation error appears
        assert self.driver.find_element_by_xpath(locators.VALIDATION_ERROR_EMAIL_CREATE).is_displayed(), \
            "The validation error doesn't appear"

    def test_teardown(self):
        self.driver.quit()
Beispiel #16
0
class TestTooltip():
    driver = WebDriverFactory.get_driver('chrome')
    main_page = MainPage(driver)

    def test_setup(self):
        self.main_page.open_main_page()
        self.main_page.open_login_page()

    def test_username_tooltip(self):
        # Enter the email value not correct to the 'Email address' input box.
        self.driver.find_element_by_xpath(
            locators.EMAIL_INPUT_BOX).send_keys(email)
        # Click to the login form area to see the error
        self.driver.find_element_by_xpath(locators.LOGIN_FORM_AREA).click()

        # Verify that the email input box contain the attribute type - email;
        # browser according current type will show tooltip.
        email_field = self.driver.find_element_by_xpath(
            locators.EMAIL_INPUT_BOX)
        type_value = email_field.get_attribute("type")
        assert type_value == 'email', "The type doesn't contain value - email"

    def test_teardown(self):
        self.driver.quit()
def test_guest_can_go_to_login_page(browser):
    link = "http://selenium1py.pythonanywhere.com/"
    page = MainPage(browser, link)
    page.open()
    page.go_to_login_page()
Beispiel #18
0
class TestSearchLetters(unittest.TestCase):
    USEREMAIL = '*****@*****.**'
    PASSWORD = os.environ['PASSWORD']

    def setUp(self):
        browser = os.environ.get('BROWSER', 'FIREFOX')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        auth_page = AuthPage(self.driver)
        auth_page.open()
        auth_form = auth_page.form
        auth_form.set_login(self.USEREMAIL)
        auth_form.set_password(self.PASSWORD)
        auth_form.submit()

        self.main_page = MainPage(self.driver)
        self.main_page.waitForVisible()

    def tearDown(self):
        self.driver.quit()

    """
        № Теста:                1
        Ключ поиска:            40bd001563085fc35165329ea1ff5c5ecbdbbeef
        Фильтры поиска:         нет
        Целевая папка:          все
        Ожидаемый результат:    2
    """

    def test_find_by_date_simple(self):
        search_key = '40bd001563085fc35165329ea1ff5c5ecbdbbeef'
        letters_in_target_expected = 2

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.make_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                2
        Ключ поиска:            40bd001563085fc35165329ea1ff5c5ecbdbbeef
        Фильтры поиска:         -
        Целевая папка:          Непрочитанные
        Ожидаемый результат:    1 письмо
    """

    def test_find_unread_by_key(self):
        letters_in_target_expected = 1
        search_key = '40bd001563085fc35165329ea1ff5c5ecbdbbeef'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.make_search(search_key)
        searchbar.search_with_icon(searchbar.ICON_UNREAD)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                3
        Ключ поиска:            40bd001563085fc35165329ea1ff5c5ecbdbbeef
        Фильтры поиска:         С флажком
        Целевая папка:          -
        Ожидаемый результат:    1 письмо
    """

    def test_find_flagged_by_key(self):
        letters_in_target_expected = 1
        search_key = '40bd001563085fc35165329ea1ff5c5ecbdbbeef'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.make_search(search_key)
        searchbar.search_with_icon(searchbar.ICON_FLAGGED)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                4
        Ключ поиска:            123
        Фильтры поиска:         C вложениями
        Целевая папка:          все
        Ожидаемый результат:    2 письма
    """

    def test_find_attached(self):
        letters_in_target_expected = 2
        search_key = '123'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.make_search(search_key)
        searchbar.search_with_icon(searchbar.ICON_ATTACH)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                5
        Ключ поиска:            mvideo
        Фильтры поиска:         Заказы
        Целевая папка:          все
        Ожидаемый результат:    2 письма
    """

    def test_find_orders(self):
        letters_in_target_expected = 2
        search_key = 'mvideo'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_ORDERS)
        searchbar.make_active_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                6
        Ключ поиска:            fin
        Фильтры поиска:         финансы
        Целевая папка:          все
        Ожидаемый результат:    0 писем
    """

    def test_find_finance(self):
        letters_in_target_expected = 0
        search_key = 'fin'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_FINANCE)
        searchbar.make_active_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                7
        Ключ поиска:            kllk
        Фильтры поиска:         регистрации
        Целевая папка:          все
        Ожидаемый результат:    1 письмо
    """

    def test_find_regs(self):
        letters_in_target_expected = 1
        search_key = 'kllk'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_REGISTRATION)
        searchbar.make_active_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                8
        Ключ поиска:            travel
        Фильтры поиска:         Путешествия
        Целевая папка:          все
        Ожидаемый результат:    0 писем
    """

    def test_find_travels(self):
        letters_in_target_expected = 0
        search_key = 'travel'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_TRAVEL)
        searchbar.make_active_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                9
        Ключ поиска:            fis
        Фильтры поиска:         Штрафы
        Целевая папка:          все
        Ожидаемый результат:    0 писем
    """

    def test_find_fees(self):
        letters_in_target_expected = 0
        search_key = 'fis'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_FEES)
        searchbar.make_active_search(search_key)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                10
        Ключ поиска 1:          fwd
        Ключ поиска 2:          verify
        Фильтры поиска:         -
        Целевая папка:          все
        Ожидаемый результат:    1 письмо
    """

    def test_find_by_two_keys(self):
        letters_in_target_expected = 1
        search_key_1 = 'fwd'
        search_key_2 = 'verify'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.make_search(search_key_1)
        searchbar.make_active_search(search_key_2)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                11
        Ключ поиска:            tech
        Фильтры поиска:         Непрочитанные, с вложениями
        Целевая папка:          все
        Ожидаемый результат:    3 письма
    """

    def test_find_by_two_icons(self):
        letters_in_target_expected = 3
        search_key = 'tech'

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.make_search(search_key)
        searchbar.search_with_icon(searchbar.ICON_UNREAD)
        searchbar.search_with_icon(searchbar.ICON_ATTACH)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                12
        Ключ поиска:            -
        Фильтры поиска:         Непрочитанные, с вложениями, с флажком
        Целевая папка:          все
        Ожидаемый результат:    2 письма
    """

    def test_find_by_three_icons(self):
        letters_in_target_expected = 2

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()

        searchbar.search_with_icon_first_time()
        searchbar.search_with_icon(searchbar.ICON_UNREAD)
        searchbar.search_with_icon(searchbar.ICON_FLAGGED)
        searchbar.search_with_icon(searchbar.ICON_ATTACH)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))
Beispiel #19
0
class TestSearchingLetters(unittest.TestCase):
    USEREMAIL = '*****@*****.**'
    PASSWORD = os.environ['PASSWORD']

    # Кликнуть по поиску, кликнуть по дате, кликнуть по 10 числу
    # Кликнуть по поиску, кликнуть по дате, кликнуть по +-3 дня, кликнуть по фильтру, выбрать 10 число
    # кликнуть по дате, выбрать 2019, выбрать 10 число
    # кликнуть по дате, выбрать 2017, выбрать 10 число
    # кликнуть по дате, кликнуть по фильтру, кликнуть по +-1день, кликнуть по +-1 день, проверить фильтр
    # кликнуть по дате, кликнуть по фильтру, кликнуть по строке поиска, клинуть по "папки"
    # кликнуть по дате, кликнуть по фильтру, кликнуть по строке поиска, клинуть по "вложения"
    # кликнуть по дате, кликнуть по фильтру, кликнуть по строке поиска, клинуть по "закладки"
    # кликнуть по дате, кликнуть по фильтру, кликнуть по строке поиска, клинуть по "папки", кликнуть по "входящие".
    # зафиксировать результат, закрыть оба фильтра и кликнуть в обратном порядке, сравнть результат
    def setUp(self):
        browser = os.environ.get('BROWSER', 'FIREFOX')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        auth_page = AuthPage(self.driver)
        auth_page.open()
        auth_form = auth_page.form
        auth_form.set_login(self.USEREMAIL)
        auth_form.set_password(self.PASSWORD)
        auth_form.submit()

        self.main_page = MainPage(self.driver)
        self.main_page.waitForVisible()

    def tearDown(self):
        self.driver.quit()

    """
        № Теста:                1
        КЭ:                     Допустимый
        Ключ поиска:            Дата
        Фильтры поиска:         Date(2018.12.09)
        Целевая папка:          все
        Ожидаемый результат:    8 писем
    """

    def test_find_by_date_simple(self):
        letters_in_target_expected = 8

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_09')

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                2
        КЭ:                     Допустимый
        Ключ поиска:            Дата +-7 дней
        Фильтры поиска:         Date(2018.12.07)
        Целевая папка:          все
        Ожидаемый результат:    16 писем
    """

    def test_find_by_date_with_interval(self):
        letters_in_target_expected = 16

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date_pm('2018_12_07', '7')

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                3
        КЭ:                     Отрицательный
        Ключ поиска:            нет
        Фильтры поиска:         Date(2018.12.31)
        Целевая папка:          все
        Ожидаемый результат:    0 писем
    """

    def test_find_by_date_from_future(self):
        letters_in_target_expected = 0

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_31')

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                4
        КЭ:                     Допустимый
        Ключ поиска:            нет
        Фильтры поиска:         Date(2018.12.15)
        Целевая папка:          отправленные
        Ожидаемый результат:    6 писем
    """

    def test_find_by_date_and_folder(self):
        letters_in_target_expected = 6

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_15')
        searchbar.search_in_folder('Отправленные')

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                5
        КЭ:                     Допустимый
        Ключ поиска:            нет
        Фильтры поиска:         Date(2018.12.14), с вложениями
        Целевая папка:          нет
        Ожидаемый результат:    2 писем
    """

    def test_find_by_date_and_with_attach(self):
        letters_in_target_expected = 2

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_14')
        searchbar.search_with_icon(searchbar.ICON_ATTACH)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
        № Теста:                6
        КЭ:                     Допустимый
        Ключ поиска:            нет
        Фильтры поиска:         Date(2018.12.14), закладки
        Целевая папка:          нет
        Ожидаемый результат:    1 писем
    """

    def test_find_by_date_and_with_attach(self):
        letters_in_target_expected = 1

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_14')
        searchbar.search_with_icon(searchbar.ICON_FLAGGED)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))

    """
            № Теста:                7
            КЭ:                     Допустимый
            Ключ поиска:            нет
            Фильтры поиска:         Date(2018.12.17), непрочитанные / непрочитанные, Date(2018.12.17)
            Целевая папка:          нет
            Ожидаемый результат:    6 писем
        """

    def test_transitive_of_filters(self):

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_17')
        searchbar.search_with_icon(searchbar.ICON_UNREAD)
        letters_in_target_actual_1 = searchbar.has_letters()
        self.driver.get(self.driver.current_url)
        searchbar.waitForVisibleAfterReload()
        searchbar.change_pm('1')
        letters_in_target_actual_2 = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_actual_1, letters_in_target_actual_2,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_actual_1, letters_in_target_actual_2))

    """
        № Теста:                8
        КЭ:                     Допустимый
        Ключ поиска:            нет
        Фильтры поиска:         Date(2018.12.17), закладки, непрочитанные, с вложениями
        Целевая папка:          нет
        Ожидаемый результат:    1 писем
    """

    def test_find_by_many_filters(self):
        letters_in_target_expected = 1

        searchbar = self.main_page.searchbar
        searchbar.waitForVisible()
        searchbar.search_by_date('2018_12_17')
        searchbar.search_with_icon(searchbar.ICON_UNREAD)
        searchbar.search_with_icon(searchbar.ICON_FLAGGED)
        searchbar.search_with_icon(searchbar.ICON_ATTACH)

        letters_in_target_actual = searchbar.has_letters()

        self.assertEqual(
            letters_in_target_expected, letters_in_target_actual,
            'Letters: expected: {}, actual: {}'.format(
                letters_in_target_expected, letters_in_target_actual))
Beispiel #20
0
def test_guest_should_see_login_link(browser):
    page = MainPage(browser, link)
    page.open()
    page.should_be_login_link()
Beispiel #21
0
def test_guest_can_go_to_login_page(browser):
    page = MainPage(browser, link)
    page.open()
    page.go_to_login_page()
    login_page = LoginPage(browser, browser.current_url)
    login_page.should_be_login_page()
Beispiel #22
0
class MainPageTest(unittest.TestCase):
    DEFAULT_PHOTO = 'data/test_prod_photo.jpg'
    PROFILE_PHOTO = 'data/test_rest_photo.jpg'
    BIG_PROFILE_PHOTO = 'data/test_big_photo.jpg'
    WRONG_PROFILE_PHOTO = 'data/test_non_photo_file'

    def setUp(self):
        self.login = os.environ.get('ADMIN_LOGIN')
        self.password = os.environ.get('ADMIN_PASSWORD')

        browser = os.environ.get('BROWSER', 'CHROME')

        self.driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                             desired_capabilities=getattr(
                                 DesiredCapabilities, browser).copy())

        address_page = AddressPage(self.driver)
        address_page.open()
        address_page.start_address('Россия, Москва, Знаменская улица, 53')

        auth_page = AuthPage(self.driver)
        auth_page.open()
        auth_page.wait_open()
        auth_page.auth(self.login, self.password)

        profile_page = ProfilePage(self.driver)
        profile_page.wait_open()

        self.main_page = MainPage(self.driver)
        self.main_page.open()

        self.main_form = self.main_page.main_form

    def test_recommendation_order(self):
        self.main_form.wait_open()
        recomendations = self.main_form.get_recommendations()
        curr_rec = recomendations[0].text

        filler = DatabaseFiller()
        filler.admin_auth()

        filler.clean_up_orders()

        products = filler.get_restaurant_products(curr_rec)
        user_id = filler.get_profile_id()

        filler.create_order(user_id, curr_rec, self.login, products[0])

        self.driver.refresh()
        self.main_page.wait_visible()

        upd_recommendations = self.main_form.get_recommendations()
        is_exists = False
        for rec in upd_recommendations:
            if rec.text == curr_rec:
                is_exists = True

        filler.clean_up_orders()

        self.assertEqual(is_exists, False)

    # TODO: доделать когда по тегам можно будет гулять
    def test_tag_search(self):
        self.main_form.wait_open()

        filler = DatabaseFiller()
        filler.admin_auth()
        filler.create_tag('testtag')
        filler.create_restaurant('testRest')
        filler.add_tag_to_restaurant('testtag', 'testRest')

        self.driver.refresh()
        self.main_form.wait_open()

        self.main_form.get_tag_button_by_name('testtag').click()

        self.driver.refresh()
        self.main_form.wait_open()

        is_exists = False
        restaurants = self.main_form.get_restaurants()
        for item in restaurants:
            if item.text == 'testRest':
                is_exists = True

        filler.delete_tag_from_restaurant('testtag', 'testRest')
        filler.delete_tag('testtag')
        filler.delete_restaurant_by_name('testRest')

        self.assertEqual(is_exists, True)

    def tearDown(self):
        self.driver.quit()
def test_guest_should_see_login_link(browser):
    link = "http://selenium1py.pythonanywhere.com/"
    page = MainPage(browser, link)
    page.open()
    page.should_be_login_link()