def verify_search_results(self): logger.info('Verifying the search results') results = self.find_many(*CAREER_JOBS_RESULT_ITEM) for item in results: actual_values = (self.get_attribute_value(item, 'data-location'), self.get_attribute_value(item, 'data-team')) assert actual_values == CAREER_JOBS_RESULT_ITEM_VALUES, log_exception( 'The search results are incorrect')
def verify_jobs_opened(self): logger.info('Verifying that the jobs section is opened') self.click(*CAREER_JOBS_LINK) assert self.get_text( *CAREER_JOBS_HEADING) == CAREER_JOBS_HEADING_TEXT, log_exception( 'The heading text is absent/wrong') assert self.get_text(*CAREER_JOBS_PARAGRAPH ) == CAREER_JOBS_PARAGRAPH_TEXT, log_exception( 'The paragraph text is absent/wrong')
def open(self, browser_name): logger.info(f'Starting the {browser_name}') if browser_name == 'firefox': self.driver = webdriver.Firefox() elif browser_name == 'chrome': self.driver = webdriver.Chrome() else: raise ValueError( log_exception(f'The {browser_name} is not supported yet')) self.driver.maximize_window()
def perform_search(self): logger.info('Performing the search with filters: Istanbul + QA') self.click(*CAREER_JOBS_LOCATION_FILTER_ISTANBUL) self.click(*CAREER_JOBS_DEPARTMENT_FILTER_QA) self.find(*CAREER_JOBS_RESULTS_LIST)
def scroll_to_search(self): logger.info('Scrolling to the jobs search') self.scroll_to_element(self.find(*CAREER_JOBS_LINK))
def reload_page(self): logger.info('Reloading the page') self.browser.get(self.browser.current_url)
def get_title(self): logger.info('Getting the page title') return self.browser.title
def open_page(self, url): logger.info(f'Navigating to {url}') self.browser.get(url)
def verify_hp_opened(self): logger.info('Verifying that the homepage is opened') assert self.get_title() == HOMEPAGE_TITLE, log_exception('The homepage was not opened')
def pretty_test_info(request): logger.info('*' * 10 + f'START TEST {str(request.node.name)}' + '*' * 10) yield logger.info('*' * 10 + f'END TEST {str(request.node.name)}' + '*' * 10)
def save_scr(self): logger.info('Saving the screenshot') self.driver.get_screenshot_as_png()
def close(self): logger.info('Closing the browser') self.driver.quit()
def read(self, env): logger.info(f'The environment is {env}. Getting the configuration') with open(self.__config, 'r') as stream: return yaml.safe_load(stream).get(env, None)
def after_request(response): """ Logging after every request. """ if response.status_code != 500: logger.info('%s %s %s %s %s', request.remote_addr, request.method, request.scheme, request.full_path, response.status) return response
def navigate_to_career(self): logger.info('Navigating to the Career page') self.click(*CAREER_MENU_LINK)