def successfully_create_project_with(self, project_data): """ Function to enter and save the data on set up project page Args: registration_data is data to fill in the different fields like first name, last name, telephone number and commune Return self """ project_name = fetch_(PROJECT_NAME, from_(project_data)) gen_ramdom = fetch_(GEN_RANDOM, from_(project_data)) if gen_ramdom: project_name = project_name + generateId() self.driver.find_text_box(PROJECT_NAME_TB).enter_text(project_name) self.driver.find_text_box(PROJECT_BACKGROUND_TB).enter_text( fetch_(PROJECT_BACKGROUND, from_(project_data))) # Selecting radio button according to given option project_type = fetch_(PROJECT_TYPE, from_(project_data)) if project_type == "survey": self.driver.find(SURVEY_PROJECT_RB).click() elif project_type == "public information": self.driver.find(PUBLIC_INFORMATION_RB).click() report_type = fetch_(REPORT_TYPE, from_(project_data)) if report_type == "data sender work": self.driver.find(DATA_SENDER_RB).click() elif report_type == "other subject": self.driver.find(OTHER_SUBJECT_RB).click() subject = fetch_(SUBJECT, from_(project_data)) if len(subject) != 0: self.driver.execute_script( "document.getElementById('id_entity_type').value = '" + subject + "';") # Selecting check box according to given options devices = fetch_(DEVICES, from_(project_data)).split(",") comm_utils = CommonUtilities(self.driver) # Selecting and Deselecting SMS checkbox for devices as per given option if "sms" in devices: if not (comm_utils.is_element_present(SMS_CB_CHECKED)): self.driver.find(SMS_CB).toggle() elif comm_utils.is_element_present(SMS_CB_CHECKED): self.driver.find(SMS_CB).toggle() # Selecting and Deselecting Smart phone checkbox for devices as per # given option # if "smartphone" in devices: # if not(comm_utils.is_element_present(SMART_PHONE_CB_CHECKED)): # self.driver.find(SMART_PHONE_CB).toggle() # elif comm_utils.is_element_present(SMART_PHONE_CB_CHECKED): # self.driver.find(SMART_PHONE_CB).toggle() # #Selecting and Deselecting Web checkbox for devices as per given option # if "web" in devices: # if not(comm_utils.is_element_present(WEB_CB_CHECKED)): # self.driver.find(WEB_CB).toggle() # elif comm_utils.is_element_present(WEB_CB_CHECKED): # self.driver.find(WEB_CB).toggle() self.driver.find(SAVE_CHANGES_BTN).click() return CreateSubjectQuestionnairePage(self.driver)
def successfully_create_project_with(self, project_data): """ Function to enter and save the data on set up project page Args: registration_data is data to fill in the different fields like first name, last name, telephone number and commune Return self """ project_name = fetch_(PROJECT_NAME, from_(project_data)) gen_ramdom = fetch_(GEN_RANDOM, from_(project_data)) if gen_ramdom: project_name = project_name + generateId() self.driver.find_text_box(PROJECT_NAME_TB).enter_text(project_name) self.driver.find_text_box(PROJECT_BACKGROUND_TB).enter_text( fetch_(PROJECT_BACKGROUND, from_(project_data))) # Selecting radio button according to given option project_type = fetch_(PROJECT_TYPE, from_(project_data)) if project_type == "survey": self.driver.find(SURVEY_PROJECT_RB).click() elif project_type == "public information": self.driver.find(PUBLIC_INFORMATION_RB).click() report_type = fetch_(REPORT_TYPE, from_(project_data)) if report_type == "data sender work": self.driver.find(DATA_SENDER_RB).click() elif report_type == "other subject": self.driver.find(OTHER_SUBJECT_RB).click() subject = fetch_(SUBJECT, from_(project_data)) if len(subject) != 0: self.driver.execute_script("document.getElementById('id_entity_type').value = '" + subject + "';") # Selecting check box according to given options devices = fetch_(DEVICES, from_(project_data)).split(",") comm_utils = CommonUtilities(self.driver) # Selecting and Deselecting SMS checkbox for devices as per given option if "sms" in devices: if not(comm_utils.is_element_present(SMS_CB_CHECKED)): self.driver.find(SMS_CB).toggle() elif comm_utils.is_element_present(SMS_CB_CHECKED): self.driver.find(SMS_CB).toggle() # Selecting and Deselecting Smart phone checkbox for devices as per # given option # if "smartphone" in devices: # if not(comm_utils.is_element_present(SMART_PHONE_CB_CHECKED)): # self.driver.find(SMART_PHONE_CB).toggle() # elif comm_utils.is_element_present(SMART_PHONE_CB_CHECKED): # self.driver.find(SMART_PHONE_CB).toggle() # #Selecting and Deselecting Web checkbox for devices as per given option # if "web" in devices: # if not(comm_utils.is_element_present(WEB_CB_CHECKED)): # self.driver.find(WEB_CB).toggle() # elif comm_utils.is_element_present(WEB_CB_CHECKED): # self.driver.find(WEB_CB).toggle() self.driver.find(SAVE_CHANGES_BTN).click() return CreateSubjectQuestionnairePage(self.driver)
def get_number_of_subject_for_entity_type(self, entity_type): commUtils = CommonUtilities(self.driver) if commUtils.is_element_present( by_xpath(SUBJECTS_INFO % entity_type.capitalize())): info = self.driver.find( by_xpath(SUBJECTS_INFO % entity_type.capitalize())).text return int(re.match(r'\d+', info).group(), 10) else: return False
def get_response_message(self): """ Function to fetch the success/error response message from flash label of the page Return success/error message """ comm_utils = CommonUtilities(self.driver) comm_utils.wait_for_element(10, FLASH_MSG_LABEL) return self.driver.find(FLASH_MSG_LABEL).text
def get_flash_message(self): """ Function to fetch the flash message from flash label of the add subject page Return message """ comm_utils = CommonUtilities(self.driver) comm_utils.wait_for_element(5, FLASH_MESSAGE_LABEL) return self.driver.find(FLASH_MESSAGE_LABEL).text
def open_subjects_table_for_entity_type(self, entity_type): commUtils = CommonUtilities(self.driver) if commUtils.is_element_present( by_xpath(SUBJECT_TYPE_LINK % entity_type.capitalize())): self.driver.find( by_xpath(SUBJECT_TYPE_LINK % entity_type.capitalize())).click() else: return False
def get_flash_message(self): """ Function to fetch the flash message from flash label of the register subject page Return message """ comm_utils = CommonUtilities(self.driver) comm_utils.wait_for_element(5, FLASH_MESSAGE_LABEL) return self.driver.find(FLASH_MESSAGE_LABEL).text
def check_subject_type_on_page(self, subject): """ Function to check the subject type on the all subject page of the website Return true or false """ commUtils = CommonUtilities(self.driver) if commUtils.is_element_present(by_xpath(SUBJECT_TYPE_LINK % subject)): return True else: return False
def get_success_message(self): """ Function to fetch the success message from label of the questionnaire page Return success message """ comm_utils = CommonUtilities(self.driver) if comm_utils.wait_for_element(10, SUCCESS_MESSAGE_LABEL): return self.driver.find(SUCCESS_MESSAGE_LABEL).text else: return "Success message not appeared on the page."
def get_error_message(self): """ Function to fetch the error messages from error label of the login page Return error message """ error_message = "" comm_utils = CommonUtilities(self.driver) comm_utils.wait_for_element(10,ERROR_MESSAGE_LABEL) locators = self.driver.find_elements_(ERROR_MESSAGE_LABEL) if locators: for locator in locators: error_message = error_message + locator.text return error_message.replace("\n", " ")
def create_project_with(self, project_data): """ Function to enter and save the data on set up project page Args: registration_data is data to fill in the different fields like first name, last name, telephone number and commune Return self """ self.driver.find_text_box(PROJECT_NAME_TB).enter_text( fetch_(PROJECT_NAME, from_(project_data))) self.driver.find_text_box(PROJECT_BACKGROUND_TB).enter_text( fetch_(PROJECT_BACKGROUND, from_(project_data))) # Selecting radio button according to given option project_type = fetch_(PROJECT_TYPE, from_(project_data)) if project_type == "survey": self.driver.find(SURVEY_PROJECT_RB).click() elif project_type == "public information": self.driver.find(PUBLIC_INFORMATION_RB).click() # Selecting check box according to given options devices = fetch_(DEVICES, from_(project_data)).split(",") comm_utils = CommonUtilities(self.driver) # Selecting and Deselecting SMS checkbox for devices as per given option if "sms" in devices: if not (comm_utils.is_element_present(SMS_CB_CHECKED)): self.driver.find(SMS_CB).click() elif comm_utils.is_element_present(SMS_CB_CHECKED): self.driver.find(SMS_CB).click() # Selecting and Deselecting Smart phone checkbox for devices as per # given option # if "smartphone" in devices: # if not(comm_utils.is_element_present(SMART_PHONE_CB_CHECKED)): # self.driver.find(SMART_PHONE_CB).click() # elif comm_utils.is_element_present(SMART_PHONE_CB_CHECKED): # self.driver.find(SMART_PHONE_CB).click() # #Selecting and Deselecting Web checkbox for devices as per given option # if "web" in devices: # if not(comm_utils.is_element_present(WEB_CB_CHECKED)): # self.driver.find(WEB_CB).click() # elif comm_utils.is_element_present(WEB_CB_CHECKED): # self.driver.find(WEB_CB).click() self.driver.find(SAVE_CHANGES_BTN).click() return self
def create_project_with(self, project_data): """ Function to enter and save the data on set up project page Args: registration_data is data to fill in the different fields like first name, last name, telephone number and commune Return self """ self.driver.find_text_box(PROJECT_NAME_TB).enter_text( fetch_(PROJECT_NAME, from_(project_data))) self.driver.find_text_box(PROJECT_BACKGROUND_TB).enter_text( fetch_(PROJECT_BACKGROUND, from_(project_data))) # Selecting radio button according to given option project_type = fetch_(PROJECT_TYPE, from_(project_data)) if project_type == "survey": self.driver.find(SURVEY_PROJECT_RB).click() elif project_type == "public information": self.driver.find(PUBLIC_INFORMATION_RB).click() # Selecting check box according to given options devices = fetch_(DEVICES, from_(project_data)).split(",") comm_utils = CommonUtilities(self.driver) # Selecting and Deselecting SMS checkbox for devices as per given option if "sms" in devices: if not(comm_utils.is_element_present(SMS_CB_CHECKED)): self.driver.find(SMS_CB).click() elif comm_utils.is_element_present(SMS_CB_CHECKED): self.driver.find(SMS_CB).click() # Selecting and Deselecting Smart phone checkbox for devices as per # given option # if "smartphone" in devices: # if not(comm_utils.is_element_present(SMART_PHONE_CB_CHECKED)): # self.driver.find(SMART_PHONE_CB).click() # elif comm_utils.is_element_present(SMART_PHONE_CB_CHECKED): # self.driver.find(SMART_PHONE_CB).click() # #Selecting and Deselecting Web checkbox for devices as per given option # if "web" in devices: # if not(comm_utils.is_element_present(WEB_CB_CHECKED)): # self.driver.find(WEB_CB).click() # elif comm_utils.is_element_present(WEB_CB_CHECKED): # self.driver.find(WEB_CB).click() self.driver.find(SAVE_CHANGES_BTN).click() return self
def get_error_message(self): """ Function to fetch the error messages from error label of the register reporter page Return error message """ error_message = "" comm_utils = CommonUtilities(self.driver) locator = comm_utils.is_element_present(PROJECT_NAME_ERROR_MSG_LABEL) if locator: error_message = error_message + "Name " + locator.text # locator = comm_utils.is_element_present(PROJECT_TYPE_ERROR_MSG_LABEL) # if locator: # error_message = error_message + "Project Type " + locator.text # locator = comm_utils.is_element_present(QUESTIONNAIRE_ABOUT_MSG_LABEL) # if locator: # error_message = error_message + "Activity Report Type " + locator.text return error_message == "" and "No error message on the page" or error_message
def create_project_with(self, project_data): """ Function to enter and save the data on set up project page Args: project_data is data to fill in the different fields Return self """ self.type_project_name(project_data) self.type_project_description(project_data) light_box = self.select_report_type(project_data) comm_util = CommonUtilities(self.driver) if comm_util.is_element_present(TITLE_LABEL): light_box.continue_change() self.set_subject(project_data) if comm_util.is_element_present(TITLE_LABEL): light_box.continue_change() return self
def get_error_message(self): """ Function to fetch the error messages from error label of the register reporter page Return error message """ error_message = "" comm_utils = CommonUtilities(self.driver) locator = comm_utils.is_element_present(PROJECT_NAME_ERROR_MSG_LABEL) if locator: error_message = error_message + "Name " + locator.text locator = comm_utils.is_element_present(PROJECT_TYPE_ERROR_MSG_LABEL) if locator: error_message = error_message + "Project Type " + locator.text locator = comm_utils.is_element_present(QUESTIONNAIRE_ABOUT_MSG_LABEL) if locator: error_message = error_message + "Activity Report Type " + locator.text return error_message == "" and "No error message on the page" or error_message
def description_has_error(self): comm_util = CommonUtilities(self.driver) if comm_util.is_element_present(PROJECT_DESCRIPTION_MSG): return True return False
def registration_success_message(self): com_util = CommonUtilities(self.driver) com_util.wait_for_element(15, WELCOME_MESSAGE_LI) success_message = self.driver.find(WELCOME_MESSAGE_LI).text return success_message
def click_checkall_checkbox_for_entity_type(self, entity_type): commUtils = CommonUtilities(self.driver) if commUtils.is_element_present(by_css(CHECKALL_CB % entity_type)): self.driver.find(by_css(CHECKALL_CB % entity_type)).click() return True return False
def has_all_failed_submission_link(self): comm_util = CommonUtilities(self.driver) if comm_util.is_element_present(by_css(ALL_FAILED_SUBMISSION_LINK)): return True return False
def got_redistribute_questionnaire_message(self): comm_utils = CommonUtilities(self.driver) locator = comm_utils.is_element_present( INFORM_DATASENDERS_OK_BUTTON_BY_CSS) if locator and locator.is_displayed(): locator.click()