def check_deleted_user_name_on_activity_log_page(self, project_name):
     self.driver.go_to(DATA_WINNER_USER_ACTIVITY_LOG_PAGE)
     username = self.driver.find(
         by_xpath("//td[contains(.,'%s')]/../td[1]" % project_name)).text
     action = self.driver.find(
         by_xpath("//td[contains(.,'%s')]/../td[2]" % project_name)).text
     self.assertEqual("Deleted User", username)
     self.assertEqual("Created Project", action)
Example #2
0
 def get_option_by_index_for_multiple_choice_question(self, index):
     code = self.driver.find(
         by_xpath(CHOICE_XPATH_LOCATOR + "[" + str(index) + "]" +
                  CHOICE_S_XPATH_LOCATOR)).text
     text = self.driver.find_text_box(
         by_xpath(CHOICE_XPATH_LOCATOR + "[" + str(index) + "]" +
                  CHOICE_TB_XPATH_LOCATOR)).get_attribute("value")
     return {'code': code, 'text': text}
Example #3
0
 def _verify_users_added_to_project(self):
     self.driver.find(by_xpath("//a[text()='My Data Senders']")).click()
     registered_ds_names = [
         element.text for element in self.driver.find_elements_(
             by_xpath("//*[@id='datasender_table']/tbody/tr/td[2]"))
     ]
     self.driver.go_to(ACCOUNT_USERS)
     user_names = [
         element.text for element in self.driver.find_elements_(
             by_xpath("//*[@id='users_list']/table/tbody/tr/td[2]"))
     ]
 def _configure_given_contacts(self, recipient_name):
     """
     Function to select Group option To whom to send
     return self
     """
     self.driver.wait_for_element(
         UI_TEST_TIMEOUT,
         by_xpath("//input[@type='checkbox' and @value='%s']" %
                  recipient_name), True)
     self.driver.find(
         by_xpath("//input[@type='checkbox' and @value='%s']" %
                  recipient_name)).click()
     return self
 def get_entry_for_row_number(self, row_number):
     questionnaire_code = self.driver.find(by_xpath(".//*/tr[%d]/td[1]" % row_number)).text
     from_number = self.driver.find(by_xpath(".//*/tr[%d]/td[2]" % row_number)).text
     to_number = self.driver.find(by_xpath(".//*/tr[%d]/td[3]" % row_number)).text
     message = self.driver.find(by_xpath(".//*/tr[%d]/td[4]" % row_number)).text
     error = self.driver.find(by_xpath(".//*/tr[%d]/td[5]" % row_number)).text
     return {
         'questionnaire_code': questionnaire_code,
         'from_number': from_number,
         'to_number': to_number,
         'message': message,
         'error': error
     }
Example #6
0
    def configure_list_of_choices_type_question(self, question_data):
        """
        Function to select list of choices option and add the choices on the questionnaire page

        Args:
        question_data is to add the choices on the page

        return self
        """
        self.driver.find_drop_down(ANSWER_TYPE_DROPDOWN).set_selected(
            LIST_OF_CHOICES_OPTION)
        self.driver.find_element_by_id("choice_text0").clear()
        index = 1
        choices = fetch_(CHOICE, from_(question_data))
        for choice in choices:
            if index > 1:
                self.driver.find(ADD_CHOICE_LINK).click()
                box = self.driver.find_text_box(
                    by_id("choice_text%d" % (index - 1)))
                box.send_keys(choice)
            index += 1
        box = self.driver.find_text_box(
            by_xpath(CHOICE_XPATH_LOCATOR + "[1]" + CHOICE_TB_XPATH_LOCATOR))
        box.send_keys(choices[0])
        choice_type = fetch_(ALLOWED_CHOICE, from_(question_data))
        if ONLY_ONE_ANSWER == choice_type:
            self.driver.find_radio_button(ONLY_ONE_ANSWER_RB).click()
        elif MULTIPLE_ANSWERS == choice_type:
            self.driver.find_radio_button(MULTIPLE_ANSWER_RB).click()
        return self
 def _expect_empty_questionnaire_dialog_to_be_shown(self):
     warning_dialog = WarningDialog(
         self.driver,
         confirm_link=by_xpath(".//*[@id='no_questions_exists']/div/a"))
     message = warning_dialog.get_message()
     self.assertEqual(message, EMPTY_QUESTIONNAIRE_MSG)
     warning_dialog.confirm()
