def test_empty_user_pass(
        self
    ):  # Test Case: A user who leaves both fields blank will see an error message.
        try:
            # Pre-Conditions
            self.preconditions()
            driver = self.driver
            f.write("test_empty_user_pass: "******"\n")

            # Test Step 1: Attempting to Login Results in Empty User and Password Error
            step = 1
            driver.find_element_by_xpath("//button[@type='submit']").click()
            Wait(driver, 10).until(
                EC.visibility_of_element_located(
                    (By.XPATH,
                     "//*[contains(text(), '* Require User Name')]")))
            Wait(driver, 10).until(
                EC.visibility_of_element_located(
                    (By.XPATH, "//*[contains(text(), '* Require Password')]")))
            if driver.find_element_by_xpath(
                    "//*[@id='contentarea']/div/router-view/div/div/div[1]/div/form/div[2]") \
                    .get_attribute("innerHTML") != "* Require User Name" and driver.find_element_by_xpath(
                    "//*[@id='contentarea']/div/router-view/div/div/div[1]/div/form/div[1]") \
                    .get_attribute("innerHTML") != "* Require User Name":
                f.write("   Test Step " + str(step) + " = " + "FAIL\n")
                step = None
                raise Exception()
            f.write("   Test Step " + str(step) + " = " + "PASS\n")
            f.write("Test Case Result = " + "PASS\n")
        except:
            if step is not None:
                f.write("   Test Step " + str(step) + " = " + "BLOCKED\n")
                f.write("Test Case Result = " + "BLOCKED\n")
            else:
                f.write("Test Case Result = " + "FAIL\n")
Example #2
0
 def wait_for_most_recent_job_success(self, async_job):
     app.logger.info(f'Waiting for {async_job} to succeed')
     time.sleep(2)
     tries = 1
     retries = util.get_long_timeout()
     success = By.XPATH, f'{JobsPage.job_most_recent_locator(async_job)[1]}//i[contains(@class, "light-green--text")]'
     failure = By.XPATH, f'{JobsPage.job_most_recent_locator(async_job)[1]}//i[contains(@class, "red--text")]'
     while tries <= retries:
         tries += 1
         try:
             if self.is_present(success):
                 app.logger.info('Job succeeded')
                 break
             else:
                 if self.is_present(JobsPage.ERROR_REDIRECT):
                     self.load_page()
                 Wait(self.driver,
                      1).until(ec.visibility_of_element_located(failure))
                 app.logger.info('Job failed')
                 break
         except TimeoutException:
             if tries == retries:
                 raise
             else:
                 time.sleep(1)
     Wait(self.driver, 1).until(ec.visibility_of_element_located(success))
Example #3
0
 def wait_for_element(self, locator, timeout):
     if util.get_xena_browser() == 'chrome':
         for entry in self.driver.get_log('browser'):
             if app.config['BASE_URL'] in entry:
                 app.logger.warning(f'Console error: {entry}')
     Wait(self.driver, timeout).until(
         method=ec.presence_of_element_located(locator),
         message=f'Failed wait for presence_of_element_located: {str(locator)}',
     )
     Wait(self.driver, timeout).until(
         method=ec.visibility_of_element_located(locator),
         message=f'Failed wait for visibility_of_element_located: {str(locator)}',
     )
Example #4
0
 def visible_menu_options(self):
     Wait(self.driver, xena.TIMEOUT_SHORT).until(
         ec.visibility_of_any_elements_located(
             SignUpPage.VISIBLE_MENU_OPTION))
     return [
         el.text for el in self.elements(SignUpPage.VISIBLE_MENU_OPTION)
     ]
Example #5
0
 def log_in(self):
     app.logger.info('Logging in to Canvas')
     self.hit_homepage()
     self.wait_for_element_and_type(CalNetPage.USERNAME_INPUT,
                                    'PLEASE LOG IN MANUALLY')
     Wait(self.driver, util.get_long_timeout()).until(
         ec.presence_of_element_located(CanvasPage.ADMIN_LINK))
