package test_4_1; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.testng.AssertJUnit; import org.testng.annotations.AfterTest; import org.testng.annotations.Test; import test_4_1.tools.Utils; /** * @author cherry 2017-02-06 * */ public class ALL { // @BeforeMethod public void before() { try { System.out.print("申请开始:"); Utils.DateTime(); Login login = new Login(); login.init(); login.login_clinicNoWarnig(); Apply apply = new Apply(); /** 省医流程 */ boolean displayed = false; WebElement element = Utils.retryingFind(By .id("recyclingApplicationVersion2")); if (element != null) { displayed = element.isDisplayed(); } if (displayed) { Utils.retryingFind(By.id("recyclingApplicationVersion2")) .click(); WebElement frame = Utils.retryingFind(By .id("iframe_recyclingApplicationVersion2")); Utils.driver.switchTo().frame(frame); Utils.retryingFind(By.id("tousseApplication")).click(); /** 申请器械包、敷料包 */ apply.apply_gdsy_sets(); Utils.driver.switchTo().frame(frame); /** 申请一次性物品 */ Utils.retryingFind(By.id("diposableGoodsApplication")).click(); apply.apply_gdsy_oneuse(); Utils.driver.switchTo().frame(frame); /** 申请消毒物品 */ Utils.retryingFind(By.id("disinfectGoodsApplication")).click(); apply.apply_gdsy_sterilize(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Utils.retryingFind(By.id("borrowManager")).click(); frame = Utils.retryingFind(By.id("iframe_borrowManager")); Utils.driver.switchTo().frame(frame); Utils.retryingFind(By.xpath("//button[contains(text(), '借物')]")) .click(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); /** 申请借物 */ apply.apply_borrow(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Utils.retryingFind(By.id("foreignTousseApplication")).click(); frame = Utils.retryingFind(By .id("iframe_foreignTousseApplication")); Utils.driver.switchTo().frame(frame); Utils.retryingFind(By.xpath("//button[contains(text(), '添加')]")) .click(); /** 申请外来器械 */ apply.apply_foreignSetInformation(); Utils.driver.switchTo().frame(frame); Utils.retryingFind(By.xpath("//button[contains(text(), '添加')]")) .click(); apply.apply_foreignSet(); apply.after(); } else { element = Utils.retryingFind(By.id("recyclingApplication")); if (element != null) { displayed = element.isDisplayed(); } if (displayed) { Utils.retryingFind(By.id("recyclingApplication")).click(); WebElement frame = Utils.retryingFind(By .id("iframe_recyclingApplication")); Utils.driver.switchTo().frame(frame); element = Utils.retryingFind(By .xpath("//button[contains(text(), '申请消毒物品')]")); if (element != null) { displayed = element.isDisplayed(); } /** 其他医院流程_非通用申请单 */ if (displayed) { /** 申请消毒物品 */ apply.apply_sterilize(); /** 申请器械包、敷料包 */ apply.apply_set(); /** 申请一次性物品 */ apply.apply_oneuse(); } /** 其他医院流程_通用申请单 */ else { Utils.retryingFind( By.xpath("//button[contains(text(), '申请物品')]")) .click(); Utils.driver.switchTo().defaultContent(); String currentwindowhandle = Utils.driver .getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); /** 向二级供应室申请器械包、敷料包 */ apply.apply_secondSupplyRoom(); /** 向一级供应室申请器械包、敷料包、一次性物品 */ apply.apply_oneSupplyRoom(); } frame = Utils.retryingFind(By .id("iframe_recyclingApplication")); Utils.driver.switchTo().frame(frame); Utils.retryingFind( By.xpath("//button[contains(text(), '借物')]")) .click(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); /** 申请借物 */ apply.apply_borrow(); /** 申请自定义器械 */ apply.apply_custom(); Utils.driver.switchTo().frame(frame); /** 申请外来器械 */ Utils.retryingFind( By.xpath("//button[contains(text(), '申请外来器械')]")) .click(); apply.apply_foreignSetInformation(); Utils.driver.switchTo().frame(frame); Utils.retryingFind( By.xpath("//button[contains(text(), '申请外来器械')]")) .click(); apply.apply_foreignSet(); apply.after(); } } } catch (Exception e) { e.printStackTrace(); AssertJUnit.fail(e.getMessage()); } } @Test public void all() { try { // before(); boolean displayed = false; System.out.print("回收开始:"); Utils.DateTime(); /** 回收 */ Recyle recyle = new Recyle(); recyle.init(); /** 一级供应室回收带标识牌的回收单 */ // recyle.recyle_recyleSignboardAndDropAndScrap(); /** 一级供应室回收单确认 */ // recyle.recyle_confirm_new(); /** 一级供应室回收申请单 */ recyle.recyle_oneSupplyRoomSignboard(); /** 判断自定义器械包申请单是否存在 */ Utils.retryingFind(By.tagName("body")); WebElement element = Utils.retryingFindForthCellOfTable(By .id("awaitForRecycleTable")); if (element != null) { displayed = element.isDisplayed(); } if (displayed) { recyle.recyle_customSet(); } recyle.after(); recyle.init(); /** 一级供应室回收外来器械 */ recyle.recyle_Foreign_edit(); recyle.recyle_Foreign(); /** 判断消毒物品申请单是否存在 */ Utils.retryingFind(By.tagName("body")); element = Utils.retryingFindForthCellOfTable(By .id("awaitForRecycleTable")); if (element != null) { displayed = element.isDisplayed(); if (displayed) { recyle.recyle_customSet(); recyle.after(); } } else { recyle.after(); } /*** 一级供应室清洗 ***/ System.out.print("清洗开始:"); Utils.DateTime(); Wash wash = new Wash(); wash.init(); wash.wash_oneSupplyRoom(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); /*** 材料入库报损丢失的材料 ***/ System.out.print("报损补充开始:"); Utils.DateTime(); Materials_Godown_Entry entry = new Materials_Godown_Entry(); entry.Materials_Godown_Entry_choice(); /*** 一级供应室装配外来器械 ***/ System.out.print("装配开始:"); Utils.DateTime(); Assemble assemble = new Assemble(); assemble.assemble_unpackForgein(); Utils.driver.switchTo().defaultContent(); WebElement frame = Utils.retryingFind(By.id("iframe_packing")); Utils.driver.switchTo().frame(frame); assemble.assemble_forgeinSet(); /*** 一级供应室审核外来器械 ***/ System.out.print("审核开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Actions moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("reviewPacking"))) .perform(); Utils.retryingFind( By.linkText(Utils.settings.getJSONObject("一级供应室装配组") .getString("名称3"))).click(); frame = Utils.retryingFind(By.id("iframe_reviewPacking")); Utils.driver.switchTo().frame(frame); Review review = new Review(); displayed = false; element = Utils.retryingFind(By .xpath("//button[contains(text(), '进入审核列表')]")); if (element != null) { displayed = element.isDisplayed(); if (displayed) { review.Review_batch(); } else { review.Review_single(); } } /*** 一级供应室装配消毒物品 ***/ Utils.driver.navigate().refresh(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("packing"))) .perform(); Utils.retryingFind( By.linkText(Utils.settings.getJSONObject("一级供应室装配组") .getString("名称2"))).click(); frame = Utils.retryingFind(By.id("iframe_packing")); Utils.driver.switchTo().frame(frame); assemble.assemble_success1(); assemble.after(); /*** 一级供应室装配敷料包、器械包、自定义器械包 ***/ assemble.init(); assemble.assemble_Scrap(); Utils.driver.switchTo().defaultContent(); frame = Utils.retryingFind(By.id("iframe_packing")); Utils.driver.switchTo().frame(frame); assemble.assemble_success1(); Utils.driver.switchTo().defaultContent(); displayed = false; element = Utils.retryingFind(By .xpath("//button[contains(text(), '确定')]")); if (element != null) { displayed = element.isDisplayed(); if (displayed) { element.click(); } } assemble.assemble_dressing(); assemble.assemble_CustomSet(); assemble.assemble_SignboardAndDrop(); /*** 一级供应室自定义装配 ***/ assemble.assemble_custom(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); /*** 一级供应室审核器械包、敷料包 ***/ moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("reviewPacking"))) .perform(); Utils.retryingFind( By.linkText(Utils.settings.getJSONObject("一级供应室装配组") .getString("名称1"))).click(); frame = Utils.retryingFind(By.id("iframe_reviewPacking")); Utils.driver.switchTo().frame(frame); displayed = false; element = Utils.retryingFind(By .xpath("//button[contains(text(), '进入审核列表')]")); if (element != null) { displayed = element.isDisplayed(); if (displayed) { review.Review_batch(); } else { review.Review_single(); } } /*** 一级供应室灭菌 ***/ System.out.print("灭菌开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Disinfection disinfection = new Disinfection(); moveover = new Actions(Utils.driver); moveover.moveToElement( Utils.retryingFind(By.id("sterilizationRecord"))).perform(); Utils.retryingFind( By.linkText(Utils.settings.getJSONObject("一级供应室灭菌炉") .getString("分类"))).click(); frame = Utils.retryingFind(By.id("iframe_sterilizationRecord")); Utils.driver.switchTo().frame(frame); Utils.retryingFind(By.xpath("//button[contains(text(), '添加')]")) .click(); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); disinfection.disinfection_failAndSuccess(); disinfection.after(); /*** 一级供应室一次性物品 ***/ System.out.print("一次性物品开始:"); Utils.DateTime(); One_use one = new One_use(); one.init(); one.One_use_Entry_success(); /*** 一级供应室发货 ***/ System.out.print("发货开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Delivery delivery = new Delivery(); Utils.retryingFind(By.id("invoicePlan")).click(); frame = Utils.retryingFind(By.id("iframe_invoicePlan")); Utils.driver.switchTo().frame(frame); String name = Utils.settings.getJSONObject("临床科室").getString("名称"); Utils.retryingFind( By.xpath("//a[contains(text(), '" + name + "')]")).click(); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); delivery.Delivery_oneSupplyRoom(); delivery.after(); /*** 临床登记使用记录 ***/ System.out.print("登记使用记录开始:"); Utils.DateTime(); UserRecord userrecord = new UserRecord(); userrecord.init(); userrecord.UserRecord_success_ji(); /*** 临床归还借物 ***/ System.out.print("归还借物开始:"); Utils.DateTime(); Utils.retryingFind(By.xpath("//span[contains(text(), '个人桌面')]")) .click(); Apply apply = new Apply(); apply.apply_borrow_return(); apply.after(); } catch (Exception e) { e.printStackTrace(); AssertJUnit.fail(e.getMessage()); } } @AfterTest public void afterMethod() { Utils.driver.quit(); } }