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

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

        self.wd.find_element_by_link_text(
            Organization.get_test_org_name()).click()
        self.wd.wait_for_xpath(
            "//h2[contains(text(), 'Organization Overview')]")
        self.wd.find_element_by_xpath("(//button[@type='button'])[2]").click()
        self.wd.find_element_by_link_text("Edit organization").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.wait_for_css("#id_description")
        self.wd.find_element_by_id("id_description").clear()
        self.wd.find_element_by_id("id_description").send_keys(
            "Test organization description edited.")
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath(
            "//h2[contains(text(), 'Organization Overview')]")
        text = self.wd.find_element_by_xpath("//div/section/p").text
        assert text == "Test organization description edited."

    def tearDown(self):
        self.wd.quit()
예제 #2
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()
예제 #3
0
class AddLocationResource(SeleniumTestCase):
    def setUp(self):
        self.wd = CustomWebDriver()

    def test_attach_existing_resource_to_new_location(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
        self.wd.find_element_by_link_text("Add location").click()

        self.wd.wait_for_xpath(
            "//h3[contains(text(), 'Draw location on map')]")
        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_css_selector(
            "a.leaflet-draw-draw-marker").click()

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="id_geometry_map"]')
        action.move_to_element(elem).move_by_offset(12, 12).click().perform()

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

        Select(self.wd.find_element_by_id("id_type")).select_by_visible_text(
            "Building")
        self.wd.find_element_by_xpath('//input[@value="Save"]').click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")

        self.wd.find_element_by_xpath(
            "//a[contains(text(),'Resources')]").click()
        self.wd.find_element_by_link_text("Attach").click()
        self.wd.find_element_by_xpath(
            '//tr/td/label/strong[contains(text(), "resource-1")]').click()
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//a[@href="#resources"]')
        assert self.wd.find_element_by_xpath(
            '//*[contains(text(), "resource-1")]')

    def test_attach_existing_resource_to_existing_location(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")

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

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="project-map"]')
        action.move_to_element(elem).perform()
        self.wd.find_element_by_css_selector('img.leaflet-marker-icon').click()
        self.wd.find_element_by_link_text("Open location").click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        self.wd.find_element_by_xpath(
            "//a[contains(text(),'Resources')]").click()
        self.wd.find_element_by_link_text("Attach").click()

        self.wd.find_element_by_xpath(
            '//tr/td/label/strong[contains(text(), "resource-1")]').click()
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//a[@href="#resources"]')
        assert self.wd.find_element_by_xpath(
            '//*[contains(text(), "resource-1")]')

    def test_attach_new_resource_to_existing_location(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")

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

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="project-map"]')
        action.move_to_element(elem).perform()
        self.wd.find_element_by_css_selector('img.leaflet-marker-icon').click()
        self.wd.find_element_by_link_text("Open location").click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        self.wd.find_element_by_xpath(
            "//a[contains(text(),'Resources')]").click()
        self.wd.find_element_by_link_text("Attach").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.find_element_by_link_text("Upload new").click()
        self.wd.wait_for_css("input.file-input")

        path = os.path.abspath("resources/pdf_file.pdf")
        self.wd.find_element_by_css_selector("input.file-input").clear()
        self.wd.find_element_by_css_selector("input.file-input").send_keys(
            path)
        self.wd.find_element_by_id("id_name").clear()
        self.wd.find_element_by_id("id_name").send_keys("resource-2")
        self.wd.wait_for_xpath("//a[@class='file-link']")
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//a[@href="#resources"]')
        assert self.wd.find_element_by_xpath(
            '//*[contains(text(), "resource-2")]')

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

    def test_attach_existing_resource_to_relationship(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")

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

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="project-map"]')
        action.move_to_element(elem).perform()
        self.wd.find_element_by_css_selector('img.leaflet-marker-icon').click()
        self.wd.find_element_by_link_text("Open location").click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        self.wd.find_element_by_xpath(
            "//a[contains(text(),'Relationships')]").click()
        self.wd.find_element_by_xpath("//tr/td/a").click()
        self.wd.wait_for_xpath('//*[contains(text(), "Relationship Detail")]')
        self.wd.find_element_by_link_text("Attach").click()

        self.wd.find_element_by_xpath(
            '//tr/td/label/strong[contains(text(), "resource-1")]').click()
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//h4[contains(text(), "Resources")]')
        assert self.wd.find_element_by_xpath(
            '//*[contains(text(), "resource-1")]')

    def test_attach_new_resource_to_relationship(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")

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

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="project-map"]')
        action.move_to_element(elem).perform()
        self.wd.find_element_by_css_selector('img.leaflet-marker-icon').click()
        self.wd.find_element_by_link_text("Open location").click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        self.wd.find_element_by_xpath(
            "//a[contains(text(),'Relationships')]").click()
        self.wd.find_element_by_xpath("//tr/td/a").click()
        self.wd.wait_for_xpath('//*[contains(text(), "Relationship Detail")]')
        self.wd.find_element_by_link_text("Attach").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.find_element_by_link_text("Upload new").click()
        self.wd.wait_for_css("input.file-input")

        path = os.path.abspath("resources/resource-1.pdf")
        self.wd.find_element_by_css_selector("input.file-input").clear()
        self.wd.find_element_by_css_selector("input.file-input").send_keys(
            path)
        self.wd.find_element_by_id("id_name").clear()
        self.wd.find_element_by_id("id_name").send_keys("resource-2")
        self.wd.wait_for_xpath("//a[@class='file-link']")
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//h4[contains(text(), "Resources")]')
        assert self.wd.find_element_by_xpath(
            '//*[contains(text(), "resource-2")]')

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

    def test_add_new_resource_to_party(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()
        projects_page.open_parties_page()

        self.wd.find_element_by_link_text("party-1").click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")
        self.wd.find_element_by_link_text("Attach").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        try:
            self.wd.find_element_by_xpath(
                "//*[contains(text(), 'Upload new resource')]")
        except:
            self.wd.find_element_by_link_text("Upload new").click()
        self.wd.wait_for_css("input.file-input")

        path = os.path.abspath("resources/pdf_file.pdf")
        self.wd.find_element_by_css_selector("input.file-input").clear()
        self.wd.find_element_by_css_selector("input.file-input").send_keys(
            path)
        self.wd.find_element_by_id("id_name").clear()
        self.wd.find_element_by_id("id_name").send_keys("resource-2")
        self.wd.wait_for_xpath("//a[@class='file-link']")
        self.wd.find_element_by_name("submit").click()

        self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")
        assert self.wd.find_element_by_xpath(
            '//td/div/p/a/strong[contains(text(), "resource-2")]')

    def test_attach_existing_resource_to_party(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()
        projects_page.open_parties_page()

        self.wd.find_element_by_link_text("party-1").click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")
        self.wd.find_element_by_link_text("Attach").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.find_element_by_xpath(
            '//tr/td/label/strong[contains(text(), "resource-1")]').click()
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")
        assert self.wd.find_element_by_xpath(
            '//td/div/p/a/strong[contains(text(), "resource-1")]')

    def test_detach_resource_from_party(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()
        projects_page.open_parties_page()

        self.wd.find_element_by_link_text("party-1").click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")
        self.wd.find_element_by_xpath("//button[@role='button']").click()
        assert self.wd.wait_for_xpath("//h2[contains(text(), 'Party detail')]")

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

    def test_attach_relationship_to_new_location(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
        self.wd.find_element_by_link_text("Add location").click()

        self.wd.wait_for_xpath(
            "//h3[contains(text(), 'Draw location on map')]")
        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_css_selector(
            "a.leaflet-draw-draw-marker").click()

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="id_geometry_map"]')
        action.move_to_element(elem).move_by_offset(15, 15).click().perform()

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

        Select(self.wd.find_element_by_id("id_type")).select_by_visible_text(
            "Building")
        self.wd.find_element_by_xpath('//input[@value="Save"]').click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")

        self.wd.find_element_by_link_text("Relationships").click()
        self.wd.find_element_by_link_text("Add relationship").click()

        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.wait_for_xpath("//h3[@class='modal-title']")
        try:
            self.wd.find_element_by_id("id_name").send_keys("party-1")
        except ElementNotVisibleException:
            self.wd.find_element_by_id("add-party").click()
            self.wd.find_element_by_id("id_name").send_keys("party-1")
        Select(self.wd.find_element_by_id(
            "id_party_type")).select_by_visible_text("Individual")
        Select(self.wd.find_element_by_id(
            "id_tenure_type")).select_by_visible_text("Freehold")
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//a[@href="#relationships"]')

    def test_attach_relationship_to_existing_location(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")

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

        action = ActionChains(self.wd)
        elem = self.wd.find_element_by_xpath('//div[@id="project-map"]')
        action.move_to_element(elem).perform()
        self.wd.find_element_by_css_selector('img.leaflet-marker-icon').click()
        self.wd.find_element_by_link_text("Open location").click()
        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")

        self.wd.find_element_by_link_text("Relationships").click()
        self.wd.find_element_by_link_text("Add relationship").click()

        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.wait_for_xpath("//h3[@class='modal-title']")
        try:
            self.wd.find_element_by_id("id_name").send_keys("party-1")
        except ElementNotVisibleException:
            self.wd.find_element_by_id("add-party").click()
            self.wd.find_element_by_id("id_name").send_keys("party-1")
        Select(self.wd.find_element_by_id(
            "id_party_type")).select_by_visible_text("Individual")
        Select(self.wd.find_element_by_id(
            "id_tenure_type")).select_by_visible_text("Freehold")
        self.wd.find_element_by_name("submit").click()
        self.wd.wait_for_xpath('//a[@href="#relationships"]')

    def tearDown(self):
        self.wd.quit()
예제 #7
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()