Example #6
0
 def log_in_via_calnet(self):
     app.logger.info('Logging in to Kaltura')
     self.driver.get(f'{app.config["KALTURA_MEDIA_SPACE_URL"]}/user/login')
     self.wait_for_element_and_type(CalNetPage.USERNAME_INPUT,
                                    'PLEASE LOG IN MANUALLY')
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.presence_of_element_located(KalturaPage.LOG_OUT_LINK))
Example #7
0
 def wait_for_approvals_msg(self, string=None):
     Wait(self.driver, util.get_short_timeout()).until(
         ec.visibility_of_element_located(SignUpPage.APPROVALS_MSG))
     if string:
         app.logger.info(
             f'Visible: {self.element(SignUpPage.APPROVALS_MSG).get_attribute("innerText")}'
         )
         self.wait_for_text_in_element(SignUpPage.APPROVALS_MSG, string)
Example #8
0
    def provision_site(self, section, section_ids, site):
        epoch = int(time.time())
        site.name = f'{site.name} {epoch}'
        site.code = f'{site.code} {epoch}'
        app.logger.info(
            f'Creating a site named {site.code} for {section.code} sections {section_ids}'
        )

        # Load tool
        admin_id = app.config['CANVAS_ADMIN_ID']
        tool_id = app.config['CANVAS_SITE_CREATION_TOOL']
        self.driver.get(
            f'{app.config["CANVAS_BASE_URL"]}/users/{admin_id}/external_tools/{tool_id}'
        )
        Wait(self.driver, util.get_medium_timeout()).until(
            ec.presence_of_element_located(CanvasPage.junction_form_loc()))
        self.hide_canvas_footer()
        Wait(self.driver, util.get_medium_timeout()).until(
            ec.frame_to_be_available_and_switch_to_it(CanvasPage.FRAME))
        Wait(self.driver, util.get_medium_timeout()).until(
            ec.visibility_of_element_located(CanvasPage.CREATE_SITE_LINK))
        self.wait_for_element_and_click(CanvasPage.CREATE_SITE_LINK)

        # Select sections by CCN
        self.wait_for_element(CanvasPage.SWITCH_TO_CCN_BUTTON,
                              util.get_long_timeout())
        self.wait_for_page_and_click(CanvasPage.SWITCH_TO_CCN_BUTTON)
        self.wait_for_page_and_click(CanvasPage.term_loc())
        self.wait_for_element_and_type(CanvasPage.CCN_TEXT_AREA,
                                       ', '.join(section_ids))
        self.wait_for_page_and_click(CanvasPage.REVIEW_CCNS_BUTTON)
        self.wait_for_page_and_click(CanvasPage.NEXT_BUTTON)

        # Name and create site; store site ID
        self.scroll_to_bottom()
        self.wait_for_element_and_type(CanvasPage.SITE_NAME_INPUT,
                                       f'{site.name}')
        self.wait_for_element_and_type(CanvasPage.SITE_ABBREV_INPUT,
                                       f'{site.code}')
        self.wait_for_page_and_click(CanvasPage.CREATE_SITE_BUTTON)
        Wait(self.driver,
             util.get_long_timeout()).until(ec.url_contains('/courses/'))
        parts = self.driver.current_url.split('/')
        site.site_id = [i for i in parts if i][-1]
        app.logger.info(f'Site {site.code} ID is {site.site_id}')
        section.sites.append(site)
Example #9
0
 def delete_site(self, site_id):
     app.logger.info(f'Deleting course site ID {site_id}')
     self.driver.get(
         f'{app.config["CANVAS_BASE_URL"]}/courses/{site_id}/confirm_action?event=delete'
     )
     self.wait_for_page_and_click_js(CanvasPage.DELETE_COURSE_BUTTON)
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.visibility_of_element_located(CanvasPage.DELETE_COURSE_SUCCESS))
Example #10
0
 def load_my_media_tool(self, site):
     app.logger.info(f'Loading My Media on site ID {site.site_id}')
     tool_id = app.config['CANVAS_MY_MEDIA_TOOL']
     self.driver.get(
         f'{app.config["CANVAS_BASE_URL"]}/courses/{site.site_id}/external_tools/{tool_id}'
     )
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.presence_of_element_located(CanvasPage.kaltura_form_loc()))
Example #11
0
 def load_site(self, site_id):
     app.logger.info(f'Loading course site ID "{site_id}"')
     self.driver.get(f'{app.config["CANVAS_BASE_URL"]}/courses/{site_id}')
     Wait(self.driver,
          util.get_medium_timeout()).until(ec.url_contains(site_id))
     if self.is_present(CanvasPage.ACCEPT_INVITE_BUTTON):
         self.wait_for_element_and_click(CanvasPage.ACCEPT_INVITE_BUTTON)
         self.when_not_present(CanvasPage.ACCEPT_INVITE_BUTTON)