Example #8
0
    def get_list_of_choices_type_question(self):
        """
        Function to get the list of choices question option on the questionnaire page

        return question dict
        """
        question = dict()
        if self.driver.find_drop_down(ANSWER_TYPE_DROPDOWN).is_selected(
                LIST_OF_CHOICES_OPTION):
            question[TYPE] = LIST_OF_CHOICES
            # options_tbs = self.driver.find_elements_(by_xpath(CHOICE_XPATH_LOCATOR))
        options_tbs = self.driver.find_elements_(
            by_xpath(CHOICE_XPATH_LOCATOR + CHOICE_TB_XPATH_LOCATOR))
        count = options_tbs.__len__() + 1
        choices = []
        index = 1
        for options_tb in options_tbs:
            # while index < count:
            # choices.append(self.driver.find_text_box(by_xpath(CHOICE_XPATH_LOCATOR + "[" + str(index) + "]" + CHOICE_TB_XPATH_LOCATOR)).get_attribute("value"))
            # index = index + 1
            choices.append(options_tb.get_attribute("value"))
        question[CHOICE] = choices

        if self.driver.find_radio_button(ONLY_ONE_ANSWER_RB).is_selected():
            question[ALLOWED_CHOICE] = ONLY_ONE_ANSWER
        elif self.driver.find_radio_button(MULTIPLE_ANSWER_RB).is_selected():
            question[ALLOWED_CHOICE] = MULTIPLE_ANSWERS

        question[QUESTION] = self.get_question()
        question[CODE] = self.get_question_code()
        return question
Example #9
0
 def add_option_to_a_multiple_choice_question(self, new_choice_text):
     self.driver.find(by_id("add_choice")).click()
     question = self.get_list_of_choices_type_question()
     index = len(question[CHOICE])
     self.driver.find_text_box(
         by_xpath(CHOICE_XPATH_LOCATOR + "[" + str(index) + "]" +
                  CHOICE_TB_XPATH_LOCATOR)).enter_text(new_choice_text)
 def get_data_sender_email_by_mobile_number(self, mobile_number):
     """
    Function to select a data sender on all data sender page
     """
     email_element = self.driver.find(
         by_xpath(DATA_SENDER_EMAIL_BY_MOBILE_NUMBER_XPATH % mobile_number))
     return email_element.text
 def get_data_sender_email_by_id(self, data_sender_id):
     """
     Function to select a data sender on all data sender page
      """
     email_element = self.driver.find(
         by_xpath(DATA_SENDER_EMAIL_BY_UID_XPATH % data_sender_id))
     return email_element.text
 def select_a_data_sender_by_mobile_number(self, mobile_number):
     """
     Function to select a data sender on all data sender page
      """
     self.driver.find(
         by_xpath(DATA_SENDER_CHECK_BOX_BY_MOBILE_XPATH %
                  mobile_number)).click()
Example #13
0
    def navigate_to_submission_log_page(self, project_name):
        """
        Function to navigate to all data records page of the website

        Return All Data Records page
         """
        self.driver.find(by_xpath(All_DATA_RECORDS_LINK_XPATH % project_name)).click()
        return SubmissionLogPage(self.driver)
    def back_to_questionnaire_creation_page(self):
        from pages.createprojectpage.questionnaire_creation_options_page import QuestionnaireCreationOptionsPage

        self.driver.find_element_by_id("back_to_create_options").click()
        QuestionnaireModifiedDialog(self.driver).ignore_changes()
        self.driver.wait_for_element(
            UI_TEST_TIMEOUT, by_xpath(".//*[@id='project_profile']/h5"), True)
        return QuestionnaireCreationOptionsPage(self.driver)
 def revert_to_original(self):
     elements_ = self.driver.find_elements_(REVERT_TO_ORIGINAL_LINK)
     print(elements_.__len__())
     for i, r in enumerate(elements_):
         r.click()
         self.driver.wait_for_element(
             UI_TEST_TIMEOUT,
             by_xpath(LAST_WARNING_MESSAGE_LOCATOR % (i + 1)), True)
