예제 #1
0
파일: main.py 프로젝트: tipishev/sportamore
    def test_upsell_on_featured_womens_product(self):
        CONSUMER = "Dam"
        PRODUCT_CATEGORY = "Underkläder"
        EXPECTED_URL = "https://www.sportamore.se/dam/klader/underklader/"
        EXPECTED_UPSELL = {'Slim 500ml', '3Ppk Value No Show'}

        driver = self.driver

        # navigate from the Main page to "herr/byxor" via hover-menu
        main_page = MainPage(driver)
        main_page.go_to_consumer_product_category(CONSUMER, PRODUCT_CATEGORY)

        # click on the featured product
        consumer_product_category_page = ConsumerProductCategoryPage(driver)
        current_url = consumer_product_category_page.current_url
        self.assertEqual(current_url, EXPECTED_URL)
        consumer_product_category_page.go_to_featured_product()

        # proceed to quantity selection
        product_page = ProductPage(driver)
        # ↓ an abstraction leak to demo flexibility
        product_page.size_select.select_first_size()
        product_page.go_to_add_to_cart()

        # check the actual upsell products against expected
        add_to_cart_page = AddToShoppingCartPage(driver)
        actual_upsell = add_to_cart_page.get_upsell_items()

        self.assertTrue(EXPECTED_UPSELL.issubset(actual_upsell),
                "Unexpected upsell items: {}".format(
                    EXPECTED_UPSELL.difference(actual_upsell)
                )
        )
예제 #2
0
def step_impl(context):
    br = context.browser
    el = MainPage(context).click(attr_name='link-infringement')
    r = requests.get(el.get_attribute("href"))
    assert r.status_code == 200

    br.switch_to_window(br.window_handles[0])
예제 #3
0
 def choose_kettle_category_test(self):
     print("Testing navigating to kettles")
     page = MainPage(self.driver)
     self.assertEqual(
         page.choose_item_category(
             "a[href='http://www.williams-sonoma.com/shop/cookware/teakettles/?cm_type=lnav']"
         ), "Tea Kettles")
     print("")
예제 #4
0
class BaseSearchInputTest(BaseTest):
    DEFAULT_SEARCH_STRING = 'test'

    def setUp(self):
        super(BaseSearchInputTest, self).setUp()

        self.main_page = MainPage(self.driver)
        self.main_page.search(self.DEFAULT_SEARCH_STRING)
예제 #5
0
 def test_guest_can_go_to_login_page(self, browser):
     link = "http://selenium1py.pythonanywhere.com/"
     page = MainPage(browser, link)
     page.open()
     page.should_be_login_link()
     page.go_to_login_page()
     login_page = LoginPage(browser, browser.current_url)
     login_page.should_be_login_page()
예제 #6
0
def test_main_page(browser, base_url):
    mp = MainPage(browser)
    with allure.step("Открываем главную страницу"):
        mp.open(base_url, mp.path)
    with allure.step("Проверяем наличие карусели товаров"):
        assert mp.get_main_carousel()
    with allure.step("Проверяем наличие логотипа"):
        assert mp.get_logo()
    with allure.step("Проверяем наличие строки поиска"):
        assert mp.get_search_field()
    with allure.step("Проверяем наличие заголовка товаров"):
        assert mp.get_head_featured_goods()
    with allure.step("Проверяем наличие товаров"):
        assert mp.get_featured_goods()
예제 #7
0
    def crack(self):
        self.initpage = InitPage(self, self.sess.get(InitPage.url).text)
        self.mainpage = MainPage(self, self.initpage.proceed().text)
        qxresp = self.mainpage.proceed()
        bsids = re.findall('bsid=(\d{6})', qxresp.text)
        params = [{'__EVENTTARGET': tag.parent.parent.a.attrs['href'].split("'")[1]}
                for tag in BeautifulSoup(qxresp.text,'html.parser').find_all('font', {'color': 'Red'}) \
                        if tag.parent.parent.a and tag.text == '否']

        for param in params:
            try:
                self.grabpage = GrabPage(self, qxresp.text, param)
                lesson_resp = self.grabpage.proceed()
                self.lessonpage = LessonPage(self, lesson_resp.text,
                                             lesson_resp.url, bsids)
                Runner(self.grabpage, self.lessonpage, self).run()
            except EmptyCourse as e:
                logger.error(e)
예제 #8
0
def test_add_to_cart_from_main_page(browser, name, phone):
    # Arrange
    link = "https://maxipro.ru"
    main_page = MainPage(browser, link)
    main_page.open_page()
    main_page.scroll_down(1000)

    # Act
    main_page.push_add_to_cart_btn()
    time.sleep(5)
    main_page.push_place_an_order_btn()
    cart_page = CartPage(browser, link)
    cart_page.place_one_click_order()
    cart_page.fill_name(name)
    cart_page.fill_phone(phone)
    cart_page.choose_delivery_method()
    cart_page.send_an_order()

    # Assert
    cart_page.check_success_msg_title()
