def test_02_sorting(self): """Проверка сортирвоки вкладки""" gb_tool = GBtool(self.driver) my_orders = My_oders(self.driver) gb_tool.goto_tab(my_orders=True) game_list = [ 'all games', 'World of Warcraft', 'Counter-Strike', 'Overwatch', 'Dota 2', 'League of legends' ] i = 1 while i < len(game_list): my_orders.do_sort_by_game(game_list[i]) i += 1 cat_list = [ 'All orders', 'Auction', 'In progress', 'Waiting', 'Warranty', 'Done', 'Drafts' ] i = 1 while i < len(cat_list): my_orders.do_sort_by_cat(cat_list[i]) i += 1
def invite_booster(self): gb_tool = GBtool(self.driver) time.sleep(1) hire_btn = self.driver.find_element_by_css_selector( Locators.INVITE_BTN[1]) booster = self.driver.find_elements_by_css_selector( Locators.BOOSTER[1])[0] booster_name = booster.find_element_by_css_selector( '.booster__playername') booster_name = booster_name.text hire_btn.click() invited_booster = self.driver.find_element_by_css_selector( Locators.INVITED_BOOSTER[1]) invited_booster_name = invited_booster.find_element_by_css_selector( '.invited-menu--dark') invited_booster_name = invited_booster_name.text hire_btn.click() gb_tool.check_exists_by_css('.booster-row', 'Приглашенный бустер', reverse=True) # assert_equal(x, 1, 'Окно не заполнено бустером') assert_equal(booster_name, invited_booster_name, 'Имена не сходятся')
def test_04_delete(self): """Удалить ставку""" ordrs = OrderSearch(self.driver) gb_tools = GBtool(self.driver) gb_tools.go_to_tab_booster(search_orders=True) time.sleep(5) ordrs.delete()
def test_03(self): """Инвайт - дезинвайт""" gb_tool = GBtool(self.driver) gb_tool.goto_tab(top_boost=True) top_boost = TopBoostPage(self.driver) top_boost.invite_booster() top_boost.dezinvite_boost()
def dezinvite_boost(self): gb_tool = GBtool(self.driver) delete = self.driver.find_element_by_css_selector( Locators.DEZINVITE[1]) time.sleep(1) delete.click() gb_tool.check_exists_by_css('.booster-row', 'Приглашенный бустер')
def delete(self): gb_tools = GBtool(self.driver) order = self.driver.find_elements(*Locators.ORDER)[0] delete = order.find_elements(*Locators.ORDER_BTNS)[1] delete.click() dialog = Locators.DIALOG gb_tools.check_exists_by_css(css=dialog[1], name='Окно удаления')
def test_02_sort(self): """Проверка сортировки""" gb_tools = GBtool(self.driver) ordrs = MyOrders(self.driver) gb_tools.go_to_tab_booster(my_orders=True) time.sleep(1) ordrs.check_game()
def test_01(self): """Проверка перехода на домашнюю страницу со страницы пользователя без заказов """ gb_tool = GBtool(self.driver) my_orders = MyOdersPage(self.driver) gb_tool.goto_tab(my_orders=True) time.sleep(1) my_orders.check_components_no_orders()
def open(self): gb_tool = GBtool(self.driver) new_btn = self.driver.find_element(*Locators.NEW_ORDER) new_btn.click() constructor = self.driver.find_element(*Locators.CONSTRUCTOR) gb_tool.check_exists_by_css(css=constructor, name="Конструктор")
def is_constructor_download(self): gb_tool = GBtool(self.driver) download = gb_tool.check_exists_by_css(css=Constructor[1], name='Конструктор') assert download == True ('Констурктор не загрузился') print('Конструктор загружен')
def search_check(self, name): gb_tool = GBtool(self.driver) gb_tool.search(name) booster = self.driver.find_elements_by_css_selector( Locators.BOOSTER[1])[0] booster_name = booster.find_element_by_css_selector( '.booster__playername') assert_equal(booster_name.text, name, 'Поиск верен')
def check_sort_by_service(self): """Сортировка по услуге""" gb_tool = GBtool(self.driver) service = self.driver.find_elements_by_css_selector( Locators.GM_CH[1])[2] name = 'Панель выбора суслуги' gb_tool.select_a_game('All games') z = gb_tool.is_active(service, name) assert_equal(z, 0, 'Сценарий неверен') gb_tool.select_a_game('World of Warcraft') z = gb_tool.is_active(service, name) assert_equal(z, 1, 'Сценарий неверен') game_list = [ 'World of Warcraft', 'Counter-Strike', 'Overwatch', 'Dota 2', 'League of Legends' ] i = 0 while i < len(game_list): self.service_check(game_list[i]) print('Услуги ' + game_list[i] + ' сошлись') i += 1
def do_sort_by_game(self, name): """Проверка сортировки по игре""" games_dict = { 'all': 0, 'World of Warcraft': 1, 'Counter-Strike': 2, 'Overwatch': 3, 'Dota 2': 4, 'League of legends': 5 } gb_tool = GBtool(self.driver) chooser = Locators.GAME_CHOOSER chooser = self.driver.find_element_by_css_selector(chooser) chooser.click() cur_game = Locators.CURRENT_GAME cur_game = self.driver.find_elements_by_css_selector(cur_game[1])[games_dict[name]] cur_game.click() game_name = chooser.text assert_equal(game_name, name, 'Название выбранной игры неверно') i = 1
def check_components(self): """Проверка компонентов топ бустеров""" gb_tool = GBtool(self.driver) time.sleep(1) password = self.driver.find_element(*Locators.PASSWORD) gb_tool.check_exists_by_css(css=password, name='Блок смены пароля') faq = self.driver.find_element(*Locators.FAQ) gb_tool.check_exists_by_css(css=faq, name='Блок справки ') usrpic = self.driver.find_element(*Locators.USERPIC) gb_tool.check_exists_by_css(css=usrpic, name='Аватар') card = self.driver.find_element(*Locators.CARD) gb_tool.check_exists_by_css(css=card, name="Карточка пользователя")
def test_02_sort(self): """Сортировка""" gb_tools = GBtool(self.driver) ordrs = OrderSearch(self.driver) gb_tools.go_to_tab_booster(search_orders=True) gb_tools.do_sort_by_game('World of Warcraft') gb_tools.check_sort_service_boost() ordrs.check_sort_by_service() ordrs.lang_checker(eng=True)
def service_check(self, name): """Проверка строк""" gb_tool = GBtool(self.driver) service = self.driver.find_elements_by_css_selector( Locators.GAME_CHOOSER[1])[2] dpdwn = self.driver.find_elements_by_css_selector( Locators.DROP_DOWN[1])[2] service_dict = { 'World of Warcraft': [ 'All services', 'Powerleveling', 'PVP', 'Dungeons', 'Raids', 'Mounts', 'Glories', 'Coaching', 'Other services' ], 'Counter-Strike': [ 'All services', 'Calibration', 'Rank boost', 'Coaching', 'Other services' ], 'Overwatch': [ 'All services', 'Skill rating boost', 'Win boost', 'Placement matches', 'LVL boost', 'Coaching', 'Other services' ], 'Dota 2': [ 'All services', 'Boost solo mmr', 'Calibration', 'Boost party mmr', 'Low priority', 'Coaching', 'Other services' ], 'League of Legends': [ 'All services', 'Division boost', 'Win boost', 'Calibration', 'Coaching', 'Other services' ] } gb_tool.select_a_game(name) i = 0 service.click() while i < len(service_dict[name]): row = dpdwn.find_elements_by_css_selector( Locators.CHOOSER_ITEM[1])[i] assert_equal(row.text, service_dict[name][i]) i += 1 service.click()
def check_components_with_orders(self): """Проверка компонентов баера с заказами""" gb_tool = GBtool(self.driver) orders = Locators.ORDERS gb_tool.check_exists_by_css(orders) orders_cat = Locators.ORDERS_CAT gb_tool.check_exists_by_css(orders_cat) orders_count = Locators.ORDERS_COUNT gb_tool.check_exists_by_css(orders_count)
def lang_checker(self, rus = False, eng = False): """Проверка сортировки по игре""" gb_tool = GBtool(self.driver) gb_tool.language_set(eng=True) i = 0 if eng == True: lang_name = 'английскому языку' src_etalon = 'https://dev.gamersbay.com/images/interface/icon/lang/flag--en.svg' time.sleep(1) while i < 20: time.sleep(2) row = self.driver.find_elements(*Locators.ORDER)[i] lang = row.find_element_by_css_selector('[alt="EN"]') src = lang.get_attribute('src') time.sleep(1) assert_equal(src, src_etalon, 'Язык не соотвествует фильтру') print('Заказ %d из 20 соответсвует сортировке по ' % (i+1) + lang_name) i += 1
def check_components_bosoter_no_oders(self): """Проверка компонентнов нового бустера""" welcome = self.driver.find_element(*Locators.WELCOME) GBtool.check_exists_by_css(self, css=welcome, name='Начать знакомство ') oders = self.driver.find_element(*Locators.ORDERS) GBtool.check_exists_by_css(self, css=oders, name='Блок топ бустеров') balance = self.driver.find_element(*Locators.BALANCE) GBtool.check_exists_by_css(self, css=balance, name='Блок баланс') faq = self.driver.find_element(*Locators.FAQ) GBtool.check_exists_by_css(self, css=faq, name='F.A.Q.')
def check_components_no_orders(self): """Проверка компонентов нового байера""" gb_tool = GBtool(self.driver) no_orders_block = Locators.NOORDERS_BLOCK gb_tool.check_exists_by_css(css=no_orders_block[1], name='Плашка первого заказа') orders_cat = Locators.ORDERS_CAT gb_tool.check_exists_by_css(css=orders_cat[1], name='Блок категорий заказа') orders_count = Locators.ORDERS_COUNT gb_tool.check_exists_by_css(css=orders_count[1], name='Счетчик заказов')
def check_components(self): """Проверка компонентов топ бустеров""" gb_tool = GBtool(self.driver) time.sleep(1) filter = Locators.FILTER gb_tool.check_exists_by_css(css=filter[1], name='выбор игры') menu = Locators.MENU gb_tool.check_exists_by_css(css=menu[1], name='Меню') orders_list = Locators.LIST gb_tool.check_exists_by_css(css=orders_list[1], name='Список заказов')
def check_components(self): """Проверка компонентов""" gb_tool = GBtool(self.driver) deposit_funds = self.driver.find_element(Locators.DEPOSIT_FUNDS) gb_tool.check_exists_by_css(css=deposit_funds, name='Блок внести средства') history = self.driver.find_element(Locators.HISTORY) gb_tool.check_exists_by_css(css=history, name='Блок история') balance = self.driver.find_element(Locators.BALANCE) gb_tool.check_exists_by_css(css=balance, name='Блок баланс')
def check_components_no_orders(self): """Проверка компонентов нового байера""" welcome = Locators.WELCOME GBtool.check_exists_by_css(self, css=welcome[1], name='Блок создания заказа') top_bst = Locators.TOP_BOOSTRS GBtool.check_exists_by_css(self, css=top_bst[1], name='Блок топ бустеров') balance = Locators.BALANCE GBtool.check_exists_by_css(self, css=balance[1], name='Блок баланс') faq = Locators.FAQ GBtool.check_exists_by_css(self, css=faq[1], name='F.A.Q.')
def login(self, mail, password): """Авторизация""" time.sleep(1) login_btn = self.driver.find_element(*Locators.LOG_IN_BUTTON) time.sleep(1) login_btn.click() logging.info('Открытие окна авторизации...') # pop_up = self.driver.find_element(*Locators.POP_UP) pop_up = Locators.POP_UP GBtool.check_exists_by_css(self, css=pop_up[1], name='Окно авторизации') mail_lgn = self.driver.find_element(*Locators.MAIL_LOG_IN) time.sleep(1) mail_lgn.click() logging.debug('Ввод почты...') mail_lgn.send_keys(mail) psswrd = self.driver.find_element(*Locators.PASSWORD) psswrd.click() psswrd.send_keys(password) logging.info("Ввод пароля...") auth_btn = self.driver.find_element(*Locators.AUTH_BTN) auth_btn.click() logging.info('Авторизация...') time.sleep(1) # header = self.driver.find_element(*Locators.HEADER) header = Locators.HEADER time.sleep(1) GBtool.check_exists_by_css(self, css=header[1], name='Шапка после регистрации') logging.info('Авторизация прошла успрешно.')
def test_03_place_bid(self): """Работа кнопки кинуть ставку""" ordrs = OrderSearch(self.driver) gb_tools = GBtool(self.driver) gb_tools.go_to_tab_booster(search_orders=True) time.sleep(5) order = self.driver.find_elements(*Locators.ORDER)[0] show_more = order.find_element(*Locators.SHOW_MORE) place_bid = order.find_element(*Locators.PLACE_BID) show_more.click() gb_tools.check_exists_by_css(css='.btn--primary', name='сделать ставку') place_bid.click() bid = self.driver.find_element(*Locators.STAVOCHKA) gb_tools.check_exists_by_css(css='.bid', name='форма ставки')
def check_game(self): """Проверка сортировки по игре""" gb_tool = GBtool(self.driver) time.sleep(1) gm = 'World of Warcraft' gb_tool.select_a_game(gm) time.sleep(2) ttl = self.driver.find_element(*Locators.TITLE) ttl = ttl.text count = int(re.findall(r'\d+', ttl)[0]) etalon = 'https://dev.gamersbay.com/images/games/1/icons/icon.svg' i = 0 while i < count: time.sleep(2) order = self.driver.find_elements(*Locators.ORDER)[i] game_icon = order.find_element(*Locators.GAME_ICON) icon = game_icon.get_attribute('src') assert_equal(etalon, icon, 'не сошлось') print('Строка %d из %d соответсвует сортировке по ' % ((i + 1), count) + gm) i += 1
def test_02_sort(self): """Сортировка раздела""" gb_tool = GBtool(self.driver) top_boost = TopBoostPage(self.driver) gb_tool.goto_tab(top_boost=True) gb_tool.do_sort_by_game('World of Warcraft') top_boost.check_sort_by_service() top_boost.search_check('secondbooster')
def check_components_with_order(self): """Проверка компонентнов байера делавшего заказы""" time.sleep(3) notification = self.driver.find_element(*Locators.NOTIFICATIONS_LIST) GBtool.check_exists_by_css(self, css=notification, name='Блок уведомлений') balance = self.driver.find_element(*Locators.BALANCE) GBtool.check_exists_by_css(self, css=balance, name='Блок баланс') faq = self.driver.find_element(*Locators.FAQ) GBtool.check_exists_by_css(self, css=faq, name='F.A.Q.')
def check_sort_by_service(self): """Проверяет сортировку по услуге""" gb_tool = GBtool(self.driver) gb_tool.select_a_game('World of Warcraft') gb_tool.select_a_service() i = 0 while i < 20: ordritm = self.driver.find_elements(*Locators.ORDRITM)[i] name = ordritm.find_element(*Locators.NAME) name = name.text name = name[18:31] assert_equal(name, 'Powerleveling', 'не сошлось') print('Запись %d из 20 отсортирвоана по улсуге ' % (i+1) + name) i += 1 gb_tool.select_a_service()
def test_03_new_order(self): """Проверка работы кнопок создания заказа""" gb_tool = GBtool(self.driver) my_orders = My_oders(self.driver) constructor = Constructor(self.driver) gb_tool.goto_tab(my_orders=True) btn = my_orders.Locators.NEW_ORDER_BTN_LEFT(self.driver) btn = self.driver.find_element_by_css_selector(btn) btn.click() constructor.is_constructor_download() gb_tool.goto_tab(my_orders=True) btn2 = my_orders.Locators.NEW_ORDER_BTN_RIGHT(self.driver) btn2 = self.driver.find_element_by_css_selector(btn2) btn2.click() constructor.is_constructor_download()