11import allure
22import pytest
3+ import time
34from Library .driver import Driver
45from Pages .amazon_home_page import AmazonHomePage
56from Pages .amazon_search_result import AmazonSearchResultPage
@@ -41,6 +42,12 @@ def test_amazon_book_search_001():
4142 with allure .step ("Apply the filter categories in the search results page" ):
4243 AmazonSearchResultPage .select_department (static_variable .static_value_for ("search_department" ))
4344 AmazonSearchResultPage .select_sub_department (static_variable .static_value_for ("search_sub_department" ))
45+ list_of_checkbox = static_variable .static_value_for ("book_format" )
46+ size_of_list = len (list_of_checkbox )
47+ for book_format in list_of_checkbox :
48+ AmazonSearchResultPage .select_checkbox_filter (book_format )
49+ assert (AmazonSearchResultPage .is_filter_set_in_head_liner (
50+ "Format: %s selected" % size_of_list )), "Applied checkbox filter is not listed in the result page headliner"
4451 AmazonSearchResultPage .select_average_customer_review (static_variable .static_value_for ("avg_customer_review" ))
4552 AmazonSearchResultPage .set_sort_by (static_variable .static_value_for ("sort_by" ))
4653 assert (AmazonSearchResultPage .is_filter_set_in_head_liner (
@@ -52,8 +59,6 @@ def test_amazon_book_search_001():
5259 assert (AmazonSearchResultPage .is_filter_set_in_head_liner (
5360 static_variable .static_value_for ("avg_customer_review" )) is True ), "Avg customer review is not displayed " \
5461 "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"
5762 AmazonSearchResultPage .set_min_max_price (static_variable .static_value_for ("min_price" ),
5863 static_variable .static_value_for ("max_price" ))
5964 assert (AmazonSearchResultPage .is_filter_set_in_head_liner (
@@ -63,33 +68,32 @@ def test_amazon_book_search_001():
6368 static_variable .static_value_for ("max_price" )) is True ), "max_price is not displayed in result page head " \
6469 "liner "
6570
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-
7471 with allure .step ("Select a product from the search result page" ):
7572 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"
73+ assert (driver .window_handles_count () == 2 ), "New tab is not opened after clicking a product"
7774 driver .switch_to_new_tab ()
7875 assert (AmazonProductPage .is_product_page_displayed () is True ), "Product page is not displayed after selecting"
7976
8077 with allure .step ("Set the delivery pincode in the product page" ):
8178 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"
79+ for i in range (0 , 10 ):
80+ time .sleep (1 )
81+ res = AmazonProductPage .get_delivery_pincode ().find (
82+ str (static_variable .static_value_for ("delivery_pincode" )))
83+ if res != - 1 :
84+ break
85+ print ("pincode: " + AmazonProductPage .get_delivery_pincode ())
86+ assert (res != - 1 ), "Delivery Pin code is not set properly"
8487
8588 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 ()
89+ ui_dynamic_data ["amazon_product_title" ] = AmazonProductPage .amazon_product_title .texts_as_string ()
90+ ui_dynamic_data ["amazon_product_byline_info" ] = AmazonProductPage .amazon_product_byline_info .texts_as_string ()
91+ ui_dynamic_data ["amazon_product_formats" ] = AmazonProductPage .amazon_product_formats .texts_as_string ()
92+ ui_dynamic_data ["amazon_product_detail_description" ] = AmazonProductPage .\
93+ amazon_product_detail_description .texts_as_string ()
94+ ui_dynamic_data ["amazon_product_offers" ] = AmazonProductPage .amazon_product_offers .texts_as_string ()
95+ ui_dynamic_data ["amazon_product_description" ] = AmazonProductPage .amazon_product_description .texts_as_string ()
96+ ui_dynamic_data ["amazon_product_details" ] = AmazonProductPage .amazon_product_details .texts_as_string ()
9397
9498 with allure .step ("Compare the dynamic value from UI with the stored file" ):
9599 dynamic_variable .compare (ui_dynamic_data )
0 commit comments