Example #12
0
 def open_printable_schedule(self):
     app.logger.info('Opening the printable room schedule')
     self.wait_for_page_and_click_js(RoomPrintablePage.PRINT_SCHED_LINK)
     time.sleep(1)
     windows = self.window_handles()
     self.switch_to_last_window(windows)
     Wait(self.driver, util.get_short_timeout()).until(
         ec.visibility_of_element_located(RoomPrintablePage.ROOM_NAME))
Example #13
0
 def is_tool_configured(self, tool_id):
     self.driver.get(
         f'{app.config["CANVAS_BASE_URL"]}/api/v1/accounts/{app.config["CANVAS_ROOT_ACCOUNT"]}/external_tools/{tool_id}'
     )
     loc = By.XPATH, '//pre'
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.presence_of_element_located(loc))
     json_string = self.element(loc).text
     return True if f'{app.config["KALTURA_TOOL_URL"]}' in json_string else False
 def preconditions(self):
     # Pre-Conditions
     driver = self.driver
     driver.get("https://www.votervoice.net/AdminSite/Login"
                )  # opens browser to Login page
     driver.set_window_size(
         1200, 988)  # Sets the size of the window to specified dimensions
     Wait(driver,
          10).until(EC.presence_of_element_located((By.NAME, "username")))
Example #15
0
def is_visible(browser, web_element):
    """Check if given web element is visible in given browser.
    """
    try:
        Wait(browser, WAIT_FRONTEND).until(EC.visibility_of(web_element))
    except TimeoutException:
        return False
    else:
        return True
Example #16
0
 def visible_menu_options(self):
     Wait(self.driver, app.config['TIMEOUT_SHORT']).until(
         method=ec.visibility_of_any_elements_located(
             DiabloPages.VISIBLE_MENU_OPTION),
         message=
         f'Failed visible_menu_options: {DiabloPages.VISIBLE_MENU_OPTION}',
     )
     return [
         el.text for el in self.elements(DiabloPages.VISIBLE_MENU_OPTION)
     ]
Example #17
0
 def log_in(self):
     app.logger.info('Logging in to Kaltura')
     self.driver.get(f'{app.config["KALTURA_MEDIA_SPACE_URL"]}/user/login')
     self.wait_for_element_and_type(KalturaPage.USERNAME_INPUT,
                                    app.config['XENA_KALTURA_USERNAME'])
     self.wait_for_element_and_type(KalturaPage.PASSWORD_INPUT,
                                    app.config['XENA_KALTURA_PASSWORD'])
     self.wait_for_element_and_click(KalturaPage.LOG_IN_BUTTON)
     Wait(self.driver, util.get_short_timeout()).until(
         ec.presence_of_element_located(KalturaPage.LOG_OUT_LINK))
Example #18
0
def is_active(browser, web_element):
    """Check if given web element is the active one in given browser.
    """
    try:
        Wait(browser, WAIT_FRONTEND).until(
            lambda s: web_element == s.switch_to.active_element)
    except TimeoutException:
        return False
    else:
        return True
Example #19
0
def page_with_header(selenium, browser_id, text):
    def header_with_text_presence(s):
        headers = s.find_elements_by_css_selector('h1, h2, h3, h4, h5')
        try:
            return any(map(lambda h: h.text == text, headers))
        except StaleElementReferenceException:
            return False

    driver = selenium[browser_id]
    Wait(driver, WAIT_BACKEND).until(header_with_text_presence)
