-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmartbear_main_page.py
More file actions
32 lines (26 loc) · 1.26 KB
/
smartbear_main_page.py
File metadata and controls
32 lines (26 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from selenium import webdriver
from selenium.webdriver.common.by import By
"""The class for the website's main page"""
class BearStoreMainPage:
def __init__(self,driver:webdriver.Edge):
self.driver = driver
def categories(self):
"""Returns a list of the categories in the BearStoreMainPage."""
categories_div = self.driver.find_element(By.CLASS_NAME,'artlist-homepage-categories')
return categories_div.find_elements(By.CSS_SELECTOR,'article > div.art-genericname > a')
def click_category(self,category_name):
categories_list = self.categories()
for category in categories_list:
if category_name.lower() == category.text.lower():
category.click()
break
def featured_products(self):
"""Returns a list of the featured products in the BearStoreMainPage."""
featured_prods = self.driver.find_element(By.CSS_SELECTOR,'#artlist-7040135593')
return featured_prods.find_elements(By.CSS_SELECTOR,'article > h3')
def click_featured_product(self,product_name):
featured_prods = self.featured_products()
for prod in featured_prods:
if product_name.lower() == prod.text.lower():
prod.click()
break