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.forgon.disinfectsystem.AbstractCSSDTest; import test_4_1.apply.applyConstants.DeskIconEnum; import test_4_1.apply.chain.ChainConsumer; import test_4_1.sterilization.SterilizationTest; import test_4_1.tools.LoginUtil; import test_4_1.tools.Utils; /** * @author cherry 2017-02-06 * */ public class ALL extends AbstractCSSDTest { private Recyle recyle = new Recyle(); private Wash wash = new Wash(); private Assemble assemble = new Assemble(); private Review review = new Review(); private PackingHistory ph = new PackingHistory(); private Disinfection disinfection = new Disinfection(); private One_use one = new One_use(); private UserRecord userrecord = new UserRecord(); private Apply apply = new Apply(); boolean displayed = false; // @BeforeMethod private void before() { try { Utils.DateTime(); LoginUtil.loginWithClinical(); ChainConsumer.doBeforeApply(DeskIconEnum.GDSY); LoginUtil.loginWithClinical(); logger.info("申请开始.........."); // 然后再运行申请单的测试 ChainConsumer.doApplyForMultiple(DeskIconEnum.GDSY); logger.info("申请流程结束.........."); Utils.driver.quit(); } catch (Exception e) { logger.error(e, e); AssertJUnit.fail(e.getMessage()); } } @Test public void all() { try { initCSSDData(); before(); System.out.print("回收开始:"); Utils.DateTime(); Login login = new Login(); login.init(); final String SERVER_URL = Utils.settings.get("服务器地址").toString(); Utils.driver.get(SERVER_URL + "/?logonType=1080p"); login.login_secondSupplyRoom(false); /** 二级供应室回收 */ /** 二级供应室自定义入筐回收 */ recyle.recyle_custom(Utils.settings.getJSONObject("二级供应室清洗篮筐1") .getString("条码")); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 二级供应室判断消毒物品申请单是否存在 */ Utils.retryingFind(By.tagName("body")); WebElement element = Utils.retryingFindForthCellOfTable(By .id("awaitForRecycleTable")); if (element != null) { displayed = element.isDisplayed(); if (displayed) { recyle.recyle_SecondSupplyRoom(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); Utils.retryingFindAndClick(By.id("return")); Utils.waitUntilUrlChange(SERVER_URL + "/homepage/portalPage.jsp", 5); Utils.tryToCloseWarningWindow(); } } else { Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); Utils.retryingFindAndClick(By.id("return")); Utils.waitUntilUrlChange(SERVER_URL + "/homepage/portalPage.jsp", 5); Utils.tryToCloseWarningWindow(); } logger.info("二级供应室清洗成功"); /** 二级供应室清洗成功 */ wash.wash_secondSupplyRoom(); wash.after(); recyle.init(); /** 一级供应室回收带标识牌的回收单 */ recyle.recyle_recyleSignboardAndDropAndScrap(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("一级供应室回收带标识牌的回收单完成"); /** 一级供应室回收单确认 */ recyle.recyle_confirm_new(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("一级供应室回收单确认"); /** 一级供应室回收部分终止的单 */ recyle.recyle_oneSupplyRoom(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/recycleForTouchScreen.jsp?resolution=1980", 5); logger.info("一级供应室回收部分终止的单完成"); /** 切换篮筐并丢失材料 */ recyle.recyle_changeBasket(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("切换篮筐并丢失材料完成"); /** 一级供应室回收单确认 */ recyle.recyle_confirm_new(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("一级供应室回收单确认完成"); /** 一级供应室回收申请单 */ recyle.recyle_oneSupplyRoomSignboard(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("一级供应室回收申请单完成"); /** 一级供应室回收外来器械 */ recyle.recyle_Foreign_edit(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("一级供应室回收外来器械完成"); recyle.recyle_Foreign(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); logger.info("recyle_Foreign"); /** 判断自定义器械包申请单是否存在 */ Utils.retryingFind(By.tagName("body")); element = Utils.retryingFindForthCellOfTable(By .id("awaitForRecycleTable")); if (element != null) { displayed = element.isDisplayed(); } if (displayed) { recyle.recyle_customSet(); Utils.waitUntilUrlChange( SERVER_URL + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); } /** 判断消毒物品申请单是否存在 */ 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_touch(); wash.after(); wash.init(); // 一级供应室清洗并清洗添加材料 wash.wash_oneSupplyRoom(); // 清洗删除篮筐再添加篮筐,扫描不同的责任人 Utils.retryingFindAndClick(By .xpath("//button[contains(text(), '添加')]")); Utils.driver.switchTo().defaultContent(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); wash.wash_washChangeBasket(); Utils.retryingFindAndClick(By .xpath("//button[contains(text(), '添加')]")); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); // 清洗失败,重新清洗,清洗完成,清洗机需要设置为清洗确认 wash.wash_fail_reWash_Finish(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndClick(By .xpath("//span[contains(text(), '个人桌面')]")); /*** 材料入库报损丢失的材料 ***/ 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_unpackForgein(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); assemble.assemble_forgeinSet(); /*** 一级供应室审核外来器械 ***/ System.out.print("审核开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndClick(By .xpath("//span[contains(text(), '个人桌面')]")); Actions moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("reviewPacking"))) .perform(); Utils.retryingFindAndClick(By.linkText(Utils.settings .getJSONObject("一级供应室装配组").getString("名称3"))); Utils.retryingFindAndSwitchToFrame(By.id("iframe_reviewPacking")); // displayed = false; element = Utils.retryingFind(By .xpath("//button[contains(text(), '进入审核列表')]")); handleReview(element, review); Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("packing"))) .perform(); Utils.retryingFindAndClick(By.linkText(Utils.settings .getJSONObject("一级供应室装配组").getString("名称2"))); Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); /*** 一级供应室补充丢失的材料 ***/ assemble.assemble_supplementLoss(); /*** 一级供应室装配聚合包 ***/ Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); assemble.assemble_ComboTousse(); /*** 一级供应室装配消毒物品 ***/ Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); assemble.assemble_success1(); assemble.after(); /*** 一级供应室装配敷料包、器械包、自定义器械包 ***/ assemble.init(); assemble.assemble_Scrap(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); /*** * 屏蔽暂时不需要的代码 * **/ /*** * assemble.assemble_success1(); * Utils.driver.switchTo().defaultContent(); displayed = false; * WebElement element = Utils.retryingFind(By * .xpath("//button[contains(text(), '确定')]")); if (element != null) * { displayed = element.isDisplayed(); if (displayed) { * element.click(); } } **/ assemble.assemble_SignboardAndDrop(); assemble.assemble_dressing(); assemble.assemble_CustomSet(); /*** 一级供应室自定义装配 ***/ assemble.assemble_custom(); /*** 一级供应室修改历史装配 ***/ Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); ph.assemble_modifyTousse(); Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); /*** 一级供应室审核器械包、敷料包 ***/ moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("reviewPacking"))) .perform(); Utils.retryingFindAndClick(By.linkText(Utils.settings .getJSONObject("一级供应室装配组").getString("名称2"))); Utils.retryingFindAndSwitchToFrame(By.id("iframe_reviewPacking")); element = Utils.retryingFind(By .xpath("//button[contains(text(), '进入审核列表')]")); handleReview(element, review); /*** 一级供应室灭菌装载删除 ***/ disinfection.disinfection_loading(); //一级供应室灭菌 SterilizationTest.sterilizationSeriesOperationsOfFristSupplyRoom(); // System.out.print("灭菌开始:"); // Utils.DateTime(); // Utils.driver.switchTo().defaultContent(); // Utils.retryingFindAndClick(By // .xpath("//span[contains(text(), '个人桌面')]")); // moveover = new Actions(Utils.driver); // moveover.moveToElement( // Utils.retryingFind(By.id("sterilizationRecord"))).perform(); // Utils.retryingFindAndClick(By.linkText(Utils.settings // .getJSONObject("灭菌炉分组").getString("大型压力蒸汽"))); // Utils.retryingFindAndSwitchToFrame(By // .id("iframe_sterilizationRecord")); // Utils.retryingFindAndClick(By // .xpath("//button[contains(text(), '添加')]")); // Utils.driver.switchTo().defaultContent(); // currentwindowhandle = Utils.driver.getWindowHandle(); // Utils.driver.switchTo().window(currentwindowhandle); // disinfection.disinfection_failAndSuccess(); // disinfection.after(); /*** 一级供应室一次性物品 ***/ System.out.print("一次性物品开始:"); Utils.DateTime(); one.init(); one.One_use_Entry_success(); /*** 一级供应室发货 ***/ System.out.print("发货开始:"); Utils.DateTime(); Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); Delivery delivery = new Delivery(); Utils.retryingFindAndClick(By.id("invoicePlan")); Utils.retryingFindAndSwitchToFrame(By.id("iframe_invoicePlan")); String name = Utils.settings.getJSONObject("临床科室").getString("名称"); Utils.retryingFindAndClick(By.xpath("//a[contains(text(), '" + name + "')]")); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); delivery.Delivery_oneSupplyRoom(); delivery.Delivery_auxiliary(); delivery.Delivery_custom(); delivery.Delivery_TousseAndDressing(); delivery.after(); /*** 临床登记使用记录 ***/ System.out.print("登记使用记录开始:"); Utils.DateTime(); userrecord.init(); userrecord.UserRecord_success_ji(); /*** 临床归还借物 ***/ System.out.print("归还借物开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndClick(By .xpath("//span[contains(text(), '个人桌面')]")); apply.apply_borrow_return(); apply.after(); } catch (Exception e) { logger.error(e, e); AssertJUnit.fail(e.getMessage()); } } private void handleReview(WebElement element, Review review) { displayed = false; if (element != null) { if (element.isDisplayed()) { review.Review_batch(); } else { review.Review_single(); } } } @AfterTest public void afterMethod() { Utils.driver.quit(); } }