Example #20
0
 def click_element(self, locator, addl_pause=None):
     self.hide_diablo_footer()
     sleep_default = app.config['CLICK_SLEEP']
     time.sleep(addl_pause or sleep_default)
     Wait(driver=self.driver, timeout=util.get_short_timeout()).until(
         method=ec.element_to_be_clickable(locator),
         message=f'Failed to click_element: {str(locator)}',
     )
     time.sleep(addl_pause or sleep_default)
     self.element(locator).click()
Example #21
0
 def masquerade_as(self, user, site_id=None):
     app.logger.info(f'Masquerading as Canvas ID {user.canvas_id}')
     self.driver.get(
         f'{app.config["CANVAS_BASE_URL"]}/users/{user.canvas_id}/masquerade'
     )
     self.wait_for_element_and_click(CanvasPage.MASQUERADE_LINK)
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.visibility_of_element_located(CanvasPage.STOP_MASQUERADE_LINK))
     if site_id:
         self.load_site(site_id)
Example #22
0
 def enable_job(self, async_job):
     app.logger.info(f'Making sure {async_job.value} is enabled')
     self.wait_for_jobs_table()
     if self.is_present(JobsPage.disabled_job_locator(async_job)):
         app.logger.info('Enabling job')
         self.element(JobsPage.disabled_job_locator(async_job)).click()
         Wait(self.driver, 2).until(
             ec.presence_of_element_located(
                 JobsPage.enabled_job_locator(async_job)))
     else:
         app.logger.info('Job is already enabled')
Example #23
0
 def delete_series(self, recording_schedule):
     app.logger.info('Clicking the delete button')
     self.load_event_edit_page(recording_schedule.series_id)
     self.wait_for_element(KalturaPage.SERIES_DELETE_BUTTON,
                           util.get_medium_timeout())
     self.scroll_to_bottom()
     self.wait_for_page_and_click(KalturaPage.SERIES_DELETE_BUTTON, 3)
     self.wait_for_element_and_click(
         KalturaPage.SERIES_DELETE_CONFIRM_BUTTON)
     redirect_url = f'{app.config["KALTURA_MEDIA_SPACE_URL"]}/calendar/index/calendar/'
     Wait(self.driver,
          util.get_short_timeout()).until(ec.url_to_be(redirect_url))
    def test_invalid_login(
        self
    ):  # Test Case: A user with invalid login credentials will see an error when attempting
        # to log in.
        try:
            # Pre-Conditions
            self.preconditions()
            driver = self.driver
            f.write("test_invalid_login: "******"\n")
            # Test Step 1: Input Incorrect Username into Username Field
            step = 1
            driver.find_element(By.NAME,
                                "username").send_keys("*****@*****.**")
            if driver.find_element(
                    By.NAME,
                    "username").get_attribute("value") != "*****@*****.**":
                f.write("   Test Step " + str(step) + " = " + "FAIL\n")
                step = None
                raise Exception()
            f.write("   Test Step " + str(step) + " = " + "PASS\n")

            # Test Step 2: Input Incorrect Password into Password Field
            step += 1
            driver.find_element(By.NAME, "password").send_keys("1234abcd")
            if driver.find_element(
                    By.NAME, "password").get_attribute("value") != "1234abcd":
                f.write("   Test Step " + str(step) + " = " + "FAIL\n")
                step = None
                raise Exception()
            f.write("   Test Step " + str(step) + " = " + "PASS\n")

            # Test Step 3: Attempting to Login Results in Error Being Displayed
            step += 1
            driver.find_element_by_xpath("//button[@type='submit']").click()
            Wait(driver, 10).until(
                EC.visibility_of_element_located((
                    By.XPATH,
                    "//*[contains(text(), 'Invalid UserName/Password Combination')]"
                )))
            if driver.find_element_by_xpath\
                        ("//*[@id='contentarea']/div/router-view/div/div/div[1]/div/form/div[4]/loading-display/span")\
                    .get_attribute("innerHTML") != "Invalid UserName/Password Combination":
                f.write("   Test Step " + str(step) + " = " + "FAIL\n")
                step = None
                raise Exception()
            f.write("   Test Step " + str(step) + " = " + "PASS\n")
            f.write("Test Case Result = " + "PASS\n")
        except:
            if step is not None:
                f.write("   Test Step " + str(step) + " = " + "BLOCKED\n")
                f.write("Test Case Result = " + "BLOCKED\n")
            else:
                f.write("Test Case Result = " + "FAIL\n")
