def test_case_doctor_agreement_add_001(self): '''创建家庭医生协议''' Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) userinfo = userList[0] username = userinfo.getAttribute("username") password = userinfo.getAttribute("passwd") # 从xml文件读取用户登录信息 LoginPageObject.test_login_common(username, password) agreementpage = Element.find_element(By.ID, "item-1010") agreementpage.click() time.sleep(2) agreementpage1 = Element.find_element(By.ID, "item-101002") agreementpage1.click() time.sleep(2) Browser.navigate_to(Conf.URL) Log.stop_test()
def test_login_common(cls, username, password, is_org=None): u"""登录操作""" name = Element.find_element(By.ID, "username") pwd = Element.find_element(By.ID, "password") submit_btn = Element.find_element(By.XPATH, "//button[@type='submit']") if is_org == "Y": province = Element.find_element(By.XPATH, ProvinceList) province.click() jiangsu = Element.find_element(By.XPATH, JiangSu) jiangsu.click() city = Element.find_element(By.XPATH, CityList) city.click() suzhou = Element.find_element(By.XPATH, SuZhou) suzhou.click() org = Element.find_element(By.XPATH, OrgList) org.click() jiulong = Element.find_element(By.XPATH, Jiulong) jiulong.click() name.send_keys(username) pwd.send_keys(password) submit_btn.click()
def test_case_login_003(self): '''错误用户名密码登录''' Conf.CASE_NAME = "test_case_login_003" Log.start_test(Conf.CASE_NAME) LoginPageObject.test_login_common("Errorname", "errorpassword") time.sleep(2) try: errormsg = Element.find_element( By.XPATH, "//section[@id='alertify-logs']/article").text expectmsg = "Bad username/password combination, please try again." Assert().assert_equal(errormsg, expectmsg, msg="wrong error message") except AssertionError, msg: raise AssertionError(msg)
def test_case_login_002(self): '''机构用户jl登录''' Conf.CASE_NAME = "test_case_login_002" Log.start_test(Conf.CASE_NAME) userinfo = userList[1] username = userinfo.getAttribute("username") password = userinfo.getAttribute("passwd") # 从xml文件读取用户登录信息 LoginPageObject.test_login_common(username, password, is_org="Y") try: pagename = Element.find_element(By.ID, "myConfig").text expectname = "九龙" Assert().assertEqual(pagename, expectname, msg='login with wrong name') except AssertionError, msg: raise AssertionError(msg)
def test_case_login_001(self): '''管理员admin登录''' Conf.CASE_NAME = "test_case_login_001" Log.start_test(Conf.CASE_NAME) userinfo = userList[0] username = userinfo.getAttribute("username") password = userinfo.getAttribute("passwd") # 从xml文件读取用户登录信息 print username LoginPageObject.test_login_common(username, password) try: pagename = Element.find_element(By.ID, "myConfig").text Assert().assertEqual(pagename, str(username), msg='login with wrong name') except AssertionError, msg: raise AssertionError(msg)
def test_case_archive_add_001(self): '''创建档案(必填项)''' Conf.CASE_NAME = "test_case_archive_add_001" Log.start_test(Conf.CASE_NAME) # userinfo = userList[1] # username = userinfo.getAttribute("username") # password = userinfo.getAttribute("passwd") # 从xml文件读取用户登录信息 archiveinfo = archiveList[0] idcard = archiveinfo.getAttribute("idcard") # 从xml文件读取添加档案信息 name = archiveinfo.getAttribute("name") org = archiveinfo.getAttribute("org") phone = archiveinfo.getAttribute("phone") address = archiveinfo.getAttribute("address") register = archiveinfo.getAttribute("register") LoginPageObject.test_login_common(self.username, self.password, is_org='Y') AddArchivePageObject.test_add_archive_required(idcard, name, org, phone, address, register) reload(sys) sys.setdefaultencoding("utf-8") try: archivename = Element.find_element( By.XPATH, "/html/body/div[3]/div[2]/div/div/div[3]/div[3]/div/table/tbody/tr[2]/td[3]" ).text Assert().assertEqual(name, str(archivename), msg='archive created successfully') except AssertionError, msg: raise AssertionError(msg)
def test_add_archive_required(cls, idcard, name, org, phone, address, registry): u"""添加档案-必填项""" driver = Conf.DRIVER archiveMenu = Element.find_element(By.ID, "item-1005") ActionChains(driver).move_to_element(archiveMenu).perform() time.sleep(1) archiveManagement = Element.find_element(By.ID, "item-100501") archiveManagement.click() time.sleep(1) Element.find_element(By.ID, "add").click() time.sleep(1) idcardfield = Element.find_element(By.ID, "idcard") idcardfield.send_keys(idcard) time.sleep(1) namefield = Element.find_element(By.ID, "name") namefield.send_keys(name) time.sleep(1) orgtree = Element.find_element(By.XPATH, "/html/body/div[6]/div[3]") ActionChains(driver).move_to_element(orgtree).perform() time.sleep(1) orgfield = Element.find_element(By.ID, org) orgfield.click() time.sleep(1) phonefield = Element.find_element(By.ID, "phone") phonefield.send_keys(phone) time.sleep(1) addressfield = Element.find_element(By.ID, "address") addressfield.send_keys(address) time.sleep(1) registryfield = Element.find_element(By.ID, "registry") registryfield.send_keys(registry) time.sleep(1) submit_btn = Element.find_element(By.ID, "btn-submit") submit_btn.click()