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 test_search_non_existing_organization(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() self.wd.find_element_by_xpath('//input[@type="search"]').send_keys( "organization-x") text = self.wd.find_css(".dataTables_empty").text assert text == "No matching records found"
def test_search_organization(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() self.wd.find_element_by_xpath('//input[@type="search"]').send_keys( Organization.get_test_org_name()) elems = self.wd.find_elements_by_css_selector(".linked") assert len(elems) != 0
def test_view_members(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_css_selector("span.icon.members").click() self.wd.wait_for_css('.table') elems = self.wd.find_elements_by_css_selector(".linked") assert len(elems) != 0
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 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 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 test_archive_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.open("/organizations/" + Organization.get_test_org_name() + "/archive/") self.wd.wait_for_xpath( "//h2[contains(text(), 'Organization Overview')]") text = self.wd.find_element_by_xpath( "//span[contains(@class, 'label-danger')]").text assert text == "ARCHIVED"
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 test_unarchive_organization(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() self.wd.find_css("#archive-filter").click() self.wd.find_element_by_xpath( '//option[@value="archived-True"]').click() self.wd.find_element_by_link_text( Organization.get_test_org_name()).click() self.wd.wait_for_xpath( "//h2[contains(text(), 'Organization Overview')]") self.open("/organizations/" + Organization.get_test_org_name() + "/unarchive/") self.wd.wait_for_xpath( "//h2[contains(text(), 'Organization Overview')]") try: self.wd.find_element_by_xpath( "//span[contains(@class, 'label-danger')]") except NoSuchElementException: assert True
def test_search_member(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() organizations_page.open_members_page() self.wd.find_element_by_xpath('//input[@type="search"]').send_keys("cadasta-test-user") elems = self.wd.find_elements_by_css_selector(".linked") assert len(elems) != 0
def test_view_member_profile(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() organizations_page.open_members_page() self.wd.find_element_by_xpath('//tr/td/a').click() self.wd.wait_for_css(".member-info") text = self.wd.find_css("h2").text assert text.startswith("MEMBER:")
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 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-test-user-2") self.wd.find_element_by_xpath('//button[@type="submit"]').click() self.wd.wait_for_css(".member-info") text = self.wd.find_css("h2").text assert text.startswith("MEMBER:")
def test_remove_member(self): organizations_page = OrganizationsPage(self.wd, self) organizations_page.go_to() organizations_page.open_members_page() self.wd.find_element_by_link_text('cadasta-test-user-2').click() self.wd.wait_for_css(".member-info") self.wd.find_element_by_xpath('//button[@name="remove"]').click() self.wd.switch_to_window(self.wd.window_handles[-1]) self.wd.get("%s%s" % (self.wd.current_url, "remove")) self.wd.wait_for_css('.table') try: self.wd.find_element_by_link_text('cadasta-test-user-2') except NoSuchElementException: assert True