예제 #1
0
class PasswordChange(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_password_change_success(self):
        self.user_login()
        self.wd.wait_for_css('.btn-user')
        self.open("/account/password/change/")
        self.wd.wait_for_css('#id_oldpassword')

        self.wd.find_css('#id_oldpassword').send_keys("XYZ#qwerty")
        self.wd.find_css('#id_password1').send_keys("XYZ#qwertyA")
        self.wd.find_css('#id_password2').send_keys("XYZ#qwertyA")
        self.wd.find_elements_by_xpath(
            "//button[contains(text(), 'Change password')]")[0].click()
        text = self.wd.find_element_by_xpath("//h1").text
        self.restore_password("XYZ#qwerty", "XYZ#qwertyA")
        assert text == "Change your password"

    def test_password_change_failure(self):
        self.user_login()
        self.wd.wait_for_css('.btn-user')
        self.open("/account/password/change/")
        self.wd.wait_for_css('#id_oldpassword')

        self.wd.find_css('#id_oldpassword').send_keys("abc")
        self.wd.find_css('#id_password1').send_keys("XYZ#qwertyA")
        self.wd.find_css('#id_password2').send_keys("XYZ#qwertyA")
        self.wd.find_elements_by_xpath(
            "//button[contains(text(), 'Change password')]")[0].click()
        text = self.wd.find_element_by_xpath("//h1").text
        assert text == "Change your password"

    def tearDown(self):
        self.wd.quit()
예제 #2
0
class Login(SeleniumTestCase):

    def setUp(self):
        self.wd = CustomWebDriver()

    def test_login(self):
        self.open("/account/login/")
        self.wd.find_css('#id_login').send_keys("cadasta-test-user-1")
        self.wd.find_css("#id_password").send_keys('XYZ#qwerty')
        self.wd.find_element_by_xpath('//button[@name="sign-in"]').click()
        self.wd.find_elements_by_xpath("//span[contains(text(), 'cadasta-test-user-1')]")

    def tearDown(self):
        self.wd.quit()
예제 #3
0
class NewRegistration(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_new_registration(self):
        registration_page = RegistrationPage(self.wd, self)
        registration_page.go_to()
        username_available = False
        index = 1

        while not username_available:
            test_username = "******" + ` index `
            test_password = "******"
            self.wd.find_css('#id_username').clear()
            self.wd.find_css('#id_username').send_keys(test_username)
            self.wd.find_css('#id_email').clear()
            self.wd.find_css('#id_email').send_keys(test_username +
                                                    "@example.com")
            self.wd.find_css("#id_password1").clear()
            self.wd.find_css("#id_password1").send_keys(test_password)
            self.wd.find_css("#id_password2").clear()
            self.wd.find_css("#id_password2").send_keys(test_password)
            self.wd.find_css("#id_full_name").send_keys('')
            action = ActionChains(self.wd)
            action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform()

            time.sleep(1)
            elems = self.wd.find_elements_by_xpath(
                "//*[contains(text(), 'A user with that username already exists.')]"
            )
            elems.extend(
                self.wd.find_elements_by_xpath(
                    "//*[contains(text(), 'Another user with this email already exists')]"
                ))
            if len(elems) == 0:
                username_available = True
                Credentials().set_test_username(test_username)
                Credentials().set_test_password(test_password)
                Credentials().set_test_email(test_username + "@example.com")
                assert self.wd.wait_for_css('.btn-user')
            else:
                index = index + 1

    def tearDown(self):
        self.wd.quit()
예제 #4
0
class CreatePrivateProject(SeleniumTestCase):

    def setUp(self):
        self.wd = CustomWebDriver()

    def test_new_project(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()
        proj_name_available = False
        index = 1

        self.wd.find_element_by_xpath('//a[@href="/projects/new/"]').click()
        self.wd.wait_for_css(".wizard")
        self.wd.wait_for_xpath('//button[@type="submit"]')
        text = self.wd.find_element_by_xpath('//button[@type="submit"]').text
        assert text == "Next"
        self.wd.find_element_by_xpath('//button[@type="submit"]').click()
        self.wd.wait_for_xpath("//h3[contains(text(), '1. General Information')]")

        while not proj_name_available:
            test_proj_name = "private-project-" + `index`
            Select(self.wd.find_element_by_name("details-organization")).select_by_visible_text(
                Organization.get_test_org_name())
            self.wd.find_element_by_xpath('//input[@id="id_details-name"]').clear()
            self.wd.find_element_by_xpath('//input[@id="id_details-name"]').send_keys(test_proj_name)
            self.wd.find_element_by_xpath('//div[@class="toggle-group"]').click()
            self.wd.find_element_by_xpath('//textarea[@id="id_details-description"]').clear()
            self.wd.find_element_by_xpath('//textarea[@id="id_details-description"]').send_keys(
                "Private project description")
            elem = self.wd.find_element_by_xpath('//button[@type="submit"]')
            try :
                elem.click()
            except WebDriverException: # Fix : element not clickable in Chrome
                action = ActionChains(self.wd)
                action.move_to_element(elem).send_keys(Keys.TAB * 11).send_keys(Keys.RETURN).perform()

            time.sleep(1)
            elems = self.wd.find_elements_by_xpath(
                "//*[contains(text(), 'Project with this name already exists in this organization.')]")
            if len(elems) == 0:
                proj_name_available = True
                self.wd.wait_for_xpath("//h3[contains(text(), 'Assign permissions to members')]")
                self.wd.find_element_by_xpath('//button[@type="submit"]').click()
                self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
                text = self.wd.find_element_by_xpath("//h1[contains(@class, 'short')]").text
                assert text.endswith("PRIVATE-PROJECT-" + `index`)
            else:
                index = index + 1

    def tearDown(self):
        self.wd.quit()
class OrganizationURLValidation(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_empty_organization_url_validation(self):
        organizations_page = OrganizationsPage(self.wd, self)
        organizations_page.create_new_org_form()

        self.wd.find_css('#id_name').send_keys("organization-x")
        self.wd.find_css('#id_urls').send_keys("http:localhost")
        self.wd.find_element_by_xpath('//button[@name="submit"]').click()
        self.wd.wait_for_css(".has-error")

        elems = self.wd.find_elements_by_xpath(
            "//*[contains(text(), 'This value should be a valid url.')]")
        assert len(elems) != 0

    def tearDown(self):
        self.wd.quit()
class EmptyOrganizationNameValidation(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_empty_organization_name_validation(self):
        organizations_page = OrganizationsPage(self.wd, self)
        organizations_page.create_new_org_form()

        self.wd.find_css('#id_name').send_keys("")
        self.wd.find_css('#id_description').send_keys(
            "Test organization description.")
        self.wd.find_element_by_xpath('//button[@name="submit"]').click()
        self.wd.wait_for_css(".has-error")

        elems = self.wd.find_elements_by_xpath(
            "//*[contains(text(), 'This field is required.')]")
        assert len(elems) != 0

    def tearDown(self):
        self.wd.quit()
예제 #7
0
class EmptyEmailInPasswordValidation(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_empty_email_in_password(self):
        self.open("/account/signup/")

        self.wd.find_css('#id_username').send_keys("cadasta-test-user2")
        self.wd.find_css('#id_email').send_keys("")
        self.wd.find_css("#id_password1").send_keys('XYZ#qwerty')
        self.wd.find_css("#id_password2").send_keys('XYZ#qwerty')
        self.wd.find_css("#id_full_name").send_keys('user2-name')
        action = ActionChains(self.wd)
        action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform()

        text = self.wd.find_elements_by_xpath(
            "//ul[contains(@class, 'parsley-errors-list')]")
        assert len(text) == 1

    def tearDown(self):
        self.wd.quit()
예제 #8
0
class AddNonExistingMember(SeleniumTestCase):

    def setUp(self):
        self.wd = CustomWebDriver()

    def test_add_member(self):
        organizations_page = OrganizationsPage(self.wd, self)
        organizations_page.go_to()
        organizations_page.open_members_page()

        self.wd.find_element_by_link_text("Add").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.wait_for_css("#id_identifier")
        self.wd.find_element_by_xpath('//input[@name="identifier"]').send_keys("cadasta-user-x")
        self.wd.find_element_by_xpath('//button[@type="submit"]').click()
        self.wd.wait_for_css(".has-error")
        elems = self.wd.find_elements_by_xpath("//*[contains(text(), 'User with username or email cadasta-user-x does not exist')]")
        assert len(elems) != 0

    def tearDown(self):
        self.wd.quit()
class DuplicateOrganizationNameValidation(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_organization_name_validation(self):
        organizations_page = OrganizationsPage(self.wd, self)
        organizations_page.create_new_org_form()

        self.wd.find_css('#id_name').send_keys(
            Organization.get_test_org_name())
        self.wd.find_css('#id_description').send_keys(
            "Test organization description.")
        self.wd.find_element_by_xpath('//button[@name="submit"]').click()
        self.wd.wait_for_css(".errorlist")
        elems = self.wd.find_elements_by_xpath(
            "//*[contains(text(), 'Organization with this Name already exists.')]"
        )
        assert len(elems) != 0

    def tearDown(self):
        self.wd.quit()
예제 #10
0
class CreateOrganization(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_new_organization(self):
        organizations_page = OrganizationsPage(self.wd, self)
        organizations_page.go_to()
        self.wd.find_element_by_xpath(
            '//a[@href="/organizations/new/"]').click()
        self.wd.wait_for_css(".modal-title")
        self.wd.wait_for_css("#id_name")
        org_name_available = False
        index = 1

        while not org_name_available:
            test_org_name = "organization-" + ` index `
            self.wd.find_css('#id_name').clear()
            self.wd.find_css('#id_name').send_keys(test_org_name)
            self.wd.find_css('#id_description').clear()
            self.wd.find_css('#id_description').send_keys(
                "Test organization description.")
            self.wd.find_element_by_xpath('//button[@name="submit"]').click()

            time.sleep(1)
            elems = self.wd.find_elements_by_xpath(
                "//*[contains(text(), 'Organization with this Name already exists.')]"
            )
            if len(elems) == 0:
                org_name_available = True
                Organization().set_test_org_name(test_org_name)
                self.wd.wait_for_xpath(
                    "//h2[contains(text(), 'Organization Overview')]")
                text = self.wd.find_element_by_xpath(
                    "//h1[contains(@class, 'short')]").text
                assert text == "ORGANIZATION-" + ` index `
            else:
                index = index + 1

    def tearDown(self):
        self.wd.quit()
예제 #11
0
class AddProjectWithExtent(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_new_project_with_extent(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()
        proj_name_available = False
        index = 1

        self.wd.find_element_by_xpath('//a[@href="/projects/new/"]').click()
        self.wd.wait_for_css(".wizard")

        page_state = self.wd.execute_script('return document.readyState;')
        while page_state != 'complete':
            page_state = self.wd.execute_script('return document.readyState;')

        self.wd.find_element_by_xpath(
            '//a[@class="leaflet-draw-draw-polygon"]').click()
        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath(
            '//div[@id="id_extents_extent_map"]')
        action.move_to_element(elem).move_by_offset(10, 10).click().perform()
        action.move_to_element(elem).move_by_offset(15, 10).click().perform()
        action.move_to_element(elem).move_by_offset(15, 15).click().perform()
        action.move_to_element(elem).move_by_offset(10, 15).click().perform()
        action.move_to_element(elem).move_by_offset(10, 10).click().perform()

        page_state = self.wd.execute_script('return document.readyState;')
        while page_state != 'complete':
            page_state = self.wd.execute_script('return document.readyState;')

        self.wd.find_element_by_xpath('//button[@type="submit"]').click()
        self.wd.wait_for_xpath(
            "//h3[contains(text(), '1. General Information')]")

        while not proj_name_available:
            test_proj_name = "project-with-extent-" + ` index `
            Select(self.wd.find_element_by_name(
                "details-organization")).select_by_visible_text(
                    Organization.get_test_org_name())
            self.wd.find_element_by_xpath(
                '//input[@id="id_details-name"]').clear()
            self.wd.find_element_by_xpath(
                '//input[@id="id_details-name"]').send_keys(test_proj_name)
            self.wd.find_element_by_xpath(
                '//textarea[@id="id_details-description"]').clear()
            self.wd.find_element_by_xpath(
                '//textarea[@id="id_details-description"]').send_keys(
                    "Project-with-extent description")
            elem = self.wd.find_element_by_xpath('//button[@type="submit"]')
            try:
                elem.click()
            except WebDriverException:  # Fix : element not clickable in Chrome
                action = ActionChains(self.wd)
                action.move_to_element(elem).send_keys(
                    Keys.TAB * 11).send_keys(Keys.RETURN).perform()

            time.sleep(1)
            elems = self.wd.find_elements_by_xpath(
                "//*[contains(text(), 'Project with this name already exists in this organization.')]"
            )
            if len(elems) == 0:
                proj_name_available = True
                self.wd.wait_for_xpath(
                    "//h3[contains(text(), 'Assign permissions to members')]")
                self.wd.find_element_by_xpath(
                    '//button[@type="submit"]').click()
                self.wd.wait_for_xpath(
                    "//h2[contains(text(), 'Project Overview')]")
                text = self.wd.find_element_by_xpath(
                    "//h1[contains(@class, 'short')]").text
                assert text.endswith("PROJECT-WITH-EXTENT-" + ` index `)
            else:
                index = index + 1

    def tearDown(self):
        self.wd.quit()