class EditProjectDetails(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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." def tearDown(self): self.wd.quit()
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()
class AddGPXResource(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_add_gpx_resource(self): projects_page = ProjectsPage(self.wd, self) projects_page.go_to() resources_page = ResourcesPage(self.wd, self) resources_page.go_to() file_path = os.path.abspath("resources/Deramola.gpx") resources_page.upload_resource(file_path, "deramola-gpx") self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]") assert self.wd.find_element_by_xpath( '//td/div/p/a/strong[contains(text(), "deramola-gpx")]') 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") assert self.wd.find_css(".leaflet-control-layers-selector") text = self.wd.find_css(".leaflet-control-layers-group-name").text assert text == "deramola-gpx" def tearDown(self): self.wd.quit()
class DetachLocationResource(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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() def tearDown(self): self.wd.quit()
class SearchMembers(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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_search_non_existing_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("user-x") text = self.wd.find_css(".dataTables_empty").text assert text == "No matching records found" def tearDown(self): self.wd.quit()
class LoadGPXFileOnMap(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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') def tearDown(self): self.wd.quit()
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()
class RemoveResource(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_detach_resource_from_project(self): projects_page = ProjectsPage(self.wd, self) projects_page.go_to() resources_page = ResourcesPage(self.wd, self) resources_page.go_to() self.wd.find_element_by_xpath("//button[@role='button']").click() assert self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]") def test_delete_resource(self): projects_page = ProjectsPage(self.wd, self) projects_page.go_to() resources_page = ResourcesPage(self.wd, self) resources_page.go_to() self.wd.find_element_by_link_text("deramola-gpx").click() self.wd.find_element_by_xpath("//a[@title='Delete resource']").click() self.wd.switch_to_window(self.wd.window_handles[-1]) self.wd.get("%s%s" % (self.wd.current_url, "archive")) assert self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]") def tearDown(self): self.wd.quit()
class EditRelationshipDetails(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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")]') def tearDown(self): self.wd.quit()
class EditLocation(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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')]") def tearDown(self): self.wd.quit()
class AcceptedResourceTypes(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def upload_valid_resource(self, file_path, resource_name): projects_page = ProjectsPage(self.wd, self) projects_page.go_to() resources_page = ResourcesPage(self.wd, self) resources_page.go_to() resources_page.upload_resource(file_path, resource_name) self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]") def test_add_csv_resource(self): path = os.path.abspath("resources/csv_file.csv") self.upload_valid_resource(path, "csv-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "csv-resource-1")]') def test_add_doc_resource(self): path = os.path.abspath("resources/doc_file.doc") self.upload_valid_resource(path, "doc-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "doc-resource-1")]') def test_add_docx_resource(self): path = os.path.abspath("resources/docx_file.docx") self.upload_valid_resource(path, "docx-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "docx-resource-1")]') def test_add_jpg_resource(self): path = os.path.abspath("resources/jpg_file.jpg") self.upload_valid_resource(path, "jpg-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "jpg-resource-1")]') def test_add_mp3_resource(self): path = os.path.abspath("resources/mp3_file.mp3") self.upload_valid_resource(path, "mp3-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "mp3-resource-1")]') def test_add_mp4_resource(self): path = os.path.abspath("resources/mp4_file.mp4") self.upload_valid_resource(path, "mp4-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "mp4-resource-1")]') def test_add_png_resource(self): path = os.path.abspath("resources/png_file.png") self.upload_valid_resource(path, "png-resource-1") assert self.wd.wait_for_xpath( '//td/div/p/a/strong[contains(text(), "png-resource-1")]') def tearDown(self): self.wd.quit()
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 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()
class LoginFailure(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_login_failure(self): self.open("/account/login/") self.wd.find_css('#id_login').send_keys("admin") self.wd.find_css("#id_password").send_keys('admin') self.wd.find_element_by_xpath('//button[@name="sign-in"]').click() elem = self.wd.find_element_by_xpath("//div[contains(@role, 'alert')]") assert elem != [] def tearDown(self): self.wd.quit()
class AnonymousUserProjectView(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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')]") def tearDown(self): self.wd.quit()
class PasswordReset(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_password_reset(self): self.user_login() self.wd.wait_for_css('.btn-user') self.open("/account/password/reset/") self.wd.find_css('#id_email').send_keys(Credentials.get_test_email()) self.wd.find_element_by_xpath( '//input[@value="Reset password"]').click() text = self.wd.find_element_by_xpath("//h1").text assert text == "Password reset" def tearDown(self): self.wd.quit()
class EmailChange(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_email_change(self): self.user_login() self.wd.wait_for_css('.btn-user') self.open("/account/profile/") self.wd.find_css('#id_email').clear() self.wd.find_css('#id_email').send_keys("*****@*****.**") self.wd.find_element_by_xpath('//button[@name="update"]').click() def tearDown(self): self.restore_username(Credentials.get_test_email()) self.wd.quit()
class FullnameChange(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_fullname_change(self): self.user_login() self.wd.wait_for_css('.btn-user') self.open("/account/profile/") self.wd.find_css('#id_full_name').clear() self.wd.find_css('#id_full_name').send_keys( "cadasta-test-user-1-fullname") self.wd.find_element_by_xpath('//button[@name="update"]').click() def tearDown(self): self.restore_fullname("") self.wd.quit()
class AddResource(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_add_resource(self): projects_page = ProjectsPage(self.wd, self) projects_page.go_to() resources_page = ResourcesPage(self.wd, self) resources_page.go_to() file_path = os.path.abspath("resources/pdf_file.pdf") resources_page.upload_resource(file_path, "resource-1") self.wd.wait_for_xpath("//h2[contains(text(), 'Resources')]") assert self.wd.find_element_by_xpath('//td/div/p/a/strong[contains(text(), "resource-1")]') def tearDown(self): self.wd.quit()
class AnonymousUserOrganizationView(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_anonymous_user_project_view(self): self.open("") self.wd.wait_for_css(".organizations") self.wd.find_element_by_link_text("Organizations").click() self.wd.wait_for_xpath("//h1[contains(text(), 'Organizations')]") self.wd.find_element_by_link_text( Organization.get_test_org_name()).click() self.wd.wait_for_xpath( "//h2[contains(text(), 'Organization Overview')]") assert self.wd.find_element_by_xpath("//div/section/p") def tearDown(self): self.wd.quit()
class ViewMemberProfile(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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 tearDown(self): self.wd.quit()
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()
class ViewMembers(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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 tearDown(self): self.wd.quit()
class Auth(SeleniumTestCase): def setUp(self): # setUp is where you setup call fixture creation scripts # and instantiate the WebDriver, which in turns loads up the browser. User.objects.create_superuser(username='******', password='******', email='*****@*****.**') # Instantiating the WebDriver will load your browser self.wd = CustomWebDriver() def tearDown(self): # Don't forget to call quit on your webdriver, so that # the browser is closed after the tests are ran self.wd.quit() # Just like Django tests, any method that is a Selenium test should # start with the "test_" prefix. def test_login(self): """ Django Admin login test """ # Open the admin index page self.open(reverse('admin:index')) # Selenium knows it has to wait for page loads (except for AJAX requests) # so we don't need to do anything about that, and can just # call find_css. Since we can chain methods, we can # call the built-in send_keys method right away to change the # value of the field self.wd.find_css('#id_username').send_keys("admin") # for the password, we can now just call find_css since we know the page # has been rendered self.wd.find_css("#id_password").send_keys('pw') # You're not limited to CSS selectors only, check # http://seleniumhq.org/docs/03_webdriver.html for # a more compreehensive documentation. self.wd.find_element_by_xpath('//input[@value="Log in"]').click() # Again, after submiting the form, we'll use the find_css helper # method and pass as a CSS selector, an id that will only exist # on the index page and not the login page self.wd.find_css(".dashboard")
class OrganizationArchive(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() 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_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 tearDown(self): self.wd.quit()
class ProjectAccessibility(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_public_project_to_private(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')]") 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')]") 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 UsernameChange(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_username_change(self): self.user_login() self.wd.wait_for_css('.btn-user') self.open("/account/profile/") self.wd.find_css('#id_username').clear() self.wd.find_css('#id_username').send_keys("cadasta-test-user-11") self.wd.find_element_by_xpath('//button[@name="update"]').click() # text = self.wd.find_elements_by_xpath("//span[@class, 'username')]").text # print text # assert text == "cadasta-test-user-11" def tearDown(self): self.restore_username(Credentials.get_test_username()) 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()
class EmptyPasswordValidation(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_empty_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('') self.wd.find_css("#id_password2").send_keys('XYZ#qwerty') self.wd.find_css("#id_full_name").send_keys('') action = ActionChains(self.wd) action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform() text = self.wd.wait_for_xpath( "//ul[contains(@class, 'parsley-errors-list')]").text assert text == "This field is required." def tearDown(self): self.wd.quit()
class PasswordValidation(SeleniumTestCase): def setUp(self): self.wd = CustomWebDriver() def test_invalid_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('password123') self.wd.find_css("#id_password2").send_keys('password123') self.wd.find_css("#id_full_name").send_keys('') action = ActionChains(self.wd) action.send_keys(Keys.TAB).send_keys(Keys.RETURN).perform() text = self.wd.wait_for_xpath( "//ul[contains(@class, 'parsley-errors-list')]").text assert text == "Your password must contain at least 3 of the following: lowercase characters, uppercase characters, special characters, and/or numerical characters." def tearDown(self): self.wd.quit()