Example #16
0
    def navigate_to_data_analysis_page(self, project_name):
        """
        Function to navigate to data analysis page of the website

        Return Data Analysis page
         """
        self.driver.find(by_xpath(ANALYSIS_LINK_XPATH % project_name)).click()
        return DataAnalysisPage(self.driver)
 def all_recipients(self, column):
     div = by_xpath(".//*[@id='datasender_table_wrapper']/div[8]")
     div_text = self.driver.find(div).text
     number_of_data_senders = int((div_text.split(' '))[2])
     poll_recipients = []
     for i in range(1, number_of_data_senders + 1):
         poll_recipients.append(self.get_cell_value(column, i))
     return poll_recipients
 def has_DS_received_sms(self, recipent, row, column):
     self.select_element(POLL_TAB)
     self.select_element(POLL_SMS_ACCORDIAN)
     self.driver.wait_for_element(UI_TEST_TIMEOUT, by_id("poll_sms_table"),
                                  True)
     recipient_name = self.driver.find(
         by_xpath(".//*[@id='poll_sms_table']/tbody/tr[%s]/td[%s]" %
                  (row, column))).text
     return recipent in recipient_name
Example #19
0
 def delete_submission(self):
     analysis_page = self.project_overview_page.navigate_to_data_page()
     submission_log_page = analysis_page.navigate_to_all_data_record_page()
     self.driver.wait_until_element_is_not_present(20, by_css("loading"))  # wait for table to load
     self.driver.find(by_xpath("//table[@class='submission_table']//td[text()='admin1']/../td/input")).click()
     # submission_log_page.check_submission_by_row_number(1)
     submission_log_page.choose_on_dropdown_action(DELETE_BUTTON)
     warning_dialog = WarningDialog(self.driver)
     warning_dialog.confirm()
Example #20
0
 def delete_user(self, username):
     self.global_navigation.sign_out()
     login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     self.driver.find(by_xpath("//td[contains(.,'%s')]/../td/input" % username)).click()
     all_users_page.select_delete_action(confirm=True)
     self.driver.wait_for_element(UI_TEST_TIMEOUT, by_css("span.loading"), True)
     self.driver.wait_until_modal_dismissed()
     message = all_users_page.get_message()
     self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)
Example #21
0
    def get_question_link_text(self, question_number):
        """
        Function to get the text of the question link

        Args:
        question_number is index number of the question

        Return link text
        """
        question_locator = by_xpath("//ol/li[%s]/a" % (question_number))
        return self.driver.find(question_locator).text
Example #22
0
 def get_questions_list_for_selected_project(self, project_name):
     create_by_template_option = self.driver.find(
         by_id("copy_existing_questionnaire"))
     create_by_template_option.click()
     self.driver.wait_for_element(UI_TEST_TIMEOUT,
                                  by_id("existing_questionnaires"), True)
     self.driver.find(
         by_xpath(
             ".//*[@id='existing_questionnaires']/div/div[text()='%s']" %
             project_name)).click()
     self.driver.wait_for_element(UI_TEST_TIMEOUT,
                                  by_id("existing_questions"), True)
     questions_list = self.driver.find_elements_(
         by_css('#existing_questions li'))
     return [question.text for question in questions_list]
Example #23
0
 def test_should_update_user_name_when_edited_from_datasender_page(self):
     add_user_page = self.all_users_page.navigate_to_add_user()
     add_user_page.add_user_with(EDIT_USER_DATA)
     self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE)
     all_datasenders_page = AllDataSendersPage(self.driver)
     all_datasenders_page.search_with(EDIT_USER_DATA.get('username'))
     self.driver.find(all_datasenders_page.get_checkbox_selector_for_datasender_row(1)).click()
     all_datasenders_page.select_edit_action()
     EDIT_DETAILS = {"name": "New testUser",
                     "mobile_number": EDIT_USER_DATA.get("mobile_phone"),
                     "commune": "Madagascar",
                     "gps": "-21.7622088847 48.0690991394"}
     AddDataSenderPage(self.driver).enter_data_sender_details_from(EDIT_DETAILS).navigate_to_datasender_page()
     self.driver.go_to(ALL_USERS_URL)
     self.all_users_page = AllUsersPage(self.driver)
     element = self.driver.find(by_xpath(NAME_COLUMN % EDIT_USER_DATA.get("username")))
     self.assertEquals(EDIT_DETAILS.get("name"),element.text)
