示例#1
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");
   }
 }
示例#2
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");
  }
示例#3
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;
  }