"""automating women menu hovering""" from config import XL_PATH, WOMEN_LOCS from expected_values import WOMEN_SUB_MENUS from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, WOMEN_LOCS) class WomenSubMenu: """gets women submenus """ # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) # pylint:disable=R0801 def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_menu(self): """hovers on electronics menu""" web.hover(self.driver, element["women"])
"""automating sports menu hovering""" from config import XL_PATH, SPORTS_LOCS from expected_values import SPORTS_SUB_MENUS from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, SPORTS_LOCS) class SportsSubMenu: """extracts sports submenu""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_menu(self): """hovers on sports menu""" web.hover(self.driver, element["sports"])
"""Login automation page""" from library.file_library import ReadFile from library.web_utils import WebUtils from config import XL_PATH, LOCATOR_VALS, TEST_SHEET web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, LOCATOR_VALS) # driver.implicitly_wait(5) class Login: """login""" def __init__(self, driver, test_case): self.driver = driver self.test_case = test_case self.username, self.password = read.read_data( XL_PATH, TEST_SHEET, self.test_case) def enter_username(self): """user""" web.send_string(self.driver, self.username, element['enter_username']) def enter_password(self): """password""" web.send_string(self.driver, self.password, element['enter_password']) def click_login(self): """click on login button""" web.click_element(self.driver, element['click_login'])
"""automates renting a movie""" from time import sleep from library.web_utils import WebUtils from library.file_library import ReadFile # from selenium import webdriver # from config import XL_PATH, RENT_TICKET_LOCS, CHROME_PATH, URL read = ReadFile() element, keys = read.read_objects(XL_PATH, RENT_TICKET_LOCS) web = WebUtils() class RentAMovie: """automates renting a movie""" def __init__(self, driver): self.driver = driver def scroll_down(self): """scrolls down""" web.scroll_down(self.driver) def scroll_up(self): """scrolls down""" web.scroll_up(self.driver) def select_city(self): """selects city""" web.click_element(self.driver, element['select_city']) def select_movie(self): """selects movie"""
"""automating buying a product end to end""" from config import XL_PATH, BUY_PRODUCT_LOCS, BUY_PRODUCT_TESTCASES from library.file_library import ReadFile from library.web_utils import WebUtils web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, BUY_PRODUCT_LOCS) class BuyProduct: """automating buying a product end to end""" def __init__(self, driver, test_case): self.driver = driver self.test_case = test_case self.product, self.price = read.read_data(XL_PATH, BUY_PRODUCT_TESTCASES, self.test_case) # print(self.product, self.price) def click_x(self): """clicks on x button""" web.click_element(self.driver, element['x_button']) def search_box(self): """sends value to search box""" web.send_string(self.driver, self.product, element['search_box']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button'])
"""fetches electronic submenus""" from config import XL_PATH, ELECTRONIC_LOCS from expected_values import ELECTRONIC_SUB_MENU # pylint:disable=R0801 from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, ELECTRONIC_LOCS) class ElectronicSubMenu: """fetches electronic submenus""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_electronics(self): """hovers on electronics menu""" web.hover(self.driver, element["electronics"])
"""automating menu hovering""" from config import XL_PATH, BABY_LOCS from expected_values import BABY_SUB_MENUS # pylint:disable=R0801 from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, BABY_LOCS) class BabySubMenu: """fetches baby submenus""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_menu(self): """hovers on baby sub menu"""
"""automating fashion menu hovering""" from config import XL_PATH, FASHION_LOCS from expected_values import FASHION_SUB_MENUS # pylint:disable=R0801 from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, FASHION_LOCS) class FashionSubMenu: """fetches fashion submenus""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" web.click_element(self.driver, element['x_button']) def hover_on_menu(self): """hovers on fashion menu""" web.hover(self.driver, element["fashion"]) def grab_sub_menu_items(self): """fetches electronic submenus""" sub_menus = web.grab_menus(self.driver, element['sub_menus']) sub_menus = [item.text for item in sub_menus] if sub_menus == FASHION_SUB_MENUS: print('All sub menus present') else: print('Some menu items maybe absent')
"""test login page""" from time import sleep import pytest from library.base_fixtures import DriverInit from library.file_library import ReadFile from config import XL_PATH, TEST_SHEET from pages.login import Login read = ReadFile() element, test_cases = read.read_objects(XL_PATH, TEST_SHEET) class TestLogin(DriverInit): """tests login""" @pytest.mark.parametrize("testcase", test_cases) def test_launch_url(self, testcase): """tests login page""" sleep(2.5) obj = Login(self.driver, testcase) # pylint:disable=E1101 # self.driver.implicitly_wait(5) sleep(2.5) obj.enter_username() sleep(2.5) obj.enter_password() sleep(2.5) obj.click_login() sleep(2.5)
"""automating furniture menu hovering""" from config import XL_PATH, FURNITURE_LOCS from expected_values import FURNITURE_SUB_MENUS # pylint:disable=R0801 from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, FURNITURE_LOCS) class FurnitureSubMenu: """obtains furniture sub menus""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_menu(self): """hovers on electronics menu""" web.hover(self.driver, element["furniture"])
"""test products availability""" from time import sleep import pytest from config import XL_PATH, BUY_PRODUCT_TESTCASES from pages.buy_product import BuyProduct from library.base_fixtures import DriverInit from library.file_library import ReadFile read = ReadFile() element, test_cases = read.read_objects(XL_PATH, BUY_PRODUCT_TESTCASES) class TestBuyProduct(DriverInit): """tests availability of products""" @pytest.mark.parametrize("testcase", test_cases) def test_buy_product(self, testcase): """tests availability of products""" obj = BuyProduct(self.driver, testcase) # pylint:disable=E1101 self.driver.implicitly_wait(10) # pylint:disable=E1101 obj.click_x() sleep(2.5) obj.search_box() sleep(2.5) obj.search_button() sleep(2.5) obj.price_filter() sleep(2.5) obj.rating_filter() sleep(2.5) obj.select_product() sleep(2.5)
""""fetches television submenus""" from config import XL_PATH, TELEVISION_LOCS from expected_values import TELEVISION from library.web_utils import WebUtils from library.file_library import ReadFile web = WebUtils() read = ReadFile() element, keys = read.read_objects(XL_PATH, TELEVISION_LOCS) # driver = webdriver.Chrome(CHROME_PATH, options=chrome_options) # driver.get(URL) class TelevisionSubMenu: """"fetches television submenus""" # pylint:disable=R0801 def __init__(self, driver): self.driver = driver def click_x(self): """clicks on x button""" # pylint:disable=R0801 web.click_element(self.driver, element['x_button']) def search_bar(self): """sends value to search box""" web.send_string(self.driver, 'sony vaio', element['search_bar']) def search_button(self): """clicks on search button""" web.click_element(self.driver, element['search_button']) def hover_on_television(self):