예제 #9
0
 def test_guest_cant_see_product_in_basket_opened_from_main_page(self, browser):
     link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
     page = MainPage(browser, link)
     page.open()
     page.go_to_basket_page()
     basket_page = BasketPage(browser, browser.current_url)
     basket_page.should_be_empty()
예제 #10
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    page = MainPage(browser, link)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.cart_is_empty()
    cart_page.empty_cart_subtitle()
예제 #11
0
def test_open_main_page(browser, base_url, generate_env):
    mp = MainPage(browser)
    with allure.step("Открываем главную страницу"):
        mp.open(base_url, mp.path)
    mp.logger.info("Сравниваем заголовок страницы с эталоном")
    with allure.step("Проверяем заголовок"):
        assert mp.get_title() == 'Your Store'
    with allure.step("Проверяем ссылку на OpenCart"):
        assert mp.get_link_powered_by_text() == 'OpenCart'
 def setup(self, browser):
     link = "http://selenium1py.pythonanywhere.com/"
     page = MainPage(browser, link)
     page.open()
     page.go_to_login_page()
     login_page = LoginPage(browser, browser.current_url)
     login_page.register_new_user(email=str(time.time()) + "@fakemail.org",
                                  password='******')
     login_page.should_be_authorized_user()
예제 #13
0
def test_open_request_form(browser, organisation, inn, name, phone, email,
                           comment):
    link = "https://maxipro.ru"
    page = MainPage(browser, link)
    page.open_page()
    page.should_be_request_link()
    page.open_request_form()
    form = RequestForm(browser, link)
    form.check_request_form()
    form.input_org_name(organisation)
    form.input_inn_number(inn)
    form.input_person_name(name)
    form.input_phone_number(phone)
    form.input_email(email)
    form.input_comment(comment)
    form.should_be_submit_btn()
    form.submit_request()
    form.check_error_message_title()
    form.check_agreement_error_text()
    form.push_error_msg_btn()
    form.check_request_form()
    form.fill_spec_checkbox()
    form.fill_agreement_checkbox()
    form.submit_request()
    form.check_error_message_title()
    form.check_requisite_error_text()
    form.push_error_msg_btn()
    form.check_request_form()
    form.load_requisite()
    form.submit_request()
    form.check_error_message_title()
    form.check_list_error_text()
    form.push_error_msg_btn()
    form.check_request_form()
    form.load_list()

    # page.should_be_submit_btn()
    # page.submit_request()
    # page.check_success_message_text()
    # page.push_success_btn()

    # page.check_list_type_error_text()

    time.sleep(10)
예제 #14
0
 def test_search_item(self):
     print ("\n" + str(test_cases(1)))
     page = MainPage(self.driver)
     search_result = page.search_item("Nexus 5")
     self.assertIn("Nexus 5", search_result)
예제 #15
0
 def test_sign_up_button(self):
     print ("\n" + str(test_cases(2)))
     page = MainPage(self.driver)
     signUpPage = page.click_sign_up_button()
     self.assertIn("ap/register", signUpPage.get_url())
예제 #16
0
 def save_for_later_test(self):
     print("Testing save for later")
     page = MainPage(self.driver)
     itemList = page.save_for_later()
     self.assertEqual(itemList[0], itemList[1])
     print("")
예제 #17
0
 def test_sign_in_with_in_valid_user(self):
     print ("\n" + str(test_cases(5)))
     mainPage = MainPage(self.driver)
     loginPage = mainPage.click_sign_in_button()
     result = loginPage.login_with_in_valid_user("invalid_user")
     self.assertIn("There was a problem with your request", result)
