package test_4_1; import org.testng.annotations.Test; import org.testng.annotations.BeforeMethod; import org.testng.AssertJUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import test_4_1.tools.Utils; /** * @author cherry 2016-09-29 * */ /*** 广东省人民医院临床科室申请器械包、敷料包、一次性物品、外来器械、借物 ***/ public class Gdsy { @BeforeMethod public void before() { try { Utils.DateTime(); Login login = new Login(); login.init(); login.login_clinicNoWarnig(); Utils.driver.findElement(By.id("recyclingApplicationVersion2")) .click(); WebElement frame = Utils.driver.findElement(By .id("iframe_recyclingApplicationVersion2")); Utils.driver.switchTo().frame(frame); System.out.println("广东省人民医院临床科室向一级供应室申请器械包、敷料包"); Utils.driver.findElement(By.id("tousseApplication")).click(); Thread.sleep(1000); Apply apply = new Apply(); apply.apply_gdsy_sets(); Thread.sleep(1000); Utils.driver.switchTo().frame(frame); System.out.println("广东省人民医院临床科室向一级供应室申请一次性物品"); Utils.driver.findElement(By.id("diposableGoodsApplication")) .click(); Thread.sleep(1000); apply.apply_gdsy_oneuse(); Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); System.out.println("广东省人民医院临床科室向一级供应室申请借物"); Utils.driver.findElement(By.id("borrowManager")).click(); Thread.sleep(1000); frame = Utils.driver.findElement(By.id("iframe_borrowManager")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//button[contains(text(), '借物')]")).click(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); apply.apply_borrow(); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); System.out.println("广东省人民医院临床科室向一级供应室申请外来器械"); Utils.driver.findElement(By.id("foreignTousseApplication")).click(); frame = Utils.driver.findElement(By .id("iframe_foreignTousseApplication")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//button[contains(text(), '添加')]")).click(); Thread.sleep(500); apply.apply_foreignSetInformation(); Thread.sleep(500); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//button[contains(text(), '添加')]")).click(); apply.apply_foreignSet(); Thread.sleep(1000); apply.after(); } catch (Exception e) { e.printStackTrace(); AssertJUnit.fail(e.getMessage()); } } /*** 广东省人民医院供应室流程 ***/ @Test public void all() { try { /*** 一级供应室回收 ***/ Utils.DateTime(); Recyle recyle = new Recyle(); recyle.init(); Thread.sleep(1000); System.out.println("一级供应室回收带标识牌的回收单"); recyle.recyle_recyleSignboardAndDropAndScrap(); recyle.after(); recyle.init(); System.out.println("一级供应室回收单确认"); recyle.recyle_confirm(); Thread.sleep(1000); System.out.println("一级供应室回收申请单"); recyle.recyle_oneSupplyRoomSignboard(); recyle.after(); recyle.init(); System.out.println("一级供应室自定义回收外来器械"); WebElement bodyElement = Utils.driver.findElement(By .tagName("body")); bodyElement.sendKeys(Utils.settings.getJSONObject("临床科室") .getString("条码") + "\n"); Thread.sleep(1000); Utils.retryingFindClickFirstCellOfTable(By .id("awaitForRecycleTable")); recyle.recyle_custom(); System.out.println("一级供应室回收外来器械"); recyle.recyle_Foreign(); recyle.after(); /*** 一级供应室清洗 ***/ Utils.DateTime(); Wash wash = new Wash(); wash.init(); wash.wash_oneSupplyRoom(); wash.after(); /*** 一级供应室装配器械包 ***/ Utils.DateTime(); Assemble assemble = new Assemble(); assemble.init(); assemble.assemble_success1(); /*** 一级供应室装配敷料包 ***/ assemble.assemble_dressing(); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); System.out.println("一级供应室材料入库用于补充丢失、报损"); /*** 材料入库报损丢失的材料 ***/ Materials_Godown_Entry entry = new Materials_Godown_Entry(); entry.Materials_Godown_Entry_2success(); entry.after(); /*** 一级供应室装配器械包 ***/ assemble.init(); // assemble.assemble_SignboardAndDropAndScrap(); Utils.driver.navigate().refresh(); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); Actions moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.driver.findElement(By.id("packing"))) .perform(); Thread.sleep(1000); Utils.driver.findElement( By.linkText(Utils.settings.getJSONObject("一级供应室装配组") .getString("名称3"))).click(); WebElement frame = Utils.driver .findElement(By.id("iframe_packing")); Utils.driver.switchTo().frame(frame); Thread.sleep(1000); assemble.assemble_success1(); /*** 一级供应室拆包装配外来器械包 ***/ assemble.assemble_unpackForgein(); /*** 一级供应室整包装配外来器械包 ***/ Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); moveover = new Actions(Utils.driver); moveover.moveToElement(Utils.driver.findElement(By.id("packing"))) .perform(); Thread.sleep(1000); Utils.driver.findElement( By.linkText(Utils.settings.getJSONObject("一级供应室装配组") .getString("名称4"))).click(); frame = Utils.driver.findElement(By.id("iframe_packing")); Utils.driver.switchTo().frame(frame); assemble.assemble_forgeinSet(); /*** 一级供应室自定义装配 ***/ assemble.assemble_custom(); /*** 一级供应室灭菌装载入筐 ***/ Utils.DateTime(); Disinfection disifection = new Disinfection(); disifection.disinfection_loading(); /*** 一级供应室外部代理灭菌 ***/ disifection.disinfection_gdsy_agent_outside(); /*** 外部代理灭菌装载入筐 ***/ disifection.disinfection_loading_outside(); /*** 一级供应室失败后重新灭菌成功 ***/ Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); moveover = new Actions(Utils.driver); moveover.moveToElement( Utils.driver.findElement(By.id("sterilizationRecord"))) .perform(); Thread.sleep(1000); Utils.driver.findElement( By.linkText(Utils.settings.getJSONObject("一级供应室灭菌炉") .getString("分类"))).click(); Thread.sleep(1000); frame = Utils.driver.findElement(By .id("iframe_sterilizationRecord")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//button[contains(text(), '添加')]")).click(); Thread.sleep(1000); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); disifection.disinfection_gdsy_failAndSuccess(); Thread.sleep(3000); /*** 一级供应室中断后继续灭菌成功 ***/ currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); frame = Utils.driver.findElement(By .id("iframe_sterilizationRecord")); Utils.driver.switchTo().frame(frame); Thread.sleep(3000); Utils.driver.findElement( By.xpath("//button[contains(text(), '添加')]")).click(); Thread.sleep(1000); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Thread.sleep(3000); disifection.disinfection_gdsy_stopAndSuccess(); disifection.after(); /*** 一级供应室入库一次性物品 ***/ Utils.DateTime(); One_use oneUse = new One_use(); oneUse.init(); oneUse.One_use_Entry_success(); /*** 一级供应室退库一次性物品 ***/ Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); Utils.driver.findElement(By.id("enterpriseView")).click(); frame = Utils.driver.findElement(By.id("iframe_enterpriseView")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//div/span[contains(text(), '后台监控管理')]")).click(); Thread.sleep(500); Utils.driver.findElement( By.xpath("//div/a/span[contains(text(), '一次性物品管理')]")) .click(); Thread.sleep(500); oneUse.One_use_cancle_success(); /*** 一级供应室发货 ***/ Utils.DateTime(); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); Utils.driver.findElement(By.id("invoicePlan")).click(); frame = Utils.driver.findElement(By.id("iframe_invoicePlan")); Utils.driver.switchTo().frame(frame); Thread.sleep(1000); String name = Utils.settings.getJSONObject("临床科室").getString("名称"); Utils.driver.findElement( By.xpath("//a[contains(text(), '" + name + "')]")).click(); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Delivery delivery = new Delivery(); delivery.Delivery_oneSupplyRoom(); delivery.after(); /*** 临床用户登记使用记录 ***/ Utils.DateTime(); UserRecord userRecord = new UserRecord(); Login login = new Login(); login.init(); login.login_clinicNoWarnig(); Utils.driver.findElement(By.id("useRecord")).click(); frame = Utils.driver.findElement(By.id("iframe_useRecord")); Utils.driver.switchTo().frame(frame); Thread.sleep(1000); Utils.driver.findElement( By.xpath("//button[contains(text(), '添加')]")).click(); Utils.driver.switchTo().defaultContent(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); userRecord.UserRecord_success_ji(); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); Thread.sleep(1000); Apply apply = new Apply(); apply.apply_borrow_return(); apply.after(); /*** 一级供应室登记退货记录 ***/ Utils.DateTime(); Reject reject = new Reject(); reject.init(); reject.Reject_one_use_success(); Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); Utils.driver.findElement(By.id("enterpriseView")).click(); frame = Utils.driver.findElement(By.id("iframe_enterpriseView")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//div/span[contains(text(), '后台监控管理')]")).click(); Thread.sleep(500); Utils.driver.findElement( By.xpath("//div/a/span[contains(text(), '退货记录管理')]")) .click(); Thread.sleep(500); Utils.driver.findElement( By.xpath("//div/a/span[contains(text(), '退货记录信息')]")) .click(); Thread.sleep(500); reject.Reject_set_success_ou(); Thread.sleep(1000); /*** 一级供应室退货后发货 ***/ Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); Thread.sleep(1000); delivery.Delivery_rejectsendout(); /*** 一级供应室登记领用 ***/ Utils.DateTime(); Utils.driver.navigate().refresh(); currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); Utils.tryToCloseWarningWindow(); Utils.driver.findElement(By.id("enterpriseView")).click(); frame = Utils.driver.findElement(By.id("iframe_enterpriseView")); Utils.driver.switchTo().frame(frame); Utils.driver.findElement( By.xpath("//div/span[contains(text(), '后台监控管理')]")).click(); Thread.sleep(500); Utils.driver.findElement( By.xpath("//div/a/span[contains(text(), '消毒供应中心物品领用')]")) .click(); Thread.sleep(500); Utils.driver .findElement( By.xpath("//ul/li/div/a/span[contains(text(), '消毒供应中心物品领用')]")) .click(); Consume consume = new Consume(); consume.Consume_success(); Thread.sleep(1000); Utils.driver.switchTo().defaultContent(); Utils.driver.findElement( By.xpath("//span[contains(text(), '个人桌面')]")).click(); Utils.changeWindow(); Utils.DateTime(); System.out.println("一级供应室回收还物单"); recyle.recyle_return(); Thread.sleep(1000); /*** 一级供应室回收使用记录转换的申请单 ***/ System.out.println("一级供应室回收使用记录转换的申请单"); // 获取body对象,sendKeys更加可靠。actions.click()的方式在win10,IE11下不可靠 bodyElement = Utils.driver.findElement(By.tagName("body")); // 输入临床科室条码,只显示临床科室的申请单 bodyElement.sendKeys(Utils.settings.getJSONObject("临床科室") .getString("条码") + "\n"); Thread.sleep(1000); Utils.retryingFindClickFirstCellOfTable(By .id("awaitForRecycleTable")); String recyclingFormWindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(recyclingFormWindowhandle); recyle.recyle_userRecordApply(); Thread.sleep(1000); Utils.DateTime(); recyle.after(); } catch (Exception e) { e.printStackTrace(); AssertJUnit.fail(e.getMessage()); } } }