Example #24
0
 def test_warning_message_should_come_while_activating_a_poll_when_another_poll_is_active(
         self):
     poll_title_1 = self.create_questionnaire_page.set_poll_questionnaire_title(
         "poll_questionnaire", generate_random=True)
     self.poll_questionnaire_page.select_broadcast_option()
     self.poll_questionnaire_page.click_create_poll()
     self.poll_questionnaire_page.deactivate_poll()
     self.global_navigation.navigate_to_dashboard_page(
     ).navigate_to_create_project_page().select_poll_questionnaire_option()
     poll_title_2 = self.create_questionnaire_page.set_poll_questionnaire_title(
         "poll_questionnaire", generate_random=True)
     self.poll_questionnaire_page.select_broadcast_option()
     self.poll_questionnaire_page.click_create_poll()
     self.global_navigation.navigate_to_all_data_page()
     previous_poll = by_xpath(FIRST_CREATED_POLL_XPATH % poll_title_1)
     self.driver.find(previous_poll).click()
     self.poll_questionnaire_page.activate_poll()
     self.assertTrue(
         self.poll_questionnaire_page.is_another_poll_active(poll_title_2))
     self.driver.find(ACTIVE_POLL_NAME).click()
LOCATOR = "locator"
BY = "by"

REGISTER_SENDER_LINK = by_css("a[class~='add_subject_link']")
DATA_SENDER_CHECK_BOX_BY_MOBILE_XPATH = "//tr/td[6][text()='%s']/../td[1]/input"
DATA_SENDER_EMAIL_TD_BY_MOBILE_XPATH = "//tr/td[6][text()='%s']/../td[7]"
DATA_SENDER_CHECK_BOX_BY_UID_XPATH = "//input[@type='checkbox' and @value='%s']"
PROJECT_CB_XPATH = "//div[contains(@class,'ui-dialog') and contains(@style, 'block')]/div/ul[@id='all_projects']/li[text()='%s']/input"
ACTION_DROP_DOWN = by_css(".btn.dropdown-toggle.action")
PROJECT_NAME_LABEL_XPATH = "//input[@value='%s']/../../td[9]"
UID_LABEL_BY_MOBILE_XPATH = "//tr/td[7][text()='%s']/../td[2]"
DATA_SENDER_DEVICES = "//input[@value='%s']/../../td[8]/img"
WEB_USER_BLOCK_EMAIL = by_css("div#web_user_block input.ds-email")
GIVE_ACCESS_LINK = by_id('web_user_button')

CANCEL_LINK = by_xpath("//div[contains(@class,'ui-dialog') and contains(@style, 'block')]/div/a[@id='cancel_link']")
CONFIRM_BUTTON = by_xpath("//div[contains(@class,'ui-dialog') and contains(@style, 'block')]/div/a[text()='Confirm']")
DELETE_BUTTON = by_css("a#ok_button")

ERROR_MESSAGE_LABEL = by_css("div#error.message-box")
SUCCESS_MESSAGE_LABEL = by_xpath("//div[contains(@class,'success-message-box') and not(contains(@class,'none'))]")
DELETE_SUCCESS_MESSAGE = by_xpath("//div[contains(@class,'success-message-box') and not(contains(@class,'none'))]")
DATASENDERS_IMPORT_LINK = by_id("a#import-datasenders")
CHECK_ALL_DS_USER = by_css("input.is_user")
CHECKALL_DS_CB = by_xpath(".//*[@id='datasender_table']/thead/tr/th[1]/input")
ALL_DS_ROWS = by_css("#datasender_table")
NONE_SELECTED_LOCATOR = by_xpath(".//li[contains(@class,'none-selected')]")
ACTION_MENU = by_xpath(".//ul[contains(@class,'dropdown-menu')]")

ACTION_LI_LOCATOR = ".//a[contains(@class,'%s')]/.."
ACTION_LOCATOR = ".//a[contains(@class,'%s')]"
Example #26
0
LIMITED = "limited"
LIMIT = "limit"
WORD = "word"
MAX = "max"

NEW_PROJECT_DATA = {'project_name': "new project ", GEN_RANDOM: True}

