コード例 #1
0
 @Override
 public Match findElement(int numRetries) {
   Match match = null;
   for (int i = 0; i <= numRetries; i++) {
     try {
       Region region =
           labelObj
               .getLabelImageLocation()
               .getRegionOfImageObject(browser, labelObj.getLabelImage());
       Assert.assertNotNull(region, "Failed to find Label '" + labelObj.getDisplayName() + "'.");
       match = new Match(region, 1);
       break;
     } catch (Throwable th) {
       if (i == numRetries) {
         Assert.fail(
             "Unable to find Label '"
                 + labelObj.getDisplayName()
                 + "'. Reason timeout(waited for "
                 + (numRetries * 2)
                 + " seconds).",
             th);
         break;
       }
     }
     browser.waitForSeconds(2);
   }
   return match;
 }
コード例 #2
0
  @Override
  public List<Match> findElements(int numRetries) {
    Region r = labelObj.getLabelImageLocation().getRegion(browser);

    return new ImageObject(UIObjectType.label, labelObj.getDisplayName(), labelObj.getLabelImage())
        .getValidator(browser, r)
        .findElements(numRetries);
  }
コード例 #3
0
 public void click(ImageSection imageSection, int numRetries) {
   try {
     Match match = findElement(numRetries);
     getImageSection(match, imageSection).click();
   } catch (Throwable th) {
     Assert.fail(
         "Failed to perform mouse click on Label '" + labelObj.getDisplayName() + "'.", th);
   }
 }
コード例 #4
0
 @Override
 public void doubleClick(int numRetries) {
   try {
     Match match = findElement(numRetries);
     match.doubleClick();
   } catch (Throwable th) {
     Assert.fail(
         "Failed to perform mouse double click on Label '" + labelObj.getDisplayName() + "'.", th);
   }
 }
コード例 #5
0
 @Override
 public void performKeyDown(Keys keys, int numRetries) {
   try {
     Match match = findElement(numRetries);
     match.click();
     match.keyDown(seleniumToSikuliKeyConverter(keys));
   } catch (Throwable th) {
     Assert.fail("Failed to perform keyDown on Label '" + labelObj.getDisplayName() + "'.", th);
   }
 }
コード例 #6
0
 @Override
 public void release(int numRetries) {
   try {
     Match match = findElement(numRetries);
     match.mouseDown(Button.LEFT);
   } catch (Throwable th) {
     Assert.fail(
         "Failed to perform mouse clickAndHold on Label '" + labelObj.getDisplayName() + "'.", th);
   }
 }
コード例 #7
0
  public void dragAndDrop(ImageObject target, Region targetRegion, int numRetries) {
    try {
      Match sourceElem = findElement(numRetries);
      Match targetElem = target.getValidator(browser, targetRegion).findElement(numRetries);

      Assert.assertNotNull(sourceElem, "Failed to find Label '" + labelObj.getDisplayName() + "'.");
      Assert.assertNotNull(targetElem, "Failed to find element '" + target.getDisplayName() + "'.");

      sourceElem.drag(targetElem);
      sourceElem.dropAt(targetElem);
    } catch (Throwable th) {
      Assert.fail(
          "Failed to perform dragAndDrop from source '"
              + labelObj.getDisplayName()
              + "' to target '"
              + target.getDisplayName()
              + "'.",
          th);
    }
  }