예제 #18
0
 def test_guest_can_go_to_login_page(self, 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()
예제 #19
0
 def page_loaded_test(self):
     print("Testing home page loads up")
     page = MainPage(self.driver)
     self.assertTrue(page.check_page_loaded())
     print("")
예제 #20
0
 def save_for_later_test(self):
     print ("Testing save for later")
     page = MainPage(self.driver)
     itemList = page.save_for_later()
     self.assertEqual(itemList[0], itemList[1])
     print("")
예제 #21
0
 def test_sign_in_with_valid_user(self):
     print ("\n" + str(test_cases(4)))
     mainPage = MainPage(self.driver)
     loginPage = mainPage.click_sign_in_button()
     result = loginPage.login_with_valid_user("valid_user")
     self.assertIn("yourstore/home", result.get_url())
예제 #22
0
 def choose_a_kettle_test(self):
     print ("Testing tea kettle selection")
     page = MainPage(self.driver)
     self.assertEqual(page.choose_specific_item(), "Shopping Cart")
     print("")
예제 #23
0
 def choose_kettle_category_test(self):
     print("Testing navigating to kettles")
     page = MainPage(self.driver)
     self.assertEqual(page.choose_item_category("a[href='http://www.williams-sonoma.com/shop/cookware/teakettles/?cm_type=lnav']"), "Tea Kettles")
     print("")
예제 #24
0
 def choose_cookware_test(self):
     print ("Testing navigating to category")
     page = MainPage(self.driver)
     self.assertEqual(page.choose_cookware(), "Cookware Sets")
     print("")
예제 #25
0
 def test_page_load(self):
     print ("\n" + str(test_cases(0)))
     page = MainPage(self.driver)
     self.assertTrue(page.check_page_loaded())
예제 #26
0
 def test_guest_should_see_login_link(self, browser):
     page = MainPage(browser, link)
     page.open()
     page.should_be_login_link()
예제 #27
0
class Cracker(object):
    def __init__(self, user, passwd):
        super().__init__()
        self.user = user
        self.passwd = passwd
        # self.view_param = param
        self.sess = login(self.user, self.passwd)

    def crack(self):
        self.initpage = InitPage(self, self.sess.get(InitPage.url).text)
        self.mainpage = MainPage(self, self.initpage.proceed().text)
        qxresp = self.mainpage.proceed()
        bsids = re.findall('bsid=(\d{6})', qxresp.text)
        params = [{'__EVENTTARGET': tag.parent.parent.a.attrs['href'].split("'")[1]}
                for tag in BeautifulSoup(qxresp.text,'html.parser').find_all('font', {'color': 'Red'}) \
                        if tag.parent.parent.a and tag.text == '否']

        for param in params:
            try:
                self.grabpage = GrabPage(self, qxresp.text, param)
                lesson_resp = self.grabpage.proceed()
                self.lessonpage = LessonPage(self, lesson_resp.text,
                                             lesson_resp.url, bsids)
                Runner(self.grabpage, self.lessonpage, self).run()
            except EmptyCourse as e:
                logger.error(e)

    def post(self, *args, **kw):
        resp = self.sess.post(*args, **kw)
        while True:
            try:
                self.handle_outdate(resp)
                self.handle_message(resp)
            except SessionOutdated:
                self.sess = login(self.user, self.passwd)
                # FIXME: initpage needed?
                self.initpage = InitPage(self,
                                         self.sess.get(InitPage.url).text)
                resp = self.sess.post(*args, **kw)
            except MessageError as e:
                resp = self.sess.post(*args, **kw)
            else:
                return resp

    def handle_outdate(self, resp):
        if 'outTimePage.aspx' in resp.url:
            self.sess = login(self.user, self.passwd)
            raise SessionOutdated
        # return resp

    def handle_message(self, resp):
        try:
            message = unquote(resp.url.split('message=')[1])
            logger.info(message)
            if '刷新' in message:
                sleep(1)
            elif message == '该课该时间段人数已满!':
                logger.debug(message)
                # raise CourseFull(message)
            raise MessageError
        except IndexError:
            pass
예제 #28
0
def step_impl(context):
    MainPage(context).go_browse()
예제 #29
0
def main_page(driver):
    return MainPage(driver)
예제 #30
0
 def choose_cookware_test(self):
     print("Testing navigating to category")
     page = MainPage(self.driver)
     self.assertEqual(page.choose_cookware(), "Cookware Sets")
     print("")
예제 #31
0
def test_guest_cant_see_product_in_basket_opened_from_main_page(browser):
    page = MainPage(browser, link)
    page.open()
    page.go_to_cart()
    basket_page = BasketPage(browser, browser.current_url)
    basket_page.should_be_empty_basket()
예제 #32
0
 def test_sign_in_button(self):
     print ("\n" + str(test_cases(3)))
     page = MainPage(self.driver)
     loginPage = page.click_sign_in_button()
     self.assertIn("ap/signin", loginPage.get_url())
예제 #33
0
 def choose_a_kettle_test(self):
     print("Testing tea kettle selection")
     page = MainPage(self.driver)
     self.assertEqual(page.choose_specific_item(), "Shopping Cart")
     print("")
예제 #34
0
 def test_blacklist(self):
     MainPage().mock_pop_window().goto_me()
예제 #35
0
    def visit_main_site(self):
        """entrance to site before tests"""

        site = MainPage.Main(self.browser)
        site.visit()
        yield site
예제 #36
0
 def page_loaded_test(self):
     print("Testing home page loads up")
     page = MainPage(self.driver)
     self.assertTrue(page.check_page_loaded())
     print("")