예제 #1
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 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";
  }
  @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("退保未成功");
    }
  }