Ejemplo n.º 1
0
  @Test
  public void userToGroup() throws Exception {
    String user = "******";
    String group = "GroupZenoss3";

    Common.Login(sClient, ZenossConstants.adminUserName, ZenossConstants.adminPassword);
    Thread.sleep(12000);

    // Click on Advanced
    sClient.click("link=Advanced");
    sClient.waitForPageToLoad("30000");
    // Click Users
    sClient.click("link=Users");
    sClient.waitForPageToLoad("30000");

    // Create new User
    Users.addNewUser(sClient, user, "*****@*****.**");

    // Create new Group
    Users.newUserGroup(sClient, group);
    Thread.sleep(3000);
    selenese.verifyTrue(sClient.isElementPresent("//a[text()='" + group + "']"));

    Thread.sleep(3000);
    // Add user to a group
    Users.UserToGroup(sClient, user, group);

    testCaseResult = "p";
  }
 @Before
 public void setUp() throws Exception {
   selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.xyz.cn/");
   selenium.start();
   selenium.windowMaximize();
   selenium.setSpeed("200");
 }
Ejemplo n.º 3
0
 public static void Login(DefaultSelenium sClient, String username, String password)
     throws Exception {
   sClient.open("/");
   sClient.type("username", username);
   sClient.type("__ac_password", password);
   sClient.click("submitbutton");
   sClient.waitForPageToLoad("40000");
 }
Ejemplo n.º 4
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    String serverHost = "localhost";
    int serverPort = 4444;
    String browserStartCommand = "*chrome";
    String browserURL = "http://localhost:3000/";

    defaultSelenium = new DefaultSelenium(serverHost, serverPort, browserStartCommand, browserURL);
    defaultSelenium.start();
    defaultSelenium.open("");
    defaultSelenium.windowMaximize();
  }
Ejemplo n.º 5
0
  @Override
  public void start() {
    if (_openonce) {
      _cyclecount++;

      if (!isBrowserOpened) {
        super.start();
        isBrowserOpened = true;
      }
    } else {
      super.start();
    }
  }
Ejemplo n.º 6
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   selenese = new SeleneseTestCase();
   sClient =
       new DefaultSelenium(
           ZenossConstants.SeleniumHubHostname,
           4444,
           ZenossConstants.browser,
           ZenossConstants.testedMachine) {
         public void open(String url) {
           commandProcessor.doCommand("open", new String[] {url, "true"});
         }
       };
   sClient.start();
   sClient.deleteAllVisibleCookies();
 }
Ejemplo n.º 7
0
  public void waitForValue(Element elem) {
    String locator = replaceParam(elem.getAttributeValue("locator"));
    String timeout = elem.getAttributeValue("timeout");
    String outParam = elem.getAttributeValue("out");

    int maxTime = Integer.parseInt(timeout);
    int maxSeconds = maxTime / 1000;
    logger.debug("waitForValue: locator=" + locator + " timeout=" + timeout);
    String foundValue = null;
    for (int second = 0; ; second++) {
      if (second >= maxSeconds) {
        throw new SeleniumException("waitForValue exceeded timeout: " + maxTime);
      }
      try {
        // getValue throws an exception if it can't find locator
        // - sleep for 1 sec and try again
        // - otherwise break as we found the value
        foundValue = sel.getValue(locator);
        if (outParam != null) {
          this.addParam(outParam, foundValue);
        }
        break;
      } catch (Exception e) {
        // wait for 1 second and then resume
        try {
          Thread.sleep(1000);
        } catch (InterruptedException threadE) {
          threadE.printStackTrace();
        }
      }
    }
  }
Ejemplo n.º 8
0
 /*
  * Waits for specified text to appear on the specified target
  * */
 public static void waitForText(String target, String text, DefaultSelenium sClient)
     throws Exception {
   byte count = 0;
   while (!sClient.getText(target).matches(text)) {
     Thread.sleep(1000);
     count++;
     if (count > 30) throw new Exception("Text not found");
   }
 }