SELECTED_TEMPLATE_NAME = u'Livestock Census'
SELECTED_TEMPLATE_QUESTIONS = [
    u'Date of visit', u'Province', u'District', u'Name of location visited',
    u'Type of Production', u'Number of Bulls', u'Number of Cows',
    u'Number of Heifers', u'Number of Calves', u'Number of Oxen',
    u'Number of total cattle', u'Number of Sheep', u'Number of Goats',
    u'Number of Donkeys', u'Number of Horses', u'Number of Poultry'
]
BLANK_QUESTIONNAIRE_SELECTION_ACCORDION = "#questionnaire_types .questionnaire_type_header #create_blank"
POLL_QUESTIONNAIRE_SELECTION_ACCORDION = "#questionnaire_types .questionnaire_type_header #create_poll"
SELECT_USING_TEMPLATE_ACCORDION = "#questionnaire_types .questionnaire_type_header #create_template"
AJAX_LOADER_HORIZONTAL = by_css('.ajax-loader-horizontal')
AJAX_LOADER = by_css('.ajax-loader')
TEMPLATE_CATEGORY_ACCORDION = by_css(
    '#questionnaire_template .questionnaire_data')
TEMPLATE_NAME_DIV = by_xpath(
    ".//*[@id='questionnaire_template']//*[text()='livestock census']")
SELECTED_TEMPLATE_QUESTIONS_DIV = by_css(
    '#questionnaire_template_section .selected_questions')
TEMPLATE_NAME_HEADER = by_css(
    '#questionnaire_template_section .project-name-header')
TEMPLATE_QUESTIONS = by_css(
    '#questionnaire_template_section .selected_questions>div>ol>li')
Example #27
0
ORGANIZATION_COUNTRY = 'organization_country'
ORGANIZATION_ZIPCODE = 'organization_zipcode'
ORGANIZATION_OFFICE_PHONE = 'organization_office_phone'
ORGANIZATION_WEBSITE = 'organization_website'
TITLE = 'title'
FIRST_NAME = 'first_name'
LAST_NAME = 'last_name'
EMAIL = 'email'
REGISTRATION_PASSWORD = '******'
REGISTRATION_CONFIRM_PASSWORD = '******'
WIRE_TRANSFER = 'wire_transfer'
PAY_MONTHLY = 'pay_monthly'
ERROR_MESSAGE = 'message'
ADMIN_MOBILE_NUMBER = "mobile_phone"
ORGANIZATION_SECTOR_DROP_DOWN_LIST = by_css("select#id_organization_sector")
ABOUT_DATAWINNERS_BOX = by_xpath(
    '//div[@class="grid_7 right_hand_section alpha omega about_datawinners"')
AGREE_TERMS = "agree-terms"

#Registration Page Data for Successful Registration Page
REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION = {
    ORGANIZATION_NAME: u"ÑGÓ 001",
    ORGANIZATION_SECTOR: u"PublicHealth",
    ORGANIZATION_ADDRESS: u"Address Line öne",
    ORGANIZATION_CITY: u"Pünë",
    ORGANIZATION_STATE: u"Máharashtra",
    ORGANIZATION_COUNTRY: u"IN",
    ORGANIZATION_ZIPCODE: u"411028",
    ORGANIZATION_OFFICE_PHONE: u"0123456789",
    ORGANIZATION_WEBSITE: u"http://ngo001.com",
    TITLE: u"Mr",
    FIRST_NAME: u"Mickey",
Example #28
0
 def navigate_to_my_data_senders_page(self, project_name):
     self.driver.find(
         by_xpath("//a[@class='project-id-class' and text()='%s']" %
                  project_name)).click()
     return ProjectOverviewPage(self.driver).navigate_to_datasenders_page()
 def get_cell_value(self, column, row):
     cell = by_xpath(".//*[@id='datasender_table']/tbody/tr[%s]/td[%s]" %
                     (row + 1, column + 1))
     self.driver.wait_for_element(UI_TEST_TIMEOUT, cell, True)
     return self.driver.find(cell).text
Example #30
0
 def navigate_to_web_submission_page(self, project_name):
     self.driver.find(by_xpath(WEB_SUBMISSION_LINK_XPATH %
                               project_name)).click()
     return WebSubmissionPage(self.driver)