def test_results_sorting(driver): driver.maximize_window() driver.get("https://shop.by/") actions = ActionChains(driver) laptops = get_catalog_item(driver, COMPUTERS_MENU_ITEM, LAPTOP_SUBMENU_ITEM) actions.move_to_element(laptops).click().perform() actions.reset_actions() if "noutbuki" not in driver.current_url: raise Exception("Redirect to /%s page doesn't happened" % "noutbuki") set_price_range(driver, min_price, max_price) manufacture_filter = BaseFilterMenu(driver, MANUFACTURE_EXPAND_XPATH) manufacture_filter.expand() manufacture_filter.click_on_items(MANUFACTORY_LIST) time.sleep(COMMON_TIMEOUT) display_size_filter = BaseFilterMenu(driver, DISPLAY_SIZE_EXPAND_XPATH) display_size_filter.expand() display_size_filter.click_on_items(DISPLAY_SIZE_LIST) time.sleep(COMMON_TIMEOUT) filter_url = driver.current_url apply_button = driver.find_element_by_class_name(SHOW_RES_BUTTON) apply_button.click() if driver.current_url == filter_url: raise Exception("Redirect on result page is not happened.") sorter = SortMenu(driver, SORTER_XPATH, SORTER_ITEMS) sorter.select("price_asc") results = Results(driver, RESULTS_XPATH) assert results, "Got empty result list" print("%s results on the page" % len(results)) flink = result_item_link(results[0]) sorter.select("price_desc") time.sleep(3) paginator = Paginator(driver, PAGINATOR_XPATH) paginator.move_to_the_last() time.sleep(COMMON_TIMEOUT) llink = result_item_link(results[-1]) print(flink) print(llink) assert flink == llink, "First item in results sorted by price ascending is not equal " \ "to the latest item in results sorted by price descending"