@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";
  }
Example #2
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";
  }
Example #3
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')]"));
  }
Example #5
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;
  }
Example #6
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");
 }