Skip to content

Commit af74719

Browse files
first cut with pass status amazon book list
1 parent 393e469 commit af74719

File tree

9 files changed

+126
-30
lines changed

9 files changed

+126
-30
lines changed
Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,82 @@
1-
name: q
2-
search_text: ''
3-
type: text
1+
amazon_product_byline_info: 'by
2+
3+
Kartik Hosanagar (Author)'
4+
amazon_product_description: "Product description\nReview\n\"[Hosanagar's] 'predictability-resilience\
5+
\ paradox' is conveyed convincingly. He excels in arguing for an algorithmic bill\
6+
\ of rights, one based on the original ideal of self-regulation by government and\
7+
\ by individuals . . . Algorthimic decision making and its influence in our lives\
8+
\ requires our attention and study.\"\n\u2014Library Journal \n\n\"Especially relevant\
9+
\ to current political hot topics, Hosanagar's outstanding introduction to algorithms\
10+
\ will appeal to and inform readers interested in learning more about the systems\
11+
\ that determine what they're exposed to online.\"\n\u2014Booklist.com\n\n\"Hosanagar\
12+
\ deserves credit for valiantly attempting, throughout this thoughtful treatise,\
13+
\ to widen understanding of a technology central to modern society.\"\n\u2014Publishers\
14+
\ Weekly\n\n\"The most useful part of the book is Hosanagar's 'algorithmic bill\
15+
\ of rights,' which would give consumers insight into the AI that surrounds them,\
16+
\ if not some measure of control.\"\n\u2014Kirkus Reviews\n\n\u201CAs we negotiate\
17+
\ the uneasy interactions between man and the intelligent machine, Kartik Hosanagar\u2019\
18+
s important and very timely book, helps us to understand a world increasingly dominated\
19+
\ by often opaque algorithms that take more and more decisions in our lives. His\
20+
\ proposal for an Algorithmic Bill of Rights needs to be acted on at the earliest!\u201D\
21+
\n\u2014Nandan Nilekani, Co-founder and Chairman of Infosys\n \n\u201CAI is finally\
22+
\ here, from guiding us home on Waze, to helping us choose a restaurant, a book\
23+
\ or a job. I believe this will launch a Renaissance of human creativity as mundane\
24+
\ tasks become handled by AI. Kartik Hosanagar\u2019s excellent book identifies\
25+
\ the growing pains we may experience along the way to this new human advancement.\u201D\
26+
\n\u2014Tim Draper, founding partner of venture capital firm DFJ\n\n\"Algorithms\
27+
\ and artificial intelligence are overturning the rules of society, but their true\
28+
\ impact is still in its infancy. Hosanagar's book is the best guide yet to understanding\
29+
\ these digital forces reshaping our lives. Rigorous yet readable, filled with insight\
30+
\ and perspective from one of our smartest thinkers about technology.\"\n\u2014\
31+
Arun Sundararajan, NYU professor and author of The Sharing Economy\nAbout the Author\n\
32+
Kartik Hosanagar is the John C. Hower Professor of Technology and Digital Business\
33+
\ and a professor of marketing at the Wharton School of the University of Pennsylvania.\
34+
\ The co-founder of four different ventures, he was recognized in 2011 by Poets\
35+
\ & Quants as one of the \"Top 40 Business Professors Under 40.\" His writing has\
36+
\ appeared in Wired, Forbes, and the Harvard Business Review, and his past consulting\
37+
\ and executive education clients include Google, American Express, Citigroup and\
38+
\ SunTrust Bank. Hosanagar earned his PhD in Management Science and Information\
39+
\ Systems from Carnegie Mellon University.\nSee all Product description"
40+
amazon_product_detail_description: ''
41+
amazon_product_details: 'Product details
42+
43+
Hardcover: 272 pages
44+
45+
Publisher: Viking (12 March 2019)
46+
47+
Language: English
48+
49+
ISBN-10: 0525560882
50+
51+
ISBN-13: 978-0525560883
52+
53+
Product Dimensions: 15.9 x 2.4 x 23.6 cm
54+
55+
Average Customer Review:
56+
57+
2 customer reviews
58+
59+
Amazon Bestsellers Rank: #1,74,299 in Books (See Top 100 in Books)
60+
61+
#2231 in Industries & Business Sectors (Books)
62+
63+
#144 in Algorithms
64+
65+
#181 in Programming Algorithms
66+
67+
Would you like to tell us about a lower price?
68+
69+
If you are a seller for this product, would you like to suggest updates through
70+
seller support?'
71+
amazon_product_formats: "See all 3 formats and editions\nKindle Edition\n\u20B9 281.20\n\
72+
Read with Our Free App\nHardcover\n\u20B9 1,664.00\n14 New from \u20B9 1,478.00"
73+
amazon_product_offers: "Save Extra with 4 offers\nCashback: Flat Rs.50 back on minimum\
74+
\ order of Rs.50 using Amazon Pay UPI. For Android App customers only. Applicable\
75+
\ on 1st ever transaction on Amazon Pay UPI. Cashback within 5 days. Set up Amazon\
76+
\ Pay UPI Here's how\nNo Cost EMI: Avail No Cost EMI on select cards for orders\
77+
\ above \u20B93000 Here's how\nBank Offer: 10% Instant Discount up to Rs. 1500 on\
78+
\ minimum purchase of Rs. 5,000 with SBI Credit cards and Credit Card EMIs Here's\
79+
\ how\nPartner Offers (1): Get GST invoice and save up to 28% on business purchases.\
80+
\ Sign up for free Here's how"
81+
amazon_product_title: 'A Human''s Guide to Machine Intelligence: How Algorithms Are
82+
Shaping Our Lives and How We Can Stay in Control'