Example #25
0
 def enable_tool(self, site, tool):
     if self.is_present(CanvasPage.tool_nav_link_locator(tool)):
         app.logger.info(f'{tool} is already enabled')
     else:
         app.logger.info(f'Enabling {tool} on site ID {site.site_id}')
         self.driver.get(
             f'{app.config["CANVAS_BASE_URL"]}/courses/{site.site_id}/settings'
         )
         self.wait_for_page_and_click(CanvasPage.NAVIGATION_LINK)
         self.hide_canvas_footer()
         self.wait_for_element_and_click(
             CanvasPage.disabled_tool_locator(tool))
         self.wait_for_element_and_click(
             CanvasPage.enable_tool_link_locator(tool))
         Wait(self.driver, util.get_medium_timeout()).until(
             ec.visibility_of_element_located(
                 CanvasPage.enabled_tool_locator(tool)), )
         self.wait_for_element_and_click(CanvasPage.TOOL_SAVE_BUTTON)
         Wait(self.driver, util.get_medium_timeout()).until(
             ec.visibility_of_element_located(
                 CanvasPage.tool_nav_link_locator(tool)), )
Example #26
0
 def log_in(self):
     app.logger.info('Logging in to email')
     self.driver.get('https://login.yahoo.com')
     self.wait_for_element_and_type_js('login-username',
                                       app.config['XENA_EMAIL_USERNAME'])
     self.click_element_js(EmailPage.NEXT_BUTTON, 2)
     self.wait_for_element_and_type_js('login-passwd',
                                       app.config['XENA_EMAIL_PASSWORD'])
     self.click_element_js(EmailPage.NEXT_BUTTON, 2)
     Wait(self.driver, util.get_medium_timeout()).until(
         ec.presence_of_element_located(EmailPage.LOG_OUT_LINK))
     time.sleep(1)
Example #27
0
def refresh_and_call(browser, callback, *args, **kwargs):
    """Refresh browser and keep calling callback with given args
    until achieve expected result or timeout.
    """
    browser.refresh()
    try:
        result = Wait(
            browser,
            WAIT_REFRESH).until(lambda s: callback(s, *args, **kwargs))
    except TimeoutException:
        return None
    else:
        return result
Example #28
0
 def delete_all_messages(self):
     self.load_page()
     if self.elements(EmailPage.MESSAGE_ROW):
         app.logger.info('Deleting all messages')
         self.wait_for_page_and_click_js(EmailPage.SELECT_ALL_CBX, 2)
         self.wait_for_page_and_click_js(EmailPage.DELETE_BUTTON, 2)
         Wait(self.driver, util.get_medium_timeout()).until(
             ec.invisibility_of_element_located(EmailPage.MESSAGE_ROW))
     elif self.is_present(EmailPage.EMPTY_FOLDER):
         app.logger.info('There are no messages to delete')
     else:
         app.logger.warning(
             'Unable to tell if there are messages in the inbox')
Example #29
0
    def __init__(self, base_url, env, browser, open_url=True):
        self.base_url = base_url
        self.env = env
        self.browser = browser

        self.wait = Wait(self.browser, 5)

        self.full_url = f"{self.base_url}{self.path}"
        self.page_is_open = open_url

        if open_url:
            self.get_page(self.full_url)
            self.is_current()
            self.wait_to_load()
Example #30
0
 def finds(self, locator: tuple) -> WebElement:
     ''''''
     if self.__locator_is_tuple(locator):
         try:
             print('finds: ',locator)
             # eles = Wait(self.__driver, wait_time).until(EC.visibility_of_all_elements_located(locator))
             eles = Wait(self.__driver, wait_time).until(EC.visibility_of_any_elements_located(locator))
             return eles
         except Exception:
             print('发生了异常,具体错误信息如下:\n')
             print(self.__print_detail_msg())
             return False
     else:
         print(f'你传入的不是tuple类型的定位器,你传入的定位器如下:\n{locator}')
         return False