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.tools.Utils; /** * @author cherry 2017-02-06 * */ public class ALL extends AbstractCSSDTest { private void doLogin() { Login login = new Login(); login.init(); login.login_clinicNoWarnig(); } // @BeforeMethod public void before() { try { System.out.print("申请开始:"); Utils.DateTime(); this.doLogin(); // 首先运行申请一张申请单,然后删除申请单 ChainConsumer.doDelete(DeskIconEnum.OTHER); Utils.driver.quit(); this.doLogin(); // 然后再运行申请单的测试 ChainConsumer.doApplyForMultiple(DeskIconEnum.OTHER); Utils.driver.quit(); } catch (Exception e) { e.printStackTrace(); AssertJUnit.fail(e.getMessage()); } } @Test public void all() { try { initCSSDData(); before(); boolean displayed = false; System.out.print("回收开始:"); Utils.DateTime(); /** 回收 */ Recyle recyle = new Recyle(); recyle.init(); /** 切换篮筐并丢失材料 */ recyle.recyle_changeBasket(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 一级供应室回收单确认 */ recyle.recyle_confirm_new(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 一级供应室回收带标识牌的回收单 */ recyle.recyle_recyleSignboardAndDropAndScrap(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 一级供应室回收单确认 */ recyle.recyle_confirm_new(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 一级供应室回收申请单 */ recyle.recyle_oneSupplyRoomSignboard(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); /** 一级供应室回收外来器械 */ recyle.recyle_Foreign_edit(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/disinfectsystem/touchScreen/recycle/awaitForRecycleList.jsp?resolution=1980", 5); recyle.recyle_Foreign(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/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_customSet(); Utils.waitUntilUrlChange( Utils.settings.get("服务器地址").toString() + "/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 = new Wash(); wash.init(); // 一级供应室清洗成功 wash.wash_oneSupplyRoom(); // 清洗添加材料 wash.wash_washAddMaterial(); // 清洗删除篮筐再添加篮筐,扫描不同的责任人 wash.wash_washChangeBasket(); String rinserBarcode = Utils.settings.getJSONObject("一级供应室清洗机").getString("清洗机条码"); setRinserNeedConfirmByBarcode(rinserBarcode); // 清洗需要确认测试场景 wash.wash_needConfirmFinish(); // 清洗失败,重新清洗,清洗完成,清洗机需要设置为清洗确认 wash.wash_fail_reWash_Finish(); cleanRinserNeedConfirmByBarcode(rinserBarcode); // 触摸屏清洗 wash.wash_touch(); // 二级供应室清洗成功 wash.wash_secondSupplyRoom(); wash.after(); 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 = new Assemble(); assemble.assemble_unpackForgein(); Utils.driver.switchTo().defaultContent(); WebElement frame = 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"))); frame = Utils.retryingFindAndSwitchToFrame(By .id("iframe_reviewPacking")); 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); Utils.tryToCloseWarningWindow(); moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.retryingFind(By.id("packing"))) .perform(); Utils.retryingFindAndClick(By.linkText(Utils.settings .getJSONObject("一级供应室装配组").getString("名称2"))); frame = Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); /*** 一级供应室补充丢失的材料 ***/ assemble.assemble_supplementLoss(); /*** 一级供应室装配聚合包 ***/ frame = Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); assemble.assemble_ComboTousse(); /*** 一级供应室装配消毒物品 ***/ Utils.driver.switchTo().defaultContent(); frame = Utils.retryingFindAndSwitchToFrame(By.id("iframe_packing")); assemble.assemble_success1(); assemble.after(); /*** 一级供应室装配敷料包、器械包、自定义器械包 ***/ assemble.init(); assemble.assemble_Scrap(); Utils.driver.switchTo().defaultContent(); frame = 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(); PackingHistory ph = new PackingHistory(); 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"))); frame = Utils.retryingFindAndSwitchToFrame(By .id("iframe_reviewPacking")); 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.retryingFindAndClick(By .xpath("//span[contains(text(), '个人桌面')]")); Disinfection disinfection = new Disinfection(); moveover = new Actions(Utils.driver); moveover.moveToElement( Utils.retryingFind(By.id("sterilizationRecord"))).perform(); Utils.retryingFindAndClick(By.linkText(Utils.settings .getJSONObject("灭菌炉分组").getString("大型压力蒸汽"))); frame = 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_use one = new One_use(); 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")); frame = 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.after(); /*** 临床登记使用记录 ***/ System.out.print("登记使用记录开始:"); Utils.DateTime(); UserRecord userrecord = new UserRecord(); userrecord.init(); userrecord.UserRecord_success_ji(); /*** 临床归还借物 ***/ System.out.print("归还借物开始:"); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.retryingFindAndClick(By .xpath("//span[contains(text(), '个人桌面')]")); 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(); } }