|
2 | 2 | import pytest |
3 | 3 | from Library.driver import Driver |
4 | 4 | from Pages.amazon_home_page import AmazonHomePage |
| 5 | +from Pages.amazon_search_result import AmazonSearchResultPage |
| 6 | +from Pages.amazon_product_page import AmazonProductPage |
5 | 7 | from Library.variable import Var |
6 | 8 |
|
7 | 9 |
|
@@ -29,5 +31,65 @@ def test_amazon_book_search_001(): |
29 | 31 | assert (AmazonHomePage.get_selected_category() == |
30 | 32 | static_variable.static_value_for("category")), "Category is not selected properly" |
31 | 33 |
|
32 | | - with allure.step("Search for the text which is needed in this case: " + static_variable.static_value_for("search_text")): |
33 | | - AmazonHomePage.search_in_the_search_box(static_variable.static_value_for("search_text")) |
| 34 | + with allure.step("Search for the text which is needed in this"): |
| 35 | + search_text = static_variable.static_value_for("search_text") |
| 36 | + AmazonHomePage.search_in_the_search_box(search_text) |
| 37 | + assert (AmazonSearchResultPage.is_search_result_page_displayed() is True), "Search result page is not displayed" |
| 38 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner(search_text) is True), "Searched text is not " \ |
| 39 | + "displayed in the result page" |
| 40 | + |
| 41 | + with allure.step("Apply the filter categories in the search results page"): |
| 42 | + AmazonSearchResultPage.select_department(static_variable.static_value_for("search_department")) |
| 43 | + AmazonSearchResultPage.select_sub_department(static_variable.static_value_for("search_sub_department")) |
| 44 | + AmazonSearchResultPage.select_average_customer_review(static_variable.static_value_for("avg_customer_review")) |
| 45 | + AmazonSearchResultPage.set_sort_by(static_variable.static_value_for("sort_by")) |
| 46 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 47 | + static_variable.static_value_for("search_department")) is True), "Searched department is not displayed " \ |
| 48 | + "in result page head liner" |
| 49 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 50 | + static_variable.static_value_for("search_sub_department")) is True), "Searched sub department is not " \ |
| 51 | + "displayed in result page head liner" |
| 52 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 53 | + static_variable.static_value_for("avg_customer_review")) is True), "Avg customer review is not displayed " \ |
| 54 | + "in result page head liner" |
| 55 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 56 | + static_variable.static_value_for("sort_by")) is True), "sort by is not displayed in result page head liner" |
| 57 | + AmazonSearchResultPage.set_min_max_price(static_variable.static_value_for("min_price"), |
| 58 | + static_variable.static_value_for("max_price")) |
| 59 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 60 | + static_variable.static_value_for("min_price")) is True), "min_price is not displayed in result page head " \ |
| 61 | + "liner " |
| 62 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 63 | + static_variable.static_value_for("max_price")) is True), "max_price is not displayed in result page head " \ |
| 64 | + "liner " |
| 65 | + |
| 66 | + with allure.step("Apply check box filters in the search result page"): |
| 67 | + list_of_checkbox = static_variable.static_value_for("book_format") |
| 68 | + size_of_list = len(list_of_checkbox) |
| 69 | + for book_format in list_of_checkbox: |
| 70 | + AmazonSearchResultPage.select_checkbox_filter(book_format) |
| 71 | + assert (AmazonSearchResultPage.is_filter_set_in_head_liner( |
| 72 | + "Format: %s selected" % size_of_list)), "Applied checkbox filter is not listed in the result page headliner" |
| 73 | + |
| 74 | + with allure.step("Select a product from the search result page"): |
| 75 | + AmazonSearchResultPage.select_a_product_from_search_result(static_variable.static_value_for("select_product")) |
| 76 | + assert (driver.window_handles_count == 2), "New tab is not opened after clicking a product" |
| 77 | + driver.switch_to_new_tab() |
| 78 | + assert (AmazonProductPage.is_product_page_displayed() is True), "Product page is not displayed after selecting" |
| 79 | + |
| 80 | + with allure.step("Set the delivery pincode in the product page"): |
| 81 | + AmazonProductPage.set_delivery_pincode(static_variable.static_value_for("delivery_pincode")) |
| 82 | + result = AmazonProductPage.get_delivery_pincode().find(static_variable.static_value_for("delivery_pincode")) |
| 83 | + assert (result is True), "Delivery Pin code is not set properly" |
| 84 | + |
| 85 | + with allure.step("Store the UI details in the dynamic dictionary"): |
| 86 | + ui_dynamic_data["amazon_product_title"] = AmazonProductPage.amazon_product_title.texts() |
| 87 | + ui_dynamic_data["amazon_product_byline_info"] = AmazonProductPage.amazon_product_byline_info.texts() |
| 88 | + ui_dynamic_data["amazon_product_formats"] = AmazonProductPage.amazon_product_formats.texts() |
| 89 | + ui_dynamic_data["amazon_product_detail_description"] = AmazonProductPage.amazon_product_detail_description.texts() |
| 90 | + ui_dynamic_data["amazon_product_offers"] = AmazonProductPage.amazon_product_offers.texts() |
| 91 | + ui_dynamic_data["amazon_product_description"] = AmazonProductPage.amazon_product_description.texts() |
| 92 | + ui_dynamic_data["amazon_product_details"] = AmazonProductPage.amazon_product_details.texts() |
| 93 | + |
| 94 | + with allure.step("Compare the dynamic value from UI with the stored file"): |
| 95 | + dynamic_variable.compare(ui_dynamic_data) |
0 commit comments