def getValue_LangAttribute(self, expected_value): """ :param expected_value: EN or ES :return: True if expected_value == value of the lang-attribute of the <html>-tag """ if expected_value.lower() == 'es': try: waits.wait_title(self.driver, MainPageLocators.TITLE_ES) waits.wait_visibility(self.driver, MainPageLocators.HTML_TAG) html_tag = self.driver.find_element(*MainPageLocators.HTML_TAG) lang_value = html_tag.get_attribute('lang') self.log.info( 'Value of the attribute @lang = {}'.format(lang_value)) if lang_value.lower() == expected_value.lower(): self.log.info( 'Expected value <{}> for property @lang for tag <html> found' .format(expected_value)) return True except: self.log.error( 'Expected value <{}> for property @lang for tag <html> NOT found' .format(expected_value)) return False elif expected_value.lower() == 'en': try: waits.wait_title(self.driver, MainPageLocators.TITLE_EN) waits.wait_visibility(self.driver, MainPageLocators.HTML_TAG) html_tag = self.driver.find_element(*MainPageLocators.HTML_TAG) lang_value = html_tag.get_attribute('lang') self.log.info( 'Value of the attribute @lang = {}'.format(lang_value)) if lang_value.lower() == expected_value.lower(): self.log.info( 'Expected value <{}> for property @lang for tag <html> found' .format(expected_value)) return True except: self.log.error( 'Expected value <{}> for property @lang for tag <html> NOT found' .format(expected_value)) return False else: self.log.error( 'Expected value is not expected'.format(expected_value)) return False
def size_element(self, element): # DIV_LIST = [HEADER_DIV, NAVIGATION_DIV, CONTACT_DIV, FOOTER_DIV, COPYRIGHT_DIV if element == 'HEADER_DIV': waits.wait_visibility(self.driver, MainPageLocators.HEADER_DIV) return self.driver.find_element( *MainPageLocators.HEADER_DIV).size['width'] > 0 elif element == 'NAVIGATION_DIV': waits.wait_visibility(self.driver, MainPageLocators.NAVIGATION_DIV) return self.driver.find_element( *MainPageLocators.NAVIGATION_DIV).size['width'] > 0 elif element == 'CONTACT_DIV': waits.wait_visibility(self.driver, MainPageLocators.CONTACT_DIV) return self.driver.find_element( *MainPageLocators.CONTACT_DIV).size['width'] > 0 elif element == 'FOOTER_DIV': waits.wait_visibility(self.driver, MainPageLocators.FOOTER_DIV) return self.driver.find_element( *MainPageLocators.FOOTER_DIV).size['width'] > 0 elif element == 'COPYRIGHT_DIV': waits.wait_visibility(self.driver, MainPageLocators.COPYRIGHT_DIV) return self.driver.find_element( *MainPageLocators.COPYRIGHT_DIV).size['width'] > 0
def get_control_messages(self): waits.wait_visibility(self.driver, MainPageLocators.CONTROL_MESSAGE) messages_list = self.driver.find_elements( *MainPageLocators.CONTROL_MESSAGE) self.log.info([message.text for message in messages_list]) return messages_list
def get_menu_destination_options(self): menu = self.get_hint_destination waits.wait_visibility(self.driver, MainPageLocators.LI_TAGS) return menu.find_elements(*MainPageLocators.LI_TAGS)
def get_hint_destination(self): waits.wait_visibility(self.driver, MainPageLocators.HINT_DESTINATION) return self.driver.find_element(*MainPageLocators.HINT_DESTINATION)
def get_hint_depart(self): waits.wait_visibility(self.driver, MainPageLocators.HINT_DEPART) return self.driver.find_element(*MainPageLocators.HINT_DEPART)
def get_book_element(self): waits.wait_visibility(self.driver, MainPageLocators.BOOK_ELEMENT) return self.driver.find_element(*MainPageLocators.BOOK_ELEMENT)
def get_destination_input(self): waits.wait_visibility(self.driver, MainPageLocators.DESTINATION_INPUT) return self.driver.find_element(*MainPageLocators.DESTINATION_INPUT)
def get_depart_input(self): waits.wait_visibility(self.driver, MainPageLocators.DEPART_INPUT) return self.driver.find_element(*MainPageLocators.DEPART_INPUT)
def error_messages(self): waits.wait_visibility(self.driver, LoginPageLocators.ERROR_MESSAGE_LOCATOR) return self.driver.find_elements( *LoginPageLocators.ERROR_MESSAGE_LOCATOR)
def submit_button(self): waits.wait_visibility(self.driver, LoginPageLocators.SUBMIT) return self.driver.find_element(*LoginPageLocators.SUBMIT)
def password_field(self): waits.wait_visibility(self.driver, LoginPageLocators.PASSWORD_FIELD) return self.driver.find_element(*LoginPageLocators.PASSWORD_FIELD)
def username_field(self): waits.wait_visibility(self.driver, LoginPageLocators.USERNAME_FIELD) return self.driver.find_element(*LoginPageLocators.USERNAME_FIELD)