示例#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";
  }
  @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";
  }
示例#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");
 }
  @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')]"));
  }
示例#5
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;
  }
示例#6
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;
  }
示例#7
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;
  }
  @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("退保未成功");
    }
  }