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 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 test_edit_relationship_details(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.wait_for_xpath('//a[@title="Edit relationship"]').click()
        self.wd.wait_for_xpath('//*[contains(text(), "Edit Relationship")]')
        Select(self.wd.find_element_by_id(
            "id_tenure_type")).select_by_visible_text("Leasehold")
        self.wd.find_element_by_xpath('//button[@type="submit"]').click()
        self.wd.wait_for_xpath('//*[contains(text(), "Relationship Detail")]')
        assert self.wd.wait_for_xpath('//*[contains(text(), "Leasehold")]')
Example #5
0
    def test_edit_location_details(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[@title='Edit location']").click()
        self.wd.wait_for_xpath(
            "//h3[contains(text(), 'Draw location on map')]")
        Select(self.wd.find_element_by_id("id_type")).select_by_visible_text(
            "Apartment")
        self.wd.find_element_by_xpath('//input[@value="Save"]').click()

        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        assert self.wd.find_element_by_xpath(
            "//*[contains(text(), 'Apartment')]")
Example #6
0
    def test_add_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;')
        print page_state

        self.wd.find_element_by_xpath(
            '//a[@class="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(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;')

        Select(self.wd.find_element_by_id("id_type")).select_by_visible_text(
            "Parcel")
        self.wd.find_element_by_xpath('//input[@value="Save"]').click()

        self.wd.wait_for_xpath("//span[contains(text(), 'Location')]")
        text = self.wd.find_element_by_xpath("//h2/span").text
        assert text == "LOCATION"
    def test_search_project(self):
        projects_page = ProjectsPage(self.wd, self)
        projects_page.go_to()

        self.wd.find_element_by_xpath('//input[@type="search"]').send_keys(
            Project.get_test_proj_name())
        elems = self.wd.find_elements_by_css_selector(".linked")
        assert len(elems) != 0
Example #8
0
 def test_anonymous_user_project_view(self):
     self.open("")
     self.wd.wait_for_css(".projects")
     self.wd.find_element_by_link_text("Projects").click()
     self.wd.wait_for_xpath("//h1[contains(text(), 'Projects')]")
     self.wd.find_element_by_link_text(Project.get_test_proj_name()).click()
     self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
     assert self.wd.wait_for_xpath("//*[contains(text(), 'Sign in')]")
Example #9
0
    def test_private_project_to_public(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_xpath("(//button[@type='button'])[2]").click()
        self.wd.find_element_by_link_text("Edit project details").click()
        self.wd.wait_for_css(".modal-title")
        self.wd.find_element_by_xpath('//div[@class="toggle-group"]').click()
        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 * 8).send_keys(Keys.RETURN).perform()
        assert self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
Example #10
0
    def test_detach_resource(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_xpath("//button[@type='submit']").click()
Example #11
0
    def test_delete_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[@title='Delete location']").click()
        self.wd.switch_to_window(self.wd.window_handles[-1])
        self.wd.wait_for_xpath("//button[@value='Confirm']").click()
Example #12
0
    def test_load_gpx_file_on_map(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_xpath(
            '//div[@id="sidebar"]/ul/li[@class="map"]/a').click()
        self.wd.wait_for_xpath('//div[@id="project-map"]')
        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_xpath("//a[@title='Layers']").click()
        self.wd.wait_for_css(".leaflet-control-layers-expanded")

        self.wd.find_element_by_xpath("//input[@type='checkbox']").click()
        assert self.wd.find_element_by_css_selector('img.leaflet-marker-icon')
Example #13
0
    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")]')
Example #14
0
    def test_edit_project(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_xpath("(//button[@type='button'])[2]").click()
        self.wd.find_element_by_link_text("Edit project details").click()

        self.wd.wait_for_css(".modal-title")
        self.wd.find_css('#id_description').clear()
        self.wd.find_css('#id_description').send_keys("Test project description edited.")

        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 * 7).send_keys(Keys.RETURN).perform()

        self.wd.wait_for_xpath("//h2[contains(text(), 'Project Overview')]")
        text = self.wd.find_element_by_xpath("//div/section/p").text
        assert text == "Test project description edited."
Example #15
0
 def go_to(self):
     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_xpath(
         '//div[@id="sidebar"]/ul/li[@class="resources"]/a').click()
     self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]")