class AccountLogin(Super): def setUp(self): Super.setUp(self) self.user = TemporaryUser("*****@*****.**"); self.user.create() def test_account_login(self): browser = self.browser browser.get(self.base_url + "/begin.do") self.click_and_wait_for_refresh(self.findLink("Log in")) browser.find_element_by_name("username").clear() browser.find_element_by_name("username").send_keys(self.user.name) browser.find_element_by_name("password").clear() browser.find_element_by_name("password").send_keys(self.user.password) self.click_and_wait_for_refresh(browser.find_element_by_name("action")) # Long emails are truncated and appended with an ellipsis, # so we can't assert by comparing user.name to what's on the DOM. # Look for Log out link instead? log_out = self.findLink("Log out") self.assertTrue(log_out.is_displayed()) def tearDown(self): self.user.delete()
class AccountLogin(Super): def setUp(self): Super.setUp(self) self.user = TemporaryUser("*****@*****.**") self.user.create() def test_account_login(self): browser = self.browser browser.get(self.base_url + "/begin.do") self.click_and_wait_for_refresh(self.findLink("Log in")) browser.find_element_by_name("username").clear() browser.find_element_by_name("username").send_keys(self.user.name) browser.find_element_by_name("password").clear() browser.find_element_by_name("password").send_keys(self.user.password) self.click_and_wait_for_refresh(browser.find_element_by_name("action")) # Long emails are truncated and appended with an ellipsis, # so we can't assert by comparing user.name to what's on the DOM. # Look for Log out link instead? log_out = self.findLink("Log out") self.assertTrue(log_out.is_displayed()) def tearDown(self): self.user.delete()
class TemplatesMyStarTest(Super): def setUp(self): Super.setUp(self) self.user = TemporaryUser("*****@*****.**"); self.user.create() def test_templates_my_star(self): browser = self.browser browser.get(self.base_url + "/login.do") browser.find_element_by_name("username").clear() browser.find_element_by_name("username").send_keys(self.user.name) browser.find_element_by_name("password").clear() browser.find_element_by_name("password").send_keys(self.user.password) browser.find_element_by_name("action").click() custom_template = """ <template name="My_Template_1" title="My Template 1" comment=""> <query name="CEO_Rivals" model="testmodel" view="CEO.name CEO.salary CEO.seniority CEO.company.name" longDescription=""> <constraint path="CEO.name" editable="true" op="!=" value="EmployeeB1"/> </query> </template>""" # Create a template browser.get(self.base_url + "/import.do") self.wait_for_elem('#xml').send_keys(custom_template) browser.find_element_by_css_selector("div > input[type=\"submit\"]").click() browser.get(self.base_url + "/templates.do") # Confirm that we have two visible non favorite templates self.assert_visible_id("all_templates_template_item_line_Underwater_People") self.assert_visible_id("all_templates_template_item_line_CEO_Rivals") # Add a template to our favorites browser.find_element_by_id("favourite_ManagerLookup").click() # Show only our favorites browser.find_element_by_id("filter_favourites_all_templates_template").click() # Confirm that our non-favorite templates are gone self.assert_invisible_id("all_templates_template_item_line_Underwater_People") self.assert_invisible_id("all_templates_template_item_line_CEO_Rivals") # Confirm that our favorite templates is visible self.assert_visible_id("all_templates_template_item_line_ManagerLookup") # Turn off the favorites filter browser.find_element_by_id("filter_favourites_all_templates_template").click() # Show only MY filters browser.find_element_by_id("filter_scope_all_templates_template").click() # Confirm that we see our template self.assert_visible_id("all_templates_template_item_line_My_Template_1") # Confirm that we don't see others self.assert_invisible_id("all_templates_template_item_line_Underwater_People") self.assert_invisible_id("all_templates_template_item_line_CEO_Rivals") self.assert_invisible_id("all_templates_template_item_line_ManagerLookup") def assert_visible_id(self, id): elem = self.wait().until(lambda d: d.find_element_by_id(id)) self.wait().until(lambda d: elem.is_displayed()) self.assertTrue(elem.is_displayed()) def assert_invisible_id(self, id): elem = self.wait().until(lambda d: d.find_element_by_id(id)) self.wait().until_not(lambda d: elem.is_displayed()) self.assertFalse(elem.is_displayed()) def tearDown(self): self.user.delete()
def setUp(self): Super.setUp(self) self.user = TemporaryUser("*****@*****.**"); self.user.create()
class AccountPersistentSettings(Super): def setUp(self): Super.setUp(self) self.user = TemporaryUser("*****@*****.**"); self.user.create() def test_account_persistent_settings(self): browser = self.browser self.login() # Make sure that our checkboxes are set to on checkbox_donotspam = self.wait().until(lambda d: d.find_element_by_name('do_not_spam')) checkbox_hidden = browser.find_element_by_name("hidden") checkbox_donotspam.click() if checkbox_donotspam.is_selected() else False checkbox_hidden.click() if checkbox_hidden.is_selected() else False # Checkboxes are now off. # Now fill out our field values: alias = browser.find_element_by_name('alias') email = browser.find_element_by_name('email') alias.clear() alias.send_keys("Temporary Display Name") browser.find_element_by_xpath("//div[@id='pagecontentmax']/div[4]/div/table/tbody/tr[3]/td[2]/form/button").click() email.clear() email.send_keys("*****@*****.**") browser.find_element_by_xpath("//div[@id='pagecontentmax']/div[4]/div/table/tbody/tr[4]/td[2]/form/button").click() self.findLink("Log out").click() # Log back in and confirm the settings have stuck: self.login() checkbox_donotspam = self.wait().until(lambda d: d.find_element_by_name('do_not_spam')) checkbox_hidden = browser.find_element_by_name("hidden") self.assertEqual(False, checkbox_donotspam.is_selected()) self.assertEqual(False, checkbox_hidden.is_selected()) # self.assertEqual("Temporary Display Name", browser.find_element_by_name("alias").get_attribute("value")) self.assertEqual("*****@*****.**", browser.find_element_by_name("email").get_attribute("value")) # Reverse the values checkbox_donotspam.click() checkbox_hidden.click() alias = browser.find_element_by_name('alias') email = browser.find_element_by_name('email') alias.clear() browser.find_element_by_xpath("//div[@id='pagecontentmax']/div[4]/div/table/tbody/tr[3]/td[2]/form/button[2]").click() email.clear() browser.find_element_by_xpath("//div[@id='pagecontentmax']/div[4]/div/table/tbody/tr[4]/td[2]/form/button[2]").click() browser.find_element_by_link_text("Log out").click() # Finally, log back in and make sure the values are back to the original self.login() # Get our checkboxes again checkbox_donotspam = self.wait().until(lambda d: d.find_element_by_name('do_not_spam')) checkbox_hidden = browser.find_element_by_name("hidden") self.assertEqual(True, checkbox_donotspam.is_selected()) self.assertEqual(True, checkbox_hidden.is_selected()) # The following MIGHT be broken on the testmodel? # self.assertEqual("Temporary Display Name", browser.find_element_by_name("alias").get_attribute("value")) self.assertEqual("", browser.find_element_by_name("email").get_attribute("value")) def login(self): browser = self.browser browser.get(self.base_url + "/login.do?returnto=%2Fmymine.do?subtab=account") uname = self.wait().until(lambda d: d.find_element_by_name('username'), 'username not found') pword = browser.find_element_by_name('password') uname.clear() uname.send_keys(self.user.name) pword.clear() pword.send_keys(self.user.password) self.click_and_wait_for_refresh(browser.find_element_by_name("action")) def is_element_present(self, how, what): try: self.browser.find_element(by=how, value=what) except NoSuchElementException, e: return False return True