def test_edit_car(self):
        self.navigate_to_edit_car_page()

        # Edit car
        self.car['year'] = "2012"
        self.car['make'] = "Ford"
        self.car['model'] = "Focus"

        random_trim_levels = []
        for _ in range(3):
            random_trim_levels.append(generate_random_trim_level())

        self.car['trim_levels'] = random_trim_levels
        self.car['car_string'] = get_car_string(self.car)

        edit_car_page = EditCarPage(self.driver)
        edit_car_page.edit_year(self.car['year'])
        edit_car_page.edit_make(self.car['make'])
        edit_car_page.edit_model(self.car['model'])
        self.edit_trim_levels(edit_car_page)
        edit_car_page.click_submit_car_button()

        LOG.info("Edited car to: %s", self.car['car_string'])

        self.assertIsNotNone(self.main_page.find_car_row(self.car))
예제 #2
0
    def find_multiple_car_rows(self, car_list):
        LOG.info("Finding multiple car rows...")
        found_count = 0
        found_car_rows = {}

        for car in car_list:
            found_car_rows[car['car_string']] = None

        while True:
            car_rows = self.get_car_rows()

            for row in car_rows:
                row_car = self.car_row_to_car_dict(row)
                row_car_string = get_car_string(row_car)

                if row_car_string in found_car_rows:
                    LOG.info("Found car: {}".format(row_car_string))
                    found_car_rows[row_car_string] = row
                    found_count += 1

                    if found_count == len(car_list):
                        return found_car_rows

            clicked_next_page_link = self.click_next_page_link()

            if not clicked_next_page_link:
                break

        return found_car_rows
예제 #3
0
    def setUpClass(cls):
        cls.car_list = [
            {
                'year': "2021",
                'make': "Honda",
                'model': "Civic",
            },
            {
                'year': "2016",
                'make': "Toyota",
                'model': "Corolla",
            },
            {
                'year': "2013",
                'make': "Ford",
                'model': "Explorer",
            },
        ]

        for car in cls.car_list:
            car['trim_levels'] = [
                generate_random_trim_level() for _ in range(3)
            ]

        for car in cls.car_list:
            car['car_string'] = get_car_string(car)

        web_driver_utility = WebDriverUtility()
        cls.driver = web_driver_utility.get_new_web_driver()
        cls.driver.get(web_driver_utility.get_home_page_url())

        cls.main_page = MainPage(cls.driver)
        cls.login()
        cls.add_cars()
    def add_trim_level(self, edit_car_page):
        trim_level_to_add = generate_random_trim_level()
        LOG.info("Trim level to add: %s", trim_level_to_add)
        self.car['trim_levels'].append(trim_level_to_add)
        self.car['car_string'] = get_car_string(self.car)

        edit_car_page.click_add_trim_level_button()
        trim_level_inputs = edit_car_page.trim_levels.find_elements(By.XPATH, ".//input")
        trim_level_inputs[-1].send_keys(trim_level_to_add)
    def delete_trim_level(self, edit_car_page):
        trim_level_to_delete = self.car['trim_levels'].pop()
        LOG.info("Trim level to delete: %s", trim_level_to_delete)
        self.car['car_string'] = get_car_string(self.car)

        trim_level_input_groups = edit_car_page.trim_levels.find_elements(By.XPATH, ".//div[contains(@class, 'input-group')]")
        for input_group in trim_level_input_groups:
            existing_trim_level = input_group.find_element(By.XPATH, ".//input")

            if trim_level_to_delete == existing_trim_level.get_attribute("value"):
                delete_button = input_group.find_element(By.XPATH, ".//button")
                delete_button.click()
                break
    def setUp(self):
        self.car = {
            'year': "2021",
            'make': "Honda",
            'model': "Civic",
            'trim_levels': [generate_random_trim_level() for _ in range(3)],
        }

        self.car['car_string'] = get_car_string(self.car)

        web_driver_utility = WebDriverUtility()
        self.driver = web_driver_utility.get_new_web_driver()
        self.driver.get(web_driver_utility.get_home_page_url())

        self.main_page = MainPage(self.driver)
예제 #7
0
    def find_car_row(self, car):
        LOG.info("Finding car row...")

        while True:
            car_rows = self.get_car_rows()

            for row in car_rows:
                row_car = self.car_row_to_car_dict(row)
                row_car_string = get_car_string(row_car)

                if row_car_string == car['car_string']:
                    LOG.info("Found car: {}".format(row_car_string))
                    return row

            clicked_next_page_link = self.click_next_page_link()

            if not clicked_next_page_link:
                break

        return None