Ejemplo n.º 9
0
  @Test
  public void testOpenHomePage() throws Exception {

    String welcomeMsg = defaultSelenium.getText("//div[@class='header']/p");
    String twitterImg = "//img[@alt='Twitter.com']";

    Assert.assertEquals("hello R2D2", welcomeMsg);

    defaultSelenium.click("//div[@class='content']/div/p/a");

    Assert.assertNotNull(twitterImg);

    // defaultSelenium.wait(20000);

    // defaultSelenium.click("//input[@id='username_or_email']");

    defaultSelenium.type("Username or Email:", "testmona1234");
  }
Ejemplo n.º 10
0
  public void getValueCmd(Element elem) {
    String locator = replaceParam(elem.getAttributeValue("locator"));
    String outParam = elem.getAttributeValue("out");

    logger.debug("getValueCmd: locator=" + locator);
    String foundValue = sel.getValue(locator);
    if (outParam != null) {
      this.addParam(outParam, foundValue);
    }
  }
  @BeforeClass
  public static void setUp() throws Exception {
    System.out.println("*** Starting selenium ... ***");
    RemoteControlConfiguration seleniumConfig = new RemoteControlConfiguration();
    seleniumConfig.setPort(4444);
    seleniumServer = new SeleniumServer(seleniumConfig);
    seleniumServer.start();

    String host = System.getProperty("myParam", "localhost");
    selenium = createSeleniumClient("http://" + host + ":" + "8080/client/");
    selenium.start();
    System.out.println("*** Started selenium ***");
  }
  public void testEmptyPassword() {
    wb.get("/appserver/jsp/amlogin.jsp?lg=cgam");
    element.findElement(By.id("usuario"));

    //		mySelenium.type(userTextLocator,user);
    //		mySelenium.type(passTextLocator, "");
    //		System.out.println(mySelenium.isElementPresent(aceptarButton));
    //		mySelenium.focus(aceptarButton);
    //		mySelenium.click(aceptarButton);
    //		System.out.println(mySelenium.getAlert());
    //

    mySelenium.captureScreenshot(screenShootPath + "\\testEmptyPassword.jpg");
  }
