class TestCaseSearch(TestCase): @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver def test_case_search_001(self): Conf.CASE_NAME = "test_case_search_001" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common('EDPRBI', 'test') Log.stop_test() def test_case_search_002(self): Conf.CASE_NAME = "test_case_search_002" Log.start_test(Conf.CASE_NAME) POFS_OVERVIEW_SEARCH = Element.find_element( By.XPATH, u'//a[@id="b"][@href="overview/overview.jsp"]') POFS_OVERVIEW_SEARCH.click() POFS_EXPTYPE = Element.find_elements( By.XPATH, u'//select[@name="exportType"]/option') POFS_EXPTYPE_CONTENT = Element.get_spinner_values( By.XPATH, u'//select[@name="exportType"]/option') Element.choose_spinner_value(POFS_EXPTYPE, POFS_EXPTYPE_CONTENT, "LCL") POFS_PO_ISSUE_DATE = Element.find_element( By.XPATH, u'//img[@src="../images/cal.gif"]') POFS_PO_ISSUE_DATE.click() Browser.switch_to_new_window() Element.date_picker(31, 1, 2008) Browser.switch_to_default_window() POFS_SEARCH = Element.find_element(By.NAME, u'submit') POFS_SEARCH.click() POFS_DETAIL = Element.find_element( By.XPATH, u'//img[@src="../images/detail.gif"]') POFS_DETAIL.click() Browser.switch_to_new_window() POFS_PONUMBER = Element.find_element( By.XPATH, u'//*[@id="printable"]/table/tbody/tr[1]/td/table/tbody/tr[2]/td[2]' ) Assert().assert_equal(POFS_PONUMBER.text, "0000434") Browser.close_window() Browser.switch_to_default_window() Log.stop_test() @classmethod def tearDownClass(self): self.driver.quit()
class TestCaseSearch(TestCase): @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver def test_case_search_001(self): Conf.CASE_NAME = "test_case_search_001" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common('EDPRBI', 'test') Log.stop_test() def test_case_search_002(self): Conf.CASE_NAME = "test_case_search_002" Log.start_test(Conf.CASE_NAME) POFS_OVERVIEW_SEARCH = Element.find_element(By.XPATH, u'//a[@id="b"][@href="overview/overview.jsp"]') POFS_OVERVIEW_SEARCH.click() POFS_EXPTYPE = Element.find_elements(By.XPATH, u'//select[@name="exportType"]/option') POFS_EXPTYPE_CONTENT = Element.get_spinner_values(By.XPATH, u'//select[@name="exportType"]/option') Element.choose_spinner_value(POFS_EXPTYPE, POFS_EXPTYPE_CONTENT, "LCL") POFS_PO_ISSUE_DATE = Element.find_element(By.XPATH, u'//img[@src="../images/cal.gif"]') POFS_PO_ISSUE_DATE.click() Browser.switch_to_new_window() Element.date_picker(31, 1, 2008) Browser.switch_to_default_window() POFS_SEARCH = Element.find_element(By.NAME, u'submit') POFS_SEARCH.click() POFS_DETAIL = Element.find_element(By.XPATH, u'//img[@src="../images/detail.gif"]') POFS_DETAIL.click() Browser.switch_to_new_window() POFS_PONUMBER = Element.find_element(By.XPATH, u'//*[@id="printable"]/table/tbody/tr[1]/td/table/tbody/tr[2]/td[2]') Assert().assert_equal(POFS_PONUMBER.text, "0000434") Browser.close_window() Browser.switch_to_default_window() Log.stop_test() @classmethod def tearDownClass(self): self.driver.quit()
class TestCaseRegister(TestCase): def setUp(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30) def test_case_001_register(self): Conf.CASE_NAME = "test_case_001_register" Log.start_test(Conf.CASE_NAME) PAN_C = Element.find_element(self.driver, By.ID, u'login-create') print PAN_C.text Log.stop_test() def tearDown(self): self.driver.quit()
class TestCaseForgetPassword(TestCase): def setUp(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30) def test_case_001_forget_password(self): Conf.CASE_NAME = "test_case_001_forget_password" Log.start_test(Conf.CASE_NAME) Element.find_element(self.driver, By.CLASS_NAME, u'pass-fgtpwd').click() Log.stop_test() def tearDown(self): self.driver.quit()
class TestCaseLogout(TestCase): @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver def setUp(self): pass def test_case_logout_001(self): '''Login page, write username and password''' Conf.CASE_NAME = "test_case_logout_001" Log.start_test(Conf.CASE_NAME) #Login CommonMethod.test_pofs_login_common() #Logout self.POFS_LOGOUT = Element.find_element(By.XPATH, u'//a[@href="login/logout.jsp"]') Assert().assert_equal(self.POFS_LOGOUT.text, "Log Out") self.POFS_LOGOUT.click() self.POFS_LOGOUT_MESSAGE = Element.find_element(By.XPATH, u'//td[@align="right"][@style=" color: red;"]').text print self.POFS_LOGOUT_MESSAGE Assert().assert_equal(self.POFS_LOGOUT_MESSAGE, "You are successfully logged out") Log.stop_test() def tearDown(self): pass @classmethod def tearDownClass(self): self.driver.quit()
def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver
def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30)
class TestCaseLogin(TestCase): """ http://my.oschina.net/lionets/blog/268704 """ @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30) def test_case_login_001(self): u"""This is comment of test_case_login_001 shown in report""" Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys("jiefenggao") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys("P@ssw0rd") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() # self.driver.get(Conf.URL) Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() def test_case_login_002(self): u"""This is comment of test_case_login_002 shown in report""" Conf.CASE_NAME = "test_case_login_002" Log.start_test(Conf.CASE_NAME) Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys("jiefenggaoa") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys("P@ssw0rd") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() def test_case_login_003(self): u"""This is comment of test_case_login_003 shown in report""" Conf.CASE_NAME = "test_case_login_003" Log.start_test(Conf.CASE_NAME) excel = Datadriver.ExcelSheet(r"Employee.xlsx", "Sheet1") for i in range(1, excel.nrows()): employeeID = excel.cell(i, "Empoyee_ID") password = excel.cell(i, "Password") expect = excel.cell(i, "Expect") if employeeID !="": Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys(employeeID) if password != "": Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys(password) Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() print Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text if expect == "expect_result_1": # Maybe the element should be asserted is the same one. # Change it in every iteration. Assert().assert_equal(Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) elif expect == "expect_result_2": Assert().assert_equal(Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) elif expect == "expect_result_3": Assert().assert_equal(Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) else: return None # self.driver.get(Conf.URL) Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() @classmethod def tearDownClass(self): self.driver.quit()
class TestCaseLogin(TestCase): """ http://my.oschina.net/lionets/blog/268704 """ @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver def setUp(self): pass def test_case_login_001(self): '''Login page, write username and password''' Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common("EDPRBI", "test") Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_002(self): '''Login page, reset button''' Conf.CASE_NAME = "test_case_login_002" Log.start_test(Conf.CASE_NAME) self.POFS_USERNAME = Element.find_element(By.NAME, u'userName') self.POFS_PASSWORD = Element.find_element(By.NAME, u'password') self.POFS_RESET = Element.find_element( By.XPATH, u'//input[@type="reset"][@value="Reset"]') self.POFS_USERNAME.send_keys("EDPRBI") self.POFS_PASSWORD.send_keys("test") self.POFS_RESET.click() username = self.driver.execute_script( "var input = document.getElementsByName('userName')[0].value;return input" ) password = self.driver.execute_script( "var input = document.getElementById('password').value;return input" ) Assert().assert_equal(username, "") Assert().assert_equal(password, "") if username == "" and password == "": print "pass" else: print "fail" # self.driver.get(Conf.URL) Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_003(self): '''Login page, wrong username and correct password''' Conf.CASE_NAME = "test_case_login_003" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common("EDPRBIa", "test") error_message = Element.find_element( By.XPATH, u'//td[@class="subhead"][@align="center"]').text Assert().assert_equal(error_message, "Invalid UserID or Password. Attempt 1 of 6.") # self.driver.get(Conf.URL) Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_004(self): excel = Datadriver.ExcelSheet(r"Employee.xlsx", "Sheet1") for i in range(1, excel.nrows()): employeeID = excel.cell(i, "Empoyee_ID") password = excel.cell(i, "Password") department = excel.cell(i, "Department") hiredate = excel.cell(i, "Date_Of_Hiring") role = excel.cell(i, "Employee_Role") fname = excel.cell(i, "F_Name") acountry = excel.cell(i, "Bj") nationality = excel.cell(i, "Nationality") if employeeID != "": print employeeID if password != "": print password print type(password) if department != "": print department print type(department) if hiredate != "": print hiredate if role != "": print role if fname != "": print fname if acountry != "": print acountry if nationality != "": print nationality def tearDown(self): pass @classmethod def tearDownClass(self): self.driver.quit()
def setUp(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30)
def setUpClass(self): Conf.DRIVER = self.driver = LoginApp().sysLogin() self.driver.implicitly_wait(30)
class TestCaseLogin(TestCase): """ http://my.oschina.net/lionets/blog/268704 """ @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver def setUp(self): pass def test_case_login_001(self): '''Login page, write username and password''' Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common("EDPRBI", "test") Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_002(self): '''Login page, reset button''' Conf.CASE_NAME = "test_case_login_002" Log.start_test(Conf.CASE_NAME) self.POFS_USERNAME = Element.find_element(By.NAME, u'userName') self.POFS_PASSWORD = Element.find_element(By.NAME, u'password') self.POFS_RESET = Element.find_element(By.XPATH, u'//input[@type="reset"][@value="Reset"]') self.POFS_USERNAME.send_keys("EDPRBI") self.POFS_PASSWORD.send_keys("test") self.POFS_RESET.click() username = self.driver.execute_script("var input = document.getElementsByName('userName')[0].value;return input") password = self.driver.execute_script("var input = document.getElementById('password').value;return input") Assert().assert_equal(username, "") Assert().assert_equal(password, "") if username == "" and password == "": print "pass" else: print "fail" # self.driver.get(Conf.URL) Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_003(self): '''Login page, wrong username and correct password''' Conf.CASE_NAME = "test_case_login_003" Log.start_test(Conf.CASE_NAME) CommonMethod.test_pofs_login_common("EDPRBIa", "test") error_message = Element.find_element(By.XPATH, u'//td[@class="subhead"][@align="center"]').text Assert().assert_equal(error_message, "Invalid UserID or Password. Attempt 1 of 6.") # self.driver.get(Conf.URL) Browser.navigate_to(Conf.URL) Log.stop_test() def test_case_login_004(self): excel = Datadriver.ExcelSheet(r"Employee.xlsx", "Sheet1") for i in range(1, excel.nrows()): employeeID = excel.cell(i, "Empoyee_ID") password = excel.cell(i, "Password") department=excel.cell(i,"Department") hiredate=excel.cell(i,"Date_Of_Hiring") role=excel.cell(i,"Employee_Role") fname=excel.cell(i,"F_Name") acountry=excel.cell(i,"Bj") nationality=excel.cell(i,"Nationality") if employeeID !="": print employeeID if password != "": print password print type(password) if department !="": print department print type(department) if hiredate!="": print hiredate if role!="": print role if fname!="": print fname if acountry!="": print acountry if nationality !="": print nationality def tearDown(self): pass @classmethod def tearDownClass(self): self.driver.quit()
class TestCaseLogin(TestCase): """ http://my.oschina.net/lionets/blog/268704 """ @classmethod def setUpClass(self): self.driver = LoginApp().sysLogin() Conf.DRIVER = self.driver self.driver.implicitly_wait(30) def test_case_login_001(self): u"""This is comment of test_case_login_001 shown in report""" Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) Element.find_element( self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys("jiefenggao") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys("P@ssw0rd") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() # self.driver.get(Conf.URL) Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() def test_case_login_002(self): u"""This is comment of test_case_login_002 shown in report""" Conf.CASE_NAME = "test_case_login_002" Log.start_test(Conf.CASE_NAME) Element.find_element( self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys("jiefenggaoa") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys("P@ssw0rd") Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() def test_case_login_003(self): u"""This is comment of test_case_login_003 shown in report""" Conf.CASE_NAME = "test_case_login_003" Log.start_test(Conf.CASE_NAME) excel = Datadriver.ExcelSheet(r"Employee.xlsx", "Sheet1") for i in range(1, excel.nrows()): employeeID = excel.cell(i, "Empoyee_ID") password = excel.cell(i, "Password") expect = excel.cell(i, "Expect") if employeeID != "": Element.find_element( self.driver, By.ID, u'TANGRAM__PSP_4__userName').send_keys(employeeID) if password != "": Element.find_element( self.driver, By.ID, u'TANGRAM__PSP_4__password').send_keys(password) Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__submit').click() print Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text if expect == "expect_result_1": # Maybe the element should be asserted is the same one. # Change it in every iteration. Assert().assert_equal( Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) elif expect == "expect_result_2": Assert().assert_equal( Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) elif expect == "expect_result_3": Assert().assert_equal( Element.find_element(self.driver, By.ID, u'TANGRAM__PSP_4__error').text, expect) else: return None # self.driver.get(Conf.URL) Browser.navigate_to(self.driver, Conf.URL) Log.stop_test() @classmethod def tearDownClass(self): self.driver.quit()