def simple_search(item, shops, nums): results = {} driver = Driver() with driver as d: for shop, num in zip(shops, nums): shopobj = SHOPS[shop](d) shopobj.navigate() result = shopobj.search_results(item, num) results[shop] = result return results
class BasePage(object): """ Родительский класс для всех страниц тестируемого приложения Класс реализует поведение общее для всех страниц. Новые страницы должны наследоваться от BasePage """ def __init__(self): self.driver = Driver().connect() self.base_url = Config.BASE_URL self.address = '' self.url = f"{self.base_url}/{self.address}" def open(self): """ Открыть в браузере базовую страницу приложения """ return self.driver.get(self.url) def is_opened(self): pass
def test_search(self, item, shop): """ This method tests the search functionality of the framework for a given shops and a given item :param item: item to be searched in the shop :param shop: shop to be searched :return: writes the results into a file named 'results1' """ item_num = configuration.SEARCH_RESERVE fp = 'results1' driver = Driver() with open(fp, 'w') as f, driver as d: shopobj = shop(d) shopobj.navigate() results = [] for result in shopobj.search_results(item, item_num): f.write(str(result) + '\n') results.append(result) for sub in shopobj.results_page.results.sub_elements: assert result.get(sub) is not None assert len(results) == item_num
def test_search_basic(self, item): """ This method tests the search functionality of the framework for all the shops for a given item :param item: item to be searched in the shops :return: writes the results into a file named 'results' """ item_num = configuration.SEARCH_RESERVE fp = 'results' driver = Driver() with open(fp, 'w') as f, driver as d: for Shop in [Amazon, Flipkart, Snapdeal]: shop = Shop(d) shop.navigate() results = [] for result in shop.search_results(item, item_num): f.write(str(result) + '\n') results.append(result) for sub in shop.results_page.results.sub_elements: assert result.get(sub) is not None assert len(results) == item_num
def __init__(self, name, locator, loc_type): self.locator = locator self.locator_type = loc_type self.name = name self.driver = Driver().connect() self.obj = None
def __init__(self): self.driver = Driver().connect() self.base_url = Config.BASE_URL self.address = '' self.url = f"{self.base_url}/{self.address}"
from sites.shops.amazon import Amazon from sites.shops.snapdeal import Snapdeal from sites.shops.flipkart import Flipkart from framework.driver import Driver item = 'Redmi 5' fp = 'results' driver_new = Driver() with open(fp, 'w') as f, driver_new as d: for cls in [Amazon, Flipkart, Snapdeal]: shop = cls(d) shop.navigate() for result in shop.search_results(item, 5): f.write(str(result) + '\n')