コード例 #1
0
 def test_challenge6(self):
     homepage = copartPages.Homepage(self.driver)
     homepage.navigate()
     homepage.do_search("Nissan")
     results_page = copartPages.ResultsPage(self.driver)
     results_page.wait_for_page_load()
     results_page.set_filter("Model", "Skyline")
コード例 #2
0
 def test_challenge2(self):
     homepage = copartPages.Homepage(self.driver)
     homepage.navigate()
     homepage.do_search("exotics")
     results_page = copartPages.ResultsPage(self.driver)
     results_page.wait_for_page_load()
     makes = results_page.get_results_by_column("make")
     self.assertIn("PORSCHE", makes)
コード例 #3
0
    def test_challenge5(self):
        homepage = copartPages.Homepage(self.driver)
        homepage.navigate()
        homepage.do_search("Porsche")
        results_page = copartPages.ResultsPage(self.driver)
        results_page.wait_for_page_load()
        results_page.set_result_max(100)
        models = results_page.get_results_by_column("model")
        model_counts = {}
        for model in models:
            if model in list(model_counts):
                model_counts[model] = model_counts[model] + 1
            else:
                model_counts[model] = 1
        print('''
=====================
        MODELS
=====================
        ''')
        for model in list(model_counts):
            print(f'{model} was found {model_counts[model]} times.')

        self.subTest('Damage check')

        damages = results_page.get_results_by_column("damage")
        damage_counts = {
            "REAR END": 0,
            "FRONT END": 0,
            "MINOR DENT/SCRATCHES": 0,
            "UNDERCARRIAGE": 0,
            "MISC": 0
        }
        damage_sorter = {
            "REAR END": "REAR END",
            "FRONT END": "FRONT END",
            "MINOR DENT/SCRATCHES": "MINOR DENT/SCRATCHES",
            "UNDERCARRIAGE": "UNDERCARRIAGE"
        }
        for damage in damages:
            name = damage_sorter.get(damage, "MISC")
            damage_counts[name] = damage_counts[name] + 1
        print('''
=====================
        DAMAGES
=====================
        ''')
        for damage in list(damage_counts):
            print(f'{damage} occurred {damage_counts[damage]} times.')
コード例 #4
0
 def test_challenge7(self):
     homepage = copartPages.Homepage(self.driver)
     homepage.navigate()
     popular_items = homepage.get_popular_items()
     results_page = copartPages.ResultsPage(self.driver)
     for item in popular_items:
         self.driver.get(item.get('url'))
         results_page.wait_for_page_load()
         search_string = results_page.get_search_string().lower()
         string_to_find = item.get('name').replace(' ', '-').lower()
         current_url = self.driver.current_url.lower()
         self.assertIn(string_to_find, current_url,
                       f"The url didn't include {string_to_find}")
         if string_to_find in search_string:
             self.assertIn(
                 string_to_find, search_string,
                 f"The search text didn't include {string_to_find}")
         else:
             not_found_string = results_page.get_not_found_string()
             self.assertIn(
                 string_to_find, not_found_string,
                 f"The not found text didn't include {string_to_find}")
コード例 #5
0
 def test_challenge3(self):
     homepage = copartPages.Homepage(self.driver)
     homepage.navigate()
     popular_items = homepage.get_popular_items()
     for item in popular_items:
         print(f"{item.get('name')} - {item.get('url')}")