Ejemplo n.º 13
0
 /**
  * @param elem Will save a browser's screenshot in runtime/logs Need to be called with
  *     captureEntirePageScreenshot and the name of the test case example :
  *     <captureEntirePageScreenshot value="CommEventCreateOpportunity"/>
  */
 private void captureEntirePageScreenshotCmd(Element elem) {
   Long now = UtilDateTime.nowTimestamp().getTime();
   String imageName = replaceParam(elem.getAttributeValue("value")) + "-" + now.toString();
   logger.debug("captureEntirePageScreenshot: " + imageName);
   imagePath = "runtime/logs/" + imageName + ".png";
   try {
     String base64Screenshot = sel.captureEntirePageScreenshotToString("");
     byte[] decodedScreenshot = Base64.decodeBase64(base64Screenshot.getBytes());
     FileOutputStream fos = new FileOutputStream(new File(imagePath));
     fos.write(decodedScreenshot);
     fos.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 14
0
  /*
   * This method assumes that IP Services page is already loaded
   * and inserts a new Service Organizer at IP Services view
   * @author Jose Rodriguez
   * @param organizerName or name of the organizer to add
   * @param sClient Selenium client connection
   * @return Boolean true if the organizer was successfully added or false in other way
   * @throws Generic Exception
   */
  public static boolean addIpServiceOrganizer(String organizerName, DefaultSelenium sClient)
      throws Exception {
    sClient.click("//table[@id='footer_add_button']/tbody/tr[2]/td[2]/em");
    sClient.click("//span[text()='Add Service Organizer']");
    Thread.sleep(2000);
    sClient.type("//input[@name='id']", organizerName);
    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent(
            "//table[@class='x-btn   x-btn-noicon ']//button[text()='Submit']")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    sClient.click("//button[text()='Submit']");
    // Refresh page and wait for Organizers list to load
    sClient.click("link=IP Services");
    sClient.waitForPageToLoad("30000");
    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent("//ul[@class='x-tree-node-ct']/li")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    boolean result = true;

    if (!sClient.isElementPresent(
        "//span[@class='node-text' and text()='" + organizerName + "']")) {
      result = false;
      throw new Exception("The new service organizer is not found");
    }

    return result;
  }
  @Test
  public void should_login_with_valid_credentials() {
    browser.open(deploymentUrl.toString().replaceFirst("/$", "") + "/login.jsf");

    browser.type("id=loginForm:username", "user1");
    browser.type("id=loginForm:password", "demo");
    browser.click("id=loginForm:login");
    browser.waitForPageToLoad("15000");

    Assert.assertTrue(
        "User should be logged in!",
        browser.isElementPresent("xpath=//li[contains(text(),'Welcome')]"));
  }
 @AfterClass
 public static void tearDown() throws Exception {
   selenium.stop();
 }
 @Test
 public void testForNews() {
   selenium.open("/index.html");
   assertTrue(selenium.isTextPresent("More News"));
 }
 @AfterClass
 public void tearDown() {
   selenium.stop();
 }
Ejemplo n.º 19
0
 public static void openUrl(DefaultSelenium sClient, String url) {
   sClient.open(url);
 }
Ejemplo n.º 20
0
  public void runCommands(List<Element> nodes) throws TestCaseException {
    for (Element elem : nodes) {
      String thisName = elem.getName();
      if ("type" == elem.getName()) {
        typeCmd(elem);

      } else if ("setParam" == thisName) {
        setParam(elem);
      } else if ("clickAt" == thisName) {
        clickAt(elem);
      } else if ("waitForValue" == thisName) {
        waitForValue(elem);
      } else if ("waitForCondition" == thisName) {
        waitForCondition(elem);
      } else if ("loadData" == thisName) {
        loadData(elem);
      } else if ("jythonRunner" == thisName) {
        jythonRunner(elem);
      } else if ("groovyRunner" == thisName) {
        groovyRunner(elem);
      } else if ("dataLoop" == thisName) {
        dataLoop(elem);
      } else if ("remoteRequest" == thisName) {
        remoteRequest(elem);
      } else if ("selectPopup" == thisName) {
        selectPopup(elem);
      } else if ("getAllWindowIds" == thisName) {
        getAllWindowIds(elem);
      } else if ("captureTextInPage" == thisName) {
        captureTextInPageCmd(elem);
      } else if ("getSelectedLabel" == thisName) {
        getSelectedLabel(elem);
      } else if ("getSelectedValue" == thisName) {
        getSelectedValue(elem);
      } else if ("getSelectedId" == thisName) {
        getSelectedId(elem);
      } else if ("testcase" == thisName) {
        testcase(elem);
      } else if ("assertContains" == thisName) {
        assertContains(elem);
      } else if ("assertNotContains" == thisName) {
        assertNotContains(elem);
      } else if ("getHtmlSource" == thisName) {
        getHtmlSource(elem);
      } else if ("getBodyText" == thisName) {
        getBodyText(elem);
      } else if ("setup" == thisName) {
        continue; // setup is handled previously
      } else if ("print" == thisName) {
        printCmd(elem);
      } else if ("waitForPageToLoad" == thisName) {
        waitForPageToLoadCmd(elem);
      } else if ("getSelectedIds" == thisName) {
        getSelectedIdsCmd(elem);
      } else if ("copy" == thisName) {
        copyCmd(elem);
      } else if ("append" == thisName) {
        appendCmd(elem);
      } else if ("loadParameter" == thisName) {
        loadParameter(elem);
      } else if ("partialRunDependency" == thisName) {
        partialRunDependency(elem);
      } else if ("if" == thisName) {
        ifCmd(elem);
      } else if ("open" == thisName) {
        openCmd(elem);
      } else if ("click" == thisName) {
        clickCmd(elem);
      } else if ("check" == thisName) {
        checkCmd(elem);
      } else if ("uncheck" == thisName) {
        uncheckCmd(elem);
      } else if ("getValue" == thisName) {
        getValueCmd(elem);
      } else if ("select" == thisName) {
        selectCmd(elem);
      } else if ("uniqueId" == thisName) {
        uniqueIdCmd(elem);
      } else if ("randomAlphaString" == thisName) {
        randomAlphaStringCmd(elem);
      } else if ("randomString" == thisName) {
        randomStringCmd(elem);
      } else if ("setSpeed" == thisName) {
        setSpeed(elem);
      } else if ("openWindow" == thisName) {
        openWindow(elem);
      } else if ("selectWindow" == thisName) {
        selectWindow(elem);
      } else if ("assertConfirmation" == thisName) {
        assertConfirmation(elem);
      } else if ("captureEntirePageScreenshot" == thisName) {
        captureEntirePageScreenshotCmd(elem);
      } else if ("runScript" == thisName) {
        runScript(elem);
      } else if ("closeBrowser" == thisName) {
        sel.stop();
      } else {
        logger.info("Undefined command calling by reflection for command: " + thisName);
        callByReflection(elem);
      }
    }
  }
 public void execute(String t, String v, DefaultSelenium ds) {
   System.out.println("Executing type command ... " + v);
   System.out.println("Target is " + t);
   System.out.println("Value is " + v);
   ds.type(t, v);
 }
Ejemplo n.º 22
0
  /*
   * This method assumes that IP Services page is already loaded
   * and inserts a new Service at the specified service organizer
   * @author Jose Rodriguez
   * @param serviceName or name of the service to be added
   * @param organizerName or name of the organizer where service will be added
   * @param sClient Selenium client connection
   * @return Boolean true if the organizer was successfully added or false in other way
   * @throws Generic Exception
   */
  public static boolean addIpService(
      String serviceName, String organizerName, DefaultSelenium sClient) throws Exception {
    // Click Service organizer
    sClient.click("//span[@class='node-text' and text()='" + organizerName + "']");
    // Add service at organizer
    sClient.click("//table[@id='footer_add_button']/tbody/tr[2]/td[2]/em");
    sClient.click("//span[text()='Add Service']");
    Thread.sleep(2000);
    sClient.type("//input[@name='id']", serviceName);
    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent(
            "//table[@class='x-btn   x-btn-noicon ']//button[text()='Submit']")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    sClient.click("//button[text()='Submit']");
    // Refresh IP Services page to load
    sClient.click("link=IP Services");
    sClient.waitForPageToLoad("30000");
    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent("//ul[@class='x-tree-node-ct']/li")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent("//div[@class='x-grid3-body']/div")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    // Click on the Service Organizer and give 10 seconds for service list to load
    sClient.click("//span[@class='node-text' and text()='" + organizerName + "']");
    Thread.sleep(10000);

    // Type service name in the search box and wait for it to show up in the service list
    sClient.typeKeys("//input[@id='name']", serviceName);
    for (int second = 0; ; second++) {
      if (second >= 60) break;
      try {
        if (sClient.isElementPresent(
            "//div[@class='x-grid3-cell-inner x-grid3-col-name' and text()='" + serviceName + "']"))
          break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    boolean result = true;

    if (!sClient.isElementPresent(
        "//div[@class='x-grid3-cell-inner x-grid3-col-name' and text()='" + serviceName + "']")) {
      result = false;
      throw new Exception("Either the service or the service organizer were not found");
    }

    return result;
  }
 @BeforeClass
 public void setUp() {
   selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.clickondetroit.com/");
   selenium.start();
 }
 public void closeSelenium() {
   mySelenium.stop();
 }
Ejemplo n.º 25
0
 @AfterClass
 public static void tearDownAfterClass() throws Exception {
   sClient.stop();
   TestlinkXMLRPC.UpdateTestCaseResult(testCaseID, ZenossConstants.testPlanID, testCaseResult);
 }
Ejemplo n.º 26
0
  /*
   * Insert and model a Single Device on the specified class
   * @author Alvaro Rivera
   * @param name Name or IP of the device to add
   * @param dClass Class where to add the device
   * @param snmpComm SNMP Community of the device
   * @param Selenium client connection
   * @return Boolean true if the device was successfully added or false in other way
   * @throws Generic Exception
   */
  public static boolean addDevice(
      String name, String dClass, String snmpComm, DefaultSelenium sClient) throws Exception {
    sClient.click("link=Infrastructure");
    sClient.waitForPageToLoad("30000");
    Thread.sleep(8000);
    sClient.click("//table[@id='adddevice-button']/tbody/tr[2]/td[2]/em");
    Thread.sleep(1500);
    sClient.click("//a[@id='addsingledevice-item']");
    Thread.sleep(7000);

    sClient.type("//input[@id='add-device-name']", name);
    sClient.click("//input[@id='add-device_class']");
    Thread.sleep(5000);
    sClient.click("//div//div[31]");
    sClient.getText("//div//div[text() = '" + dClass + "']");

    sClient.click("link=More...");
    Thread.sleep(2000);
    sClient.type("ext-comp-1156", snmpComm);

    sClient.click("//table[@id='addsingledevice-submit']/tbody/tr[2]/td[2]");
    Thread.sleep(5000);
    sClient.click("//*[contains(text(), 'View Job Log')]");
    sClient.waitForPageToLoad("120000");

    waitForElement("Job completed at", sClient);

    boolean result = true;

    if (sClient.isTextPresent("Traceback")) {
      result = false;
      throw new Exception("There is tracebacks presents on the Model's process log");
    } else if (sClient.isTextPresent("Error")) {
      result = false;
      throw new Exception("There is Error presents on the Model's process log");
    }
    return result;
  }
  @Test
  public void addDeviceUserCommand() throws Exception {
    String device = "test-hpux.zenoss.loc";
    String deviceClass = "/Server/SSH/HP-UX";
    String commandID = "NewUserCommand";
    String description = "New command";
    String command = "echo name = ${here/id}";

    Common.Login(sClient, ZenossConstants.adminUserName, ZenossConstants.adminPassword);
    Thread.sleep(12000);
    // Add device
    Device addDevice = new Device("" + device + "", sClient);
    addDevice.add("" + deviceClass + "");
    Thread.sleep(10000);

    sClient.click("link=Infrastructure");
    sClient.waitForPageToLoad("30000");
    Thread.sleep(3000);
    // Click on the device
    sClient.click("link=" + device + "");
    sClient.waitForPageToLoad("30000");
    // Click on Administration
    Thread.sleep(5000);
    sClient.click("//ul[@id='ext-gen243']/div/li[7]/div/a/span");
    Thread.sleep(15000);
    // Click on gear menu on Define Commands
    sClient.click("//table[@id='ext-comp-1001']/tbody/tr[2]/td[2]/em");
    // Click on Add User Command...
    Thread.sleep(1000);
    sClient.click("UserCommandlistaddUserCommand");
    // Enter Command ID
    Thread.sleep(1000);
    sClient.type("new_id", commandID);
    // Click Ok button
    Thread.sleep(1000);
    sClient.click("//input[@id='dialog_submit']");
    Thread.sleep(5000);
    selenese.verifyTrue(sClient.isTextPresent("User command " + commandID + " has been created."));
    // Enter a Description
    sClient.type("description:text", description);
    // Enter a Command
    sClient.type("command:text", command);
    // Type admin password
    sClient.type("password", ZenossConstants.adminPassword);
    sClient.selectWindow("null");
    // Click on Save button
    Thread.sleep(2000);
    sClient.click("//input[@value=' Save ']");
    Thread.sleep(6000);
    selenese.verifyTrue(sClient.isElementPresent("//a[text()='" + commandID + "']"));
    selenese.verifyTrue(sClient.isElementPresent("//td[text()='" + description + "']"));
    selenese.verifyTrue(sClient.isElementPresent("//td[text()='" + command + "']"));

    testCaseResult = "p";
  }
Ejemplo n.º 28
0
 public static void waitForElement(String element, DefaultSelenium sClient) throws Exception {
   byte count = 0;
   while (!sClient.isElementPresent(element)) Thread.sleep(1000);
   count++;
   if (count > 30) throw new Exception("Element not found");
 }
Ejemplo n.º 29
0
  /** @param args */
  public static void main(String[] args) {

    DefaultSelenium selenium =
        new DefaultSelenium("localhost", 4444, "*firefox", "http://www.hdfcbank.com/");
    selenium.start();
    selenium.open("/");
    selenium.windowMaximize();
    selenium.windowFocus();

    System.out.println("----------Generating window names from first window-----------");
    String winnames[] = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.click("//*[@id='loginsubmit']");

    System.out.println("----------Generating window names from second window-----------");

    winnames = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.selectWindow(winnames[1]);
    selenium.waitForPopUp(winnames[1], "50000");

    selenium.click("//*[@id='wrapper']/div[2]/div[2]/ul/li[1]/a");

    System.out.println("----------Generating window names from second window-----------");

    winnames = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.selectWindow(winnames[2]);
    selenium.waitForPopUp(winnames[2], "50000");

    selenium.type(
        "//html/body/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr[5]/td[2]/input",
        "Raman");

    selenium.close();
    selenium.selectWindow(winnames[1]);
    selenium.close();
  }
  @Test
  public void testTuiBao_XJ() throws Exception {
    selenium.open("/");
    selenium.click("lra24");
    selenium.waitForPageToLoad("30000");
    selenium.type("username", "api-xiejie");
    selenium.type("input2", "654321");
    selenium.click("loginBut");
    // 前台投保获得订单号
    String orderID;
    Ins_Front inf = new Ins_Front();
    orderID = inf.buy_YJX(selenium, "华泰“安达天下”国际旅游保险成人计划标准款", 8257, 1);

    selenium.type("payPwd", "65432100");
    selenium.click("subAcc");
    selenium.waitForPageToLoad("30000");
    // 调用数据库,根据订单号获得投保单号
    /*String u = "192.168.1.217";
    Connection conn = DBManager.getConnection(u);*/
    CommSql sql = new CommSql();
    // AppDTO[] app=sql.getAppInfo(conn,orderID,"");
    AppDTO[] app = sql.getAppInfo(orderID);
    String AppID;
    AppID = app[0].getAppId();
    Thread.sleep(30000);
    // 在新窗口中打开后台
    String url = "http://cst.xyz.cn";
    String win = "window";
    selenium.openWindow(url, win);
    selenium.waitForPopUp("window", "30000");
    selenium.selectWindow("window");

    selenium.type("textfield2", "xiejie");
    selenium.type("textfield", "654321");
    selenium.click("//button[@type='submit']");
    selenium.waitForPageToLoad("30000");
    selenium.click("link=保单管理");
    selenium.waitForPageToLoad("30000");
    selenium.type("APP_ID", AppID);
    selenium.click("searchBtn");
    selenium.waitForPageToLoad("30000");

    selenium.click("link=退保登记");
    selenium.waitForPageToLoad("30000");
    selenium.type("policySurrenderDto.applyReason", "12345");
    selenium.type("policySurrenderDto.applyName", "谢洁");
    selenium.type("policySurrenderDto.applyTel", "86509906");
    selenium.select("idtype", "label=军官证");
    selenium.click("//option[@value='armcard']");
    selenium.type("policySurrenderDto.cardNo", "123");
    selenium.click("surrenderCheck");
    // 上传文件
    Thread.sleep(10000);
    String baseRoot = System.getProperty("user.dir");
    String CancelINSAffixUp = null;
    Properties p = new Properties();
    InputStream in = new FileInputStream(new File("src/test/resources/instest-sys.properties"));
    p.load(in);
    CancelINSAffixUp = baseRoot + p.getProperty("CancelINSAffixUp");
    Runtime.getRuntime().exec(CancelINSAffixUp);
    // Runtime.getRuntime().exec("D:\\ins-seleniumTest\\src\\test\\resources\\AutoIt\\CancelINSAffixUp.exe");
    Thread.sleep(15000);
    selenium.click("link=上传");
    Thread.sleep(15000);

    selenium.click("//button[@type='submit']");
    Thread.sleep(15000);
    // 查询数据库,获取保单ID
    // AppDTO policy=sql.getPolicyInfo(conn,AppID);
    PolicyDTO policy = sql.getPolicyInfo(AppID);
    String policyID;
    policyID = policy.getPolicyNo();
    Thread.sleep(30000);
    // 开始退保
    selenium.type("POLICY_NO", policyID);
    selenium.click("searchBtn");
    selenium.waitForPageToLoad("30000");
    selenium.click("link=处理");
    selenium.waitForPageToLoad("30000");
    selenium.click("surrenderCheck");
    selenium.click("toAudit");
    selenium.waitForPageToLoad("30000");
    selenium.type("POLICY_NO", policyID);
    selenium.click("link=审核");
    selenium.waitForPageToLoad("30000");
    selenium.click("surrenderCheck");
    selenium.click("//input[@name=\"policySurrenderDto.surrenderStatus\"][1]");
    selenium.click("//button[@type='submit']");

    // 查询保单状态
    Thread.sleep(30000);
    // AppDTO policy1=sql.getPolicyInfo(conn,AppID);
    PolicyDTO policy1 = sql.getPolicyInfo(AppID);
    int policyStatus = policy1.getPolicyStatus();
    if (policyStatus == 2) {
      System.out.print("退保成功");
    } else {
      System.out.print("退保未成功");
    }
  }