Beispiel #1
0
    def is_url_broken(self, link=""):
        """
            Checks if the URL supplied or current page is broken mean oops page or not

            :Args:
             - link = Optional Value: if not passed then current page is used to test

            :Usage:
                utils.is_url_broken(self.browser)
        """
        try:
            # Navigate to the link if it is not there already
            if link != self.browser.current_url and link != "":
                self.browser.get(link)
            #Needs to login instead any of the link redirect us to login page
            if "login" in self.browser.current_url and self.browser.find_elements_by_id(
                    'email').__len__() > 0:
                utils.login(browser=self.browser)

            element = self.browser.find_elements_by_xpath(
                '//*[contains(text(),"Well, this is embarrassing - you found a broken link.")]'
            ).__len__()
            return element
        except (InvalidSchema, MissingSchema, ConnectionError):
            logger.error("Hit an exception while traversing the URL")
            return True
Beispiel #2
0
    def assert_on_broken_links(self):
        session = requests.session()
        with self.multiple_assertions():
            for link in utils.get_all_links(self.browser):
                # This means either we are out of portal or already visited the link
                # Short Circuiting if we get more then 500 links in total
                if self.config.common.url not in link[0] or link[0] in visited:
                    logger.debug(
                        "Skipping link %s because it is either visited or not a crittercism link in crawling" % link[0])
                    continue

                visited.add(link[0])
                logger.debug("Working on url '%s'" % (link[0]))
                try:
                    resp = session.get(link[0])
                    logger.debug(
                        "Got the response code %s from url %s from page %s" % (resp.status_code, link[0], link[1]))
                    self.assertTrue((resp.status_code not in [500, 404]),
                                    ("Return code %s URL %s from page %s" % (resp.status_code, link[0], link[1])))

                    if link[0] != self.browser.current_url:
                        self.browser.get(link[0])
                    #Needs to login instead any of the link redirect us to login page
                    if "login" in self.browser.current_url and self.browser.find_elements_by_id('email').__len__() > 0:
                        utils.login(browser=self.browser)

                    element = self.browser.find_elements_by_xpath(
                        '//*[contains(text(),"Well, this is embarrassing - you found a broken link.")]').__len__()
                    self.assertEqual(element, 0, "Found a broken Link at : " + link[0] + " from page :" + link[1])
                    # call itself if the link contains crittercism else it will crawl the entire web :)
                    self.assert_on_broken_links()
                except (InvalidSchema, MissingSchema, ConnectionError):
                    continue
Beispiel #3
0
    def validate_user_profile(self, email_id=None, account_type=None):
        # Logout as any user because this needs to login as a admin user
        self.browser.get(self.config.common.url + "/developers/logout")
        utils.login(browser=self.browser)

        search_page_url = self.config.common.url + "/admin/search"
        #email_id = "*****@*****.**"
        self.browser.get(search_page_url)
        self.browser.find_element_by_id("search-email").send_keys(email_id + Keys.ENTER)

        email_link = self.browser.find_element_by_xpath("//a[contains(text(),'" + email_id + "')]").get_attribute(
            "href")
        self.browser.get(email_link)

        actual_email = self.browser.find_element_by_xpath("//table//*/*[contains(text(),'" + email_id + "')]").text
        self.assertEqual(actual_email, email_id, ("Expecting %s email but found %s instead" % (actual_email, email_id)))

        """
        Need to go with Resolved Plan
        billed_plan_caption = self.browser.find_element_by_xpath('//*[@id="admin-portal"]/div/table[1]/tbody/tr[13]/td[1]/strong').text
        billed_plan_value = self.browser.find_element_by_xpath('//*[@id="admin-portal"]/div/table[1]/tbody/tr[13]/td[2]').text
        self.assertEqual(account_type, billed_plan_value, ("Expecting Basic but found %s" % billed_plan_value) )
        """
        pay_via_caption = self.browser.find_element_by_xpath(
            '//*[@id="admin-portal"]/div/table[1]/tbody/tr[16]/td[1]/strong').text
        pay_via_value = self.browser.find_element_by_xpath(
            '//*[@id="admin-portal"]/div/table[1]/tbody/tr[16]/td[2]').text
        self.assertEqual("Credit Card", pay_via_value, ("Expecting Credit Card but found %s" % pay_via_value))
Beispiel #4
0
    def get_back_to_dashboard(self):
        """
            Get back to the enterprise account

        """
        self.logout()
        self.browser.implicitly_wait(1)
        utils.login(self.browser)
Beispiel #5
0
    def get_back_to_dashboard(self):
        """
            Get back to the enterprise account

        """
        self.logout()
        self.browser.implicitly_wait(1)
        utils.login(self.browser)
Beispiel #6
0
    def test_6_basic_new_android(self):
        """
            6)log into basic account, generate a new android application, load wrapping page
        """

        self.logout()
        utils.login(self.browser, username=self.config.login.basic_username, password=self.config.login.basic_password)
        app_name = self.create_new_app(constants.ANDROID)

        app_ids = team.get_id_from_app_name(self.browser, app_name)
        self.browser.get(self.config.common.url + "/developers/wrapping/" + app_ids[0])
        self.browser.implicitly_wait(2)
        self.assertNotEqual(self.browser.current_url,
                            self.config.common.url + "/developers/wrapping/" + app_ids[0],
                            "Loaded wrapping page for a non-iOS application with a basic user")
        team.delete_app_given_ids(browser=self.browser, app_ids=app_ids)
Beispiel #7
0
    def test_6_basic_new_android(self):
        """
            6)log into basic account, generate a new android application, load wrapping page
        """

        self.logout()
        utils.login(self.browser,
                    username=self.config.login.basic_username,
                    password=self.config.login.basic_password)
        app_name = self.create_new_app(constants.ANDROID)

        app_ids = team.get_id_from_app_name(self.browser, app_name)
        self.browser.get(self.config.common.url + "/developers/wrapping/" +
                         app_ids[0])
        self.browser.implicitly_wait(2)
        self.assertNotEqual(
            self.browser.current_url,
            self.config.common.url + "/developers/wrapping/" + app_ids[0],
            "Loaded wrapping page for a non-iOS application with a basic user")
        team.delete_app_given_ids(browser=self.browser, app_ids=app_ids)
Beispiel #8
0
    def is_url_broken(self, link=""):
        """
            Checks if the URL supplied or current page is broken mean oops page or not

            :Args:
             - link = Optional Value: if not passed then current page is used to test

            :Usage:
                utils.is_url_broken(self.browser)
        """
        try:
            # Navigate to the link if it is not there already
            if link != self.browser.current_url and link != "":
                self.browser.get(link)
            #Needs to login instead any of the link redirect us to login page
            if "login" in self.browser.current_url and self.browser.find_elements_by_id('email').__len__() > 0:
                utils.login(browser=self.browser)

            element = self.browser.find_elements_by_xpath(
                '//*[contains(text(),"Well, this is embarrassing - you found a broken link.")]').__len__()
            return element
        except (InvalidSchema, MissingSchema, ConnectionError):
            logger.error("Hit an exception while traversing the URL")
            return True