Beispiel #1
0
def step(context):
    while len(context.cars) < 2:
        main_page = MainPage()
        main_page.open_menu()
        main_page.select_menu_item()

        review_page = ReviewPage()

        context.brand, context.model, context.year = review_page.select_random_car(
        )
        review_page.view_car()

        car_page = CarPage(car_brand=context.brand,
                           car_model=context.model,
                           car_year=context.year)
        car_page.switch_to_tab()

        context.overview_page = OverviewPage(car_brand=context.brand,
                                             car_model=context.model,
                                             car_year=context.year)

        context.engines, context.transmissions = context.overview_page.get_engines_and_transmissions(
        )

        car = Car(context.brand, context.model, context.year, context.engines,
                  context.transmissions)

        if context.overview_page.is_compare_possible(
        ) == True and context.overview_page.are_characteristics_present(
        ) == True:
            context.cars.append(car)
Beispiel #2
0
def test_button_for_write_review_is_work(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
    page = ProductPage(browser, link)
    page.open()
    page.write_review_button()
    page = ReviewPage(browser, browser.current_url)
    page.button_review_is_worke()
Beispiel #3
0
    def test_cars_site_comparing_cars(self):
        cars = []

        while len(cars) < 2:
            main_page = MainPage()
            main_page.open_menu()
            main_page.select_menu_item()

            review_page = ReviewPage()
            brand, model, year = review_page.select_random_car()
            review_page.view_car()

            car_page = CarPage(car_brand=brand, car_model=model, car_year=year)
            car_page.switch_to_tab()

            overview_page = OverviewPage(
                car_brand=brand, car_model=model, car_year=year)
            engines, transmissions = overview_page.get_engines_and_transmissions()

            car = Car(brand, model, year, engines, transmissions)

            if overview_page.is_compare_possible() == True and overview_page.are_characteristics_present() == True:
                cars.append(car)

            if len(cars) == 2:
                overview_page.compare()

        compare_page = ComparePage()
        compare_page.select_necessary_car(
            cars[0].brand, cars[0].model, cars[0].year)
        first_car_engines, second_car_engines, first_car_transmissions, second_car_transmissions = compare_page.get_car_parameters()
        compare_page.compare_car_parameters(
            cars[0],
            cars[1],
            first_car_engines,
            second_car_engines,
            first_car_transmissions,
            second_car_transmissions)
 def __init__(self, app):
     self.app = app
     self.driver = app.driver
     self.review_actions = ReviewPage(driver=self.driver)
class ReviewActions(BasePage, BasePageObject):
    def __init__(self, app):
        self.app = app
        self.driver = app.driver
        self.review_actions = ReviewPage(driver=self.driver)

    @allure.step("Open review form to write a review")
    def open_review_form(self):
        LOGGER.info("Open review form to write a review")
        self.review_actions.click_create_review_button()

    @allure.step("Fill in review info")
    def fill_in_review(self, title, content, username, email):
        LOGGER.info("Fill in review info")
        self.review_actions.click_score_option()
        self.review_actions.type_review_title(title)
        self.review_actions.type_review_content(content)
        self.review_actions.type_review_username(username)
        self.review_actions.type_review_email(email)

    @allure.step("Post review")
    def post_review(self):
        LOGGER.info("Post review")
        self.review_actions.click_post_review_button()

    @allure.step("Verify created review")
    def verify_review(self, title, content):
        LOGGER.info("Verify created review")
        review_title = self.review_actions.get_review_title()
        review_content = self.review_actions.get_review_content()
        assert review_title == title, f"Test create review failed. " \
                                      f"Expected review title: {title}, " \
                                      f"Actual review title: {review_title}"
        assert review_content == content, f"Test create review failed. " \
                                          f"Expected review content: {content}, " \
                                          f"Actual review content: {review_content}"
        allure.attach(self.driver.get_screenshot_as_png(), "screenshot",
                      attachment_type.PNG)
def test_write_review_by_guest(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/reviews/add/#addreview"
    page = ReviewPage(browser, link)
    page.open()
    page.write_review_by_guest()
def open_review_page(init_driver):
    driver = init_driver
    driver.get(config['urls']['review_page'])
    time.sleep(3)
    return ReviewPage(driver)