Index: ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/Reject.java =================================================================== diff -u -r20396 -r20488 --- ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/Reject.java (.../Reject.java) (revision 20396) +++ ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/Reject.java (.../Reject.java) (revision 20488) @@ -1,14 +1,20 @@ package test.forgon.disinfectsystem.selenium; +import java.util.function.Function; + import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; import org.testng.annotations.BeforeMethod; import org.testng.AssertJUnit; import org.apache.commons.collections4.CollectionUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.os.WindowsUtils; +import org.openqa.selenium.support.ui.Wait; +import test.forgon.disinfectsystem.selenium.factory.WaitFactory; import test.forgon.disinfectsystem.selenium.tools.JSWaiter; import test.forgon.disinfectsystem.selenium.tools.Utils; @@ -117,27 +123,43 @@ .xpath("//button[contains(text(), '添加')]")); String currentwindowhandle = Utils.driver.getWindowHandle(); Utils.driver.switchTo().window(currentwindowhandle); + Utils.switchToDefaultContent(); String name = Utils.settings.getJSONObject("临床科室").getString("名称"); JSWaiter.waitUntilJQueryReady(); - if (Utils.isFind(Utils.retryingFind(By.id("depart")))) { - Utils.retryingFindAndClick(By.id("depart")); - Utils.retryingFindAndSendKeys(By.id("depart"), Keys.DOWN); - Utils.retryingFindAndClick(By - .xpath("//div/div/div[contains(text(), '" + name - + "')]")); - Utils.retryingFindAndSendKeys(By.id("warehouse"), Keys.DOWN); - Utils.retryingFindAndSendKeys(By.id("warehouse"), "\n"); - Utils.retryingFindAndSendKeys(By.id("package1"), Utils.settings - .getJSONObject("一级供应室材料").getString("拼音码")); - Utils.retryingFindAndSendKeys(By.id("package1"), "\n"); - Utils.retryingFindAndSendKeys(By.id("count1"), "1" + "\n"); - Utils.retryingFindAndClick(By - .xpath("//button[contains(text(), '保存')]")); - currentwindowhandle = Utils.driver.getWindowHandle(); - Utils.driver.switchTo().window(currentwindowhandle); - Utils.retryingFindAndClick(By - .xpath("//button[contains(text(), '是')]")); - JSWaiter.waitUntilJQueryReady(); + if (Utils.isFind(Utils.retryingFind(By.id("returnGoodsRecordWin")))) { + if (Utils.isFind(Utils.retryingFind(By.id("depart")))) { + JSWaiter.waitUntilJQueryReady(); + Utils.retryingFindAndClick(By.id("depart")); + Utils.retryingFindAndSendKeys(By.id("depart"), Keys.DOWN); + Utils.retryingFindAndClick(By.id("returnOfPeopleBarcode")); + Utils.retryingFindAndSendKeys(By.id("depart"), Keys.DOWN); + Wait wait = WaitFactory.createDefaultWait(); + wait.until(new Function() { + public WebElement apply(WebDriver driver) { + return Utils.retryingFind(By + .xpath("//div/div/div[contains(text(), '" + + name + "')]")); + } + }); + Utils.retryingFindAndClick(By + .xpath("//div/div/div[contains(text(), '" + name + + "')]")); + Utils.retryingFindAndSendKeys(By.id("warehouse"), Keys.DOWN); + Utils.retryingFindAndSendKeys(By.id("warehouse"), "\n"); + Utils.retryingFindAndSendKeys( + By.id("package1"), + Utils.settings.getJSONObject("一级供应室材料").getString( + "拼音码")); + Utils.retryingFindAndSendKeys(By.id("package1"), "\n"); + Utils.retryingFindAndSendKeys(By.id("count1"), "1" + "\n"); + Utils.retryingFindAndClick(By + .xpath("//button[contains(text(), '保存')]")); + currentwindowhandle = Utils.driver.getWindowHandle(); + Utils.driver.switchTo().window(currentwindowhandle); + Utils.retryingFindAndClick(By + .xpath("//button[contains(text(), '是')]")); + JSWaiter.waitUntilJQueryReady(); + } } } catch (Exception e) { e.printStackTrace();