Data/TestData/amazon.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ book_format:
99
- Paperback
1010
- Kindle eBooks
1111
- Hardcover
12-
min_price: 1000
13-
max_price: 1500
12+
min_price: 1,000
13+
max_price: 1,500
1414
select_product: 1
1515
delivery_pincode: 600001

Library/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def switch_to_new_tab(self):
7272
self.driver.switch_to.window(list_of_window_handles.pop())
7373

7474
def window_handles_count(self):
75-
return self.driver.window_handles
75+
return len(self.driver.window_handles)
7676

7777
def switch_to_parent_tab(self):
7878
self.driver.switch_to.window(self.current_window_handle)

Library/locator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ def texts(self) -> list:
7575
else:
7676
return arr_text
7777

78+
def texts_as_string(self) -> str:
79+
try:
80+
arr_text = []
81+
elements = Store.current_driver.find_elements(self.by, self.value)
82+
for ele in elements:
83+
arr_text.append(ele.text)
84+
except Exception as e:
85+
print("get texts not worked at \n" + self.by + "\n" + self.value + "\n Exception: \n" + str(e))
86+
return ""
87+
else:
88+
return ''.join(map(str, arr_text))
89+
7890
def is_displayed(self) -> bool:
7991
try:
8092
return Store.current_driver.find_elements(self.by, self.value).is_displayed()

Locators/amazon_search_result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def amazon_search_sort_by_selector(cls, string):
3232

3333
@classmethod
3434
def amazon_search_checkbox_filters(cls, string):
35-
return Locator("css selector", "ul.a-unordered-list li[aria-label='%s']" % string)
35+
return Locator("xpath", "//ul[contains(@class,'a-unordered-list')]//span[text()='%s']" % string)
3636

3737
@classmethod
3838
def amazon_search_result_list_header(cls, number):

Pages/amazon_home_page.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def is_home_page_displayed(cls):
1212

1313
@classmethod
1414
def select_category_drop_down(cls, string):
15-
AmazonHomePageLocator.amazon_search_categories.wait_till_displayed()
1615
AmazonHomePageLocator.amazon_search_categories.select(string)
1716

1817
@classmethod

Pages/amazon_product_page.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def set_delivery_pincode(cls, string):
1616
AmazonProductPageLocator.amazon_deliver_to_pincode.wait_till_displayed()
1717
AmazonProductPageLocator.amazon_deliver_to_pincode.send_keys(string)
1818
AmazonProductPageLocator.amazon_deliver_to_pincode_apply.click()
19+
AmazonProductPageLocator.amazon_deliver_to_pincode_apply.click()
1920
return AmazonProductPageLocator.amazon_product_page_identifier.wait_till_displayed()
2021

2122
@classmethod

Pages/amazon_search_result.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def get_search_result_head_liner_text(cls):
1717
@classmethod
1818
def is_filter_set_in_head_liner(cls, string):
1919
head_liner = AmazonSearchResultLocator.amazon_search_result_top_header.text()
20-
result = head_liner.find(string)
21-
if result == 0:
20+
result = head_liner.find(str(string))
21+
print("headliner : " + str(head_liner) + " expected string: " + str(string) + " result: " + str(result))
22+
if result != -1:
2223
return True
2324
else:
2425
return False

Tests/amazon.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import allure
22
import pytest
3+
import time
34
from Library.driver import Driver
45
from Pages.amazon_home_page import AmazonHomePage
56
from 